Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
12c9ae0d
Commit
12c9ae0d
authored
Apr 11, 2004
by
Andrew Morton
Committed by
Linus Torvalds
Apr 11, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] ppc64: Add PMCs to sysfs
From: Anton Blanchard <anton@samba.org> Add PMCs to sysfs.
parent
c1a86d3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
12 deletions
+125
-12
arch/ppc64/kernel/sysfs.c
arch/ppc64/kernel/sysfs.c
+108
-0
include/asm-ppc64/processor.h
include/asm-ppc64/processor.h
+17
-12
No files found.
arch/ppc64/kernel/sysfs.c
View file @
12c9ae0d
...
...
@@ -4,7 +4,113 @@
#include <linux/smp.h>
#include <linux/percpu.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <asm/current.h>
#include <asm/processor.h>
#include <asm/cputable.h>
#include <asm/hvcall.h>
/* PMC stuff */
/* XXX convert to rusty's on_one_cpu */
static
unsigned
long
run_on_cpu
(
unsigned
long
cpu
,
unsigned
long
(
*
func
)(
unsigned
long
),
unsigned
long
arg
)
{
cpumask_t
old_affinity
=
current
->
cpus_allowed
;
unsigned
long
ret
;
/* should return -EINVAL to userspace */
if
(
set_cpus_allowed
(
current
,
cpumask_of_cpu
(
cpu
)))
return
0
;
ret
=
func
(
arg
);
set_cpus_allowed
(
current
,
old_affinity
);
return
ret
;
}
#define SYSFS_PMCSETUP(NAME, ADDRESS) \
static unsigned long read_##NAME(unsigned long junk) \
{ \
return mfspr(ADDRESS); \
} \
static unsigned long write_##NAME(unsigned long val) \
{ \
mtspr(ADDRESS, val); \
return 0; \
} \
static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
{ \
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
return sprintf(buf, "%lx\n", val); \
} \
static ssize_t store_##NAME(struct sys_device *dev, const char *buf, \
size_t count) \
{ \
struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
unsigned long val; \
int ret = sscanf(buf, "%lx", &val); \
if (ret != 1) \
return -EINVAL; \
run_on_cpu(cpu->sysdev.id, write_##NAME, val); \
return count; \
}
SYSFS_PMCSETUP
(
mmcr0
,
SPRN_MMCR0
);
SYSFS_PMCSETUP
(
mmcr1
,
SPRN_MMCR1
);
SYSFS_PMCSETUP
(
mmcra
,
SPRN_MMCRA
);
SYSFS_PMCSETUP
(
pmc1
,
SPRN_PMC1
);
SYSFS_PMCSETUP
(
pmc2
,
SPRN_PMC2
);
SYSFS_PMCSETUP
(
pmc3
,
SPRN_PMC3
);
SYSFS_PMCSETUP
(
pmc4
,
SPRN_PMC4
);
SYSFS_PMCSETUP
(
pmc5
,
SPRN_PMC5
);
SYSFS_PMCSETUP
(
pmc6
,
SPRN_PMC6
);
SYSFS_PMCSETUP
(
pmc7
,
SPRN_PMC7
);
SYSFS_PMCSETUP
(
pmc8
,
SPRN_PMC8
);
SYSFS_PMCSETUP
(
purr
,
SPRN_PURR
);
static
SYSDEV_ATTR
(
mmcr0
,
0600
,
show_mmcr0
,
store_mmcr0
);
static
SYSDEV_ATTR
(
mmcr1
,
0600
,
show_mmcr1
,
store_mmcr1
);
static
SYSDEV_ATTR
(
mmcra
,
0600
,
show_mmcra
,
store_mmcra
);
static
SYSDEV_ATTR
(
pmc1
,
0600
,
show_pmc1
,
store_pmc1
);
static
SYSDEV_ATTR
(
pmc2
,
0600
,
show_pmc2
,
store_pmc2
);
static
SYSDEV_ATTR
(
pmc3
,
0600
,
show_pmc3
,
store_pmc3
);
static
SYSDEV_ATTR
(
pmc4
,
0600
,
show_pmc4
,
store_pmc4
);
static
SYSDEV_ATTR
(
pmc5
,
0600
,
show_pmc5
,
store_pmc5
);
static
SYSDEV_ATTR
(
pmc6
,
0600
,
show_pmc6
,
store_pmc6
);
static
SYSDEV_ATTR
(
pmc7
,
0600
,
show_pmc7
,
store_pmc7
);
static
SYSDEV_ATTR
(
pmc8
,
0600
,
show_pmc8
,
store_pmc8
);
static
SYSDEV_ATTR
(
purr
,
0600
,
show_purr
,
NULL
);
static
void
__init
register_cpu_pmc
(
struct
sys_device
*
s
)
{
sysdev_create_file
(
s
,
&
attr_mmcr0
);
sysdev_create_file
(
s
,
&
attr_mmcr1
);
if
(
cur_cpu_spec
->
cpu_features
&
CPU_FTR_MMCRA
)
sysdev_create_file
(
s
,
&
attr_mmcra
);
sysdev_create_file
(
s
,
&
attr_pmc1
);
sysdev_create_file
(
s
,
&
attr_pmc2
);
sysdev_create_file
(
s
,
&
attr_pmc3
);
sysdev_create_file
(
s
,
&
attr_pmc4
);
sysdev_create_file
(
s
,
&
attr_pmc5
);
sysdev_create_file
(
s
,
&
attr_pmc6
);
if
(
cur_cpu_spec
->
cpu_features
&
CPU_FTR_PMC8
)
{
sysdev_create_file
(
s
,
&
attr_pmc7
);
sysdev_create_file
(
s
,
&
attr_pmc8
);
}
if
(
cur_cpu_spec
->
cpu_features
&
CPU_FTR_SMT
)
sysdev_create_file
(
s
,
&
attr_purr
);
}
/* NUMA stuff */
#ifdef CONFIG_NUMA
static
struct
node
node_devices
[
MAX_NUMNODES
];
...
...
@@ -60,6 +166,8 @@ static int __init topology_init(void)
#endif
register_cpu
(
c
,
cpu
,
parent
);
register_cpu_pmc
(
&
c
->
sysdev
);
sysdev_create_file
(
&
c
->
sysdev
,
&
attr_physical_id
);
}
...
...
include/asm-ppc64/processor.h
View file @
12c9ae0d
...
...
@@ -235,8 +235,6 @@
#define SPRN_IMMR 0x27E
/* Internal Memory Map Register */
#define SPRN_L2CR 0x3F9
/* Level 2 Cache Control Regsiter */
#define SPRN_LR 0x008
/* Link Register */
#define SPRN_MMCR0 0x3B8
/* Monitor Mode Control Register 0 */
#define SPRN_MMCR1 0x3BC
/* Monitor Mode Control Register 1 */
#define SPRN_PBL1 0x3FC
/* Protection Bound Lower 1 */
#define SPRN_PBL2 0x3FE
/* Protection Bound Lower 2 */
#define SPRN_PBU1 0x3FD
/* Protection Bound Upper 1 */
...
...
@@ -244,10 +242,7 @@
#define SPRN_PID 0x3B1
/* Process ID */
#define SPRN_PIR 0x3FF
/* Processor Identification Register */
#define SPRN_PIT 0x3DB
/* Programmable Interval Timer */
#define SPRN_PMC1 0x3B9
/* Performance Counter Register 1 */
#define SPRN_PMC2 0x3BA
/* Performance Counter Register 2 */
#define SPRN_PMC3 0x3BD
/* Performance Counter Register 3 */
#define SPRN_PMC4 0x3BE
/* Performance Counter Register 4 */
#define SPRN_PURR 0x135
/* Processor Utilization of Resources Register */
#define SPRN_PVR 0x11F
/* Processor Version Register */
#define SPRN_RPA 0x3D6
/* Required Physical Address Register */
#define SPRN_SDA 0x3BF
/* Sampled Data Address Register */
...
...
@@ -307,17 +302,26 @@
#define WRS_SYSTEM 3
/* WDT forced system reset */
#define TSR_PIS 0x08000000
/* PIT Interrupt Status */
#define TSR_FIS 0x04000000
/* FIT Interrupt Status */
#define SPRN_UMMCR0 0x3A8
/* User Monitor Mode Control Register 0 */
#define SPRN_UMMCR1 0x3AC
/* User Monitor Mode Control Register 0 */
#define SPRN_UPMC1 0x3A9
/* User Performance Counter Register 1 */
#define SPRN_UPMC2 0x3AA
/* User Performance Counter Register 2 */
#define SPRN_UPMC3 0x3AD
/* User Performance Counter Register 3 */
#define SPRN_UPMC4 0x3AE
/* User Performance Counter Register 4 */
#define SPRN_USIA 0x3AB
/* User Sampled Instruction Address Register */
#define SPRN_XER 0x001
/* Fixed Point Exception Register */
#define SPRN_ZPR 0x3B0
/* Zone Protection Register */
#define SPRN_VRSAVE 0x100
/* Vector save */
/* Performance monitor SPRs */
#define SPRN_SIAR 780
#define SPRN_SDAR 781
#define SPRN_MMCRA 786
#define SPRN_PMC1 787
#define SPRN_PMC2 788
#define SPRN_PMC3 789
#define SPRN_PMC4 790
#define SPRN_PMC5 791
#define SPRN_PMC6 792
#define SPRN_PMC7 793
#define SPRN_PMC8 794
#define SPRN_MMCR0 795
#define SPRN_MMCR1 798
/* Short-hand versions for a number of the above SPRNs */
#define CTR SPRN_CTR
/* Counter Register */
...
...
@@ -343,6 +347,7 @@
#define __LR SPRN_LR
#define PVR SPRN_PVR
/* Processor Version */
#define PIR SPRN_PIR
/* Processor ID */
#define PURR SPRN_PURR
/* Processor Utilization of Resource Register */
#define RPA SPRN_RPA
/* Required Physical Address Register */
#define SDR1 SPRN_SDR1
/* MMU hash base register */
#define SPR0 SPRN_SPRG0
/* Supervisor Private Registers */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment