diff options
author | Paul Mackerras <paulus@samba.org> | 2009-02-26 06:43:46 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2009-02-26 06:43:46 -0500 |
commit | f3dfd2656deb81a0addee4f4ceff66b50a387388 (patch) | |
tree | 2d43269668b2a468a2bd2988b1937f9a71d458b4 | |
parent | 742bd95ba96e19b3f7196c3a0834ebc17c8ba006 (diff) |
perfcounters: fix a few minor cleanliness issues
This fixes three issues noticed by Arnd Bergmann:
- Add #ifdef __KERNEL__ and move some things around in perf_counter.h
to make sure only the bits that userspace needs are exported to
userspace.
- Use __u64, __s64, __u32 types in the structs exported to userspace
rather than u64, s64, u32.
- Make the sys_perf_counter_open syscall available to the SPUs on
Cell platforms.
And one issue that I noticed in looking at the code again:
- Wrap the perf_counter_open syscall with SYSCALL_DEFINE4 so we get
the proper handling of int arguments on ppc64 (and some other 64-bit
architectures).
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/include/asm/systbl.h | 2 | ||||
-rw-r--r-- | include/linux/perf_counter.h | 43 | ||||
-rw-r--r-- | include/linux/syscalls.h | 9 | ||||
-rw-r--r-- | kernel/perf_counter.c | 6 |
4 files changed, 30 insertions, 30 deletions
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h index 4c8095f6bec0..d312eec8abb9 100644 --- a/arch/powerpc/include/asm/systbl.h +++ b/arch/powerpc/include/asm/systbl.h | |||
@@ -322,4 +322,4 @@ SYSCALL_SPU(epoll_create1) | |||
322 | SYSCALL_SPU(dup3) | 322 | SYSCALL_SPU(dup3) |
323 | SYSCALL_SPU(pipe2) | 323 | SYSCALL_SPU(pipe2) |
324 | SYSCALL(inotify_init1) | 324 | SYSCALL(inotify_init1) |
325 | SYSCALL(perf_counter_open) | 325 | SYSCALL_SPU(perf_counter_open) |
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 32cd1acb7386..186efaf49665 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -13,20 +13,8 @@ | |||
13 | #ifndef _LINUX_PERF_COUNTER_H | 13 | #ifndef _LINUX_PERF_COUNTER_H |
14 | #define _LINUX_PERF_COUNTER_H | 14 | #define _LINUX_PERF_COUNTER_H |
15 | 15 | ||
16 | #include <asm/atomic.h> | 16 | #include <linux/types.h> |
17 | #include <asm/ioctl.h> | 17 | #include <linux/ioctl.h> |
18 | |||
19 | #ifdef CONFIG_PERF_COUNTERS | ||
20 | # include <asm/perf_counter.h> | ||
21 | #endif | ||
22 | |||
23 | #include <linux/list.h> | ||
24 | #include <linux/mutex.h> | ||
25 | #include <linux/rculist.h> | ||
26 | #include <linux/rcupdate.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | |||
29 | struct task_struct; | ||
30 | 18 | ||
31 | /* | 19 | /* |
32 | * User-space ABI bits: | 20 | * User-space ABI bits: |
@@ -78,12 +66,12 @@ enum perf_counter_record_type { | |||
78 | * Hardware event to monitor via a performance monitoring counter: | 66 | * Hardware event to monitor via a performance monitoring counter: |
79 | */ | 67 | */ |
80 | struct perf_counter_hw_event { | 68 | struct perf_counter_hw_event { |
81 | s64 type; | 69 | __s64 type; |
82 | 70 | ||
83 | u64 irq_period; | 71 | __u64 irq_period; |
84 | u32 record_type; | 72 | __u32 record_type; |
85 | 73 | ||
86 | u32 disabled : 1, /* off by default */ | 74 | __u32 disabled : 1, /* off by default */ |
87 | nmi : 1, /* NMI sampling */ | 75 | nmi : 1, /* NMI sampling */ |
88 | raw : 1, /* raw event type */ | 76 | raw : 1, /* raw event type */ |
89 | inherit : 1, /* children inherit it */ | 77 | inherit : 1, /* children inherit it */ |
@@ -95,7 +83,7 @@ struct perf_counter_hw_event { | |||
95 | 83 | ||
96 | __reserved_1 : 23; | 84 | __reserved_1 : 23; |
97 | 85 | ||
98 | u64 __reserved_2; | 86 | __u64 __reserved_2; |
99 | }; | 87 | }; |
100 | 88 | ||
101 | /* | 89 | /* |
@@ -104,10 +92,24 @@ struct perf_counter_hw_event { | |||
104 | #define PERF_COUNTER_IOC_ENABLE _IO('$', 0) | 92 | #define PERF_COUNTER_IOC_ENABLE _IO('$', 0) |
105 | #define PERF_COUNTER_IOC_DISABLE _IO('$', 1) | 93 | #define PERF_COUNTER_IOC_DISABLE _IO('$', 1) |
106 | 94 | ||
95 | #ifdef __KERNEL__ | ||
107 | /* | 96 | /* |
108 | * Kernel-internal data types: | 97 | * Kernel-internal data types and definitions: |
109 | */ | 98 | */ |
110 | 99 | ||
100 | #ifdef CONFIG_PERF_COUNTERS | ||
101 | # include <asm/perf_counter.h> | ||
102 | #endif | ||
103 | |||
104 | #include <linux/list.h> | ||
105 | #include <linux/mutex.h> | ||
106 | #include <linux/rculist.h> | ||
107 | #include <linux/rcupdate.h> | ||
108 | #include <linux/spinlock.h> | ||
109 | #include <asm/atomic.h> | ||
110 | |||
111 | struct task_struct; | ||
112 | |||
111 | /** | 113 | /** |
112 | * struct hw_perf_counter - performance counter hardware details: | 114 | * struct hw_perf_counter - performance counter hardware details: |
113 | */ | 115 | */ |
@@ -293,4 +295,5 @@ static inline int perf_counter_task_disable(void) { return -EINVAL; } | |||
293 | static inline int perf_counter_task_enable(void) { return -EINVAL; } | 295 | static inline int perf_counter_task_enable(void) { return -EINVAL; } |
294 | #endif | 296 | #endif |
295 | 297 | ||
298 | #endif /* __KERNEL__ */ | ||
296 | #endif /* _LINUX_PERF_COUNTER_H */ | 299 | #endif /* _LINUX_PERF_COUNTER_H */ |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 88255d3261a4..28ef2be839c7 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -696,10 +696,7 @@ asmlinkage long sys_pipe(int __user *); | |||
696 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]); | 696 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]); |
697 | 697 | ||
698 | 698 | ||
699 | asmlinkage int sys_perf_counter_open( | 699 | asmlinkage long sys_perf_counter_open( |
700 | 700 | const struct perf_counter_hw_event __user *hw_event_uptr, | |
701 | struct perf_counter_hw_event *hw_event_uptr __user, | 701 | pid_t pid, int cpu, int group_fd); |
702 | pid_t pid, | ||
703 | int cpu, | ||
704 | int group_fd); | ||
705 | #endif | 702 | #endif |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index ad62965828d3..16b14ba99d34 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -1690,9 +1690,9 @@ perf_counter_alloc(struct perf_counter_hw_event *hw_event, | |||
1690 | * @cpu: target cpu | 1690 | * @cpu: target cpu |
1691 | * @group_fd: group leader counter fd | 1691 | * @group_fd: group leader counter fd |
1692 | */ | 1692 | */ |
1693 | asmlinkage int | 1693 | SYSCALL_DEFINE4(perf_counter_open, |
1694 | sys_perf_counter_open(struct perf_counter_hw_event *hw_event_uptr __user, | 1694 | const struct perf_counter_hw_event __user *, hw_event_uptr, |
1695 | pid_t pid, int cpu, int group_fd) | 1695 | pid_t, pid, int, cpu, int, group_fd) |
1696 | { | 1696 | { |
1697 | struct perf_counter *counter, *group_leader; | 1697 | struct perf_counter *counter, *group_leader; |
1698 | struct perf_counter_hw_event hw_event; | 1698 | struct perf_counter_hw_event hw_event; |