From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, axboe@kernel.dk,
rusty@rustcorp.com.au, akpm@linux-foundation.org,
ebiederm@xmission.com, tytso@mit.edu, Trond.Myklebust@netapp.com,
aelder@sgi.com, hch@infradead.org, viro@zeniv.linux.org.uk,
davem@davemloft.net, netdev@vger.kernel.org, x86@kernel.org,
mingo@redhat.com, fweisbec@gmail.com, dan.j.williams@intel.com,
borislav.petkov@amd.com, ying.huang@intel.com, lenb@kernel.org,
neilb@suse.de, cl@linux-foundation.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 7/8] percpu: add __percpu sparse annotations to hw_breakpoint
Date: Tue, 26 Jan 2010 00:22:14 +0900 [thread overview]
Message-ID: <1264432935-10453-8-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1264432935-10453-1-git-send-email-tj@kernel.org>
Add __percpu sparse annotations to hw_breakpoint.
These annotations are to make sparse consider percpu variables to be
in a different address space and warn if accessed without going
through percpu accessors. This patch doesn't affect normal builds.
per_cpu(nr_task_bp_pinned, cpu) is replaced with
&per_cpu(nr_task_bp_pinned[0], cpu). This is the same to the compiler
but allows per_cpu() macro to correctly drop __percpu designation for
the returned pointer.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
---
include/linux/hw_breakpoint.h | 8 ++++----
kernel/hw_breakpoint.c | 14 +++++++-------
samples/hw_breakpoint/data_breakpoint.c | 6 +++---
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index 41235c9..f462d3d 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -66,14 +66,14 @@ register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
perf_overflow_handler_t triggered,
int cpu);
-extern struct perf_event **
+extern struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered);
extern int register_perf_hw_breakpoint(struct perf_event *bp);
extern int __register_perf_hw_breakpoint(struct perf_event *bp);
extern void unregister_hw_breakpoint(struct perf_event *bp);
-extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events);
+extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
extern int reserve_bp_slot(struct perf_event *bp);
extern void release_bp_slot(struct perf_event *bp);
@@ -98,7 +98,7 @@ static inline struct perf_event *
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
perf_overflow_handler_t triggered,
int cpu) { return NULL; }
-static inline struct perf_event **
+static inline struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered) { return NULL; }
static inline int
@@ -107,7 +107,7 @@ static inline int
__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
static inline void
-unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { }
+unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
static inline int
reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
static inline void release_bp_slot(struct perf_event *bp) { }
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 50dbd59..11dae6d 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -74,7 +74,7 @@ static DEFINE_MUTEX(nr_bp_mutex);
static unsigned int max_task_bp_pinned(int cpu)
{
int i;
- unsigned int *tsk_pinned = per_cpu(nr_task_bp_pinned, cpu);
+ unsigned int *tsk_pinned = &per_cpu(nr_task_bp_pinned[0], cpu);
for (i = HBP_NUM -1; i >= 0; i--) {
if (tsk_pinned[i] > 0)
@@ -163,7 +163,7 @@ static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
count = task_bp_pinned(tsk);
- tsk_pinned = per_cpu(nr_task_bp_pinned, cpu);
+ tsk_pinned = &per_cpu(nr_task_bp_pinned[0], cpu);
if (enable) {
tsk_pinned[count]++;
if (count > 0)
@@ -377,17 +377,17 @@ EXPORT_SYMBOL_GPL(unregister_hw_breakpoint);
*
* @return a set of per_cpu pointers to perf events
*/
-struct perf_event **
+struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered)
{
- struct perf_event **cpu_events, **pevent, *bp;
+ struct perf_event * __percpu *cpu_events, **pevent, *bp;
long err;
int cpu;
cpu_events = alloc_percpu(typeof(*cpu_events));
if (!cpu_events)
- return ERR_PTR(-ENOMEM);
+ return (void __percpu __force *)ERR_PTR(-ENOMEM);
get_online_cpus();
for_each_online_cpu(cpu) {
@@ -415,7 +415,7 @@ fail:
put_online_cpus();
free_percpu(cpu_events);
- return ERR_PTR(err);
+ return (void __percpu __force *)ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
* unregister_wide_hw_breakpoint - unregister a wide breakpoint in the kernel
* @cpu_events: the per cpu set of events to unregister
*/
-void unregister_wide_hw_breakpoint(struct perf_event **cpu_events)
+void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events)
{
int cpu;
struct perf_event **pevent;
diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c
index c69cbe9..bd0f337 100644
--- a/samples/hw_breakpoint/data_breakpoint.c
+++ b/samples/hw_breakpoint/data_breakpoint.c
@@ -34,7 +34,7 @@
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
-struct perf_event **sample_hbp;
+struct perf_event * __percpu *sample_hbp;
static char ksym_name[KSYM_NAME_LEN] = "pid_max";
module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO);
@@ -61,8 +61,8 @@ static int __init hw_break_module_init(void)
attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R;
sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler);
- if (IS_ERR(sample_hbp)) {
- ret = PTR_ERR(sample_hbp);
+ if (IS_ERR((void __force *)sample_hbp)) {
+ ret = PTR_ERR((void __force *)sample_hbp);
goto fail;
}
--
1.6.4.2
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, axboe@kernel.dk,
rusty@rustcorp.com.au, akpm@linux-foundation.org,
ebiederm@xmission.com, tytso@mit.edu, Trond.Myklebust@netapp.com,
aelder@sgi.com, hch@
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 7/8] percpu: add __percpu sparse annotations to hw_breakpoint
Date: Tue, 26 Jan 2010 00:22:14 +0900 [thread overview]
Message-ID: <1264432935-10453-8-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1264432935-10453-1-git-send-email-tj@kernel.org>
Add __percpu sparse annotations to hw_breakpoint.
These annotations are to make sparse consider percpu variables to be
in a different address space and warn if accessed without going
through percpu accessors. This patch doesn't affect normal builds.
per_cpu(nr_task_bp_pinned, cpu) is replaced with
&per_cpu(nr_task_bp_pinned[0], cpu). This is the same to the compiler
but allows per_cpu() macro to correctly drop __percpu designation for
the returned pointer.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
---
include/linux/hw_breakpoint.h | 8 ++++----
kernel/hw_breakpoint.c | 14 +++++++-------
samples/hw_breakpoint/data_breakpoint.c | 6 +++---
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index 41235c9..f462d3d 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -66,14 +66,14 @@ register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
perf_overflow_handler_t triggered,
int cpu);
-extern struct perf_event **
+extern struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered);
extern int register_perf_hw_breakpoint(struct perf_event *bp);
extern int __register_perf_hw_breakpoint(struct perf_event *bp);
extern void unregister_hw_breakpoint(struct perf_event *bp);
-extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events);
+extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
extern int reserve_bp_slot(struct perf_event *bp);
extern void release_bp_slot(struct perf_event *bp);
@@ -98,7 +98,7 @@ static inline struct perf_event *
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
perf_overflow_handler_t triggered,
int cpu) { return NULL; }
-static inline struct perf_event **
+static inline struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered) { return NULL; }
static inline int
@@ -107,7 +107,7 @@ static inline int
__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
static inline void
-unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { }
+unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
static inline int
reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
static inline void release_bp_slot(struct perf_event *bp) { }
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 50dbd59..11dae6d 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -74,7 +74,7 @@ static DEFINE_MUTEX(nr_bp_mutex);
static unsigned int max_task_bp_pinned(int cpu)
{
int i;
- unsigned int *tsk_pinned = per_cpu(nr_task_bp_pinned, cpu);
+ unsigned int *tsk_pinned = &per_cpu(nr_task_bp_pinned[0], cpu);
for (i = HBP_NUM -1; i >= 0; i--) {
if (tsk_pinned[i] > 0)
@@ -163,7 +163,7 @@ static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
count = task_bp_pinned(tsk);
- tsk_pinned = per_cpu(nr_task_bp_pinned, cpu);
+ tsk_pinned = &per_cpu(nr_task_bp_pinned[0], cpu);
if (enable) {
tsk_pinned[count]++;
if (count > 0)
@@ -377,17 +377,17 @@ EXPORT_SYMBOL_GPL(unregister_hw_breakpoint);
*
* @return a set of per_cpu pointers to perf events
*/
-struct perf_event **
+struct perf_event * __percpu *
register_wide_hw_breakpoint(struct perf_event_attr *attr,
perf_overflow_handler_t triggered)
{
- struct perf_event **cpu_events, **pevent, *bp;
+ struct perf_event * __percpu *cpu_events, **pevent, *bp;
long err;
int cpu;
cpu_events = alloc_percpu(typeof(*cpu_events));
if (!cpu_events)
- return ERR_PTR(-ENOMEM);
+ return (void __percpu __force *)ERR_PTR(-ENOMEM);
get_online_cpus();
for_each_online_cpu(cpu) {
@@ -415,7 +415,7 @@ fail:
put_online_cpus();
free_percpu(cpu_events);
- return ERR_PTR(err);
+ return (void __percpu __force *)ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(register_wide_hw_breakpoint);
* unregister_wide_hw_breakpoint - unregister a wide breakpoint in the kernel
* @cpu_events: the per cpu set of events to unregister
*/
-void unregister_wide_hw_breakpoint(struct perf_event **cpu_events)
+void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events)
{
int cpu;
struct perf_event **pevent;
diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c
index c69cbe9..bd0f337 100644
--- a/samples/hw_breakpoint/data_breakpoint.c
+++ b/samples/hw_breakpoint/data_breakpoint.c
@@ -34,7 +34,7 @@
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
-struct perf_event **sample_hbp;
+struct perf_event * __percpu *sample_hbp;
static char ksym_name[KSYM_NAME_LEN] = "pid_max";
module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO);
@@ -61,8 +61,8 @@ static int __init hw_break_module_init(void)
attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R;
sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler);
- if (IS_ERR(sample_hbp)) {
- ret = PTR_ERR(sample_hbp);
+ if (IS_ERR((void __force *)sample_hbp)) {
+ ret = PTR_ERR((void __force *)sample_hbp);
goto fail;
}
--
1.6.4.2
next prev parent reply other threads:[~2010-01-25 15:19 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 15:22 [PATCHSET] percpu: add __percpu sparse annotations Tejun Heo
2010-01-25 15:22 ` [PATCH 1/8] percpu: add __percpu sparse annotations to core kernel subsystems Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 21:58 ` Christoph Lameter
2010-01-25 21:58 ` Christoph Lameter
2010-01-31 11:42 ` Paul E. McKenney
2010-01-31 11:42 ` Paul E. McKenney
2010-01-25 15:22 ` Tejun Heo
2010-01-25 15:22 ` [PATCH 2/8] percpu: add __percpu sparse annotations to fs Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 15:22 ` [PATCH 3/8] percpu: add __percpu sparse annotations to net Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 21:32 ` David Miller
2010-01-25 15:22 ` [PATCH 4/8] percpu: add __percpu sparse annotations to net drivers Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 21:33 ` David Miller
2010-01-25 15:22 ` [PATCH 5/8] percpu: add __percpu sparse annotations to x86 Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-26 1:06 ` H. Peter Anvin
2010-01-26 2:17 ` Tejun Heo
2010-02-01 3:30 ` H. Peter Anvin
2010-01-25 15:22 ` [PATCH 6/8] percpu: add __percpu sparse annotations to trace Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 15:35 ` Steven Rostedt
2010-01-25 15:22 ` Tejun Heo [this message]
2010-01-25 15:22 ` [PATCH 7/8] percpu: add __percpu sparse annotations to hw_breakpoint Tejun Heo
2010-01-26 0:19 ` Frederic Weisbecker
2010-01-26 0:48 ` Tejun Heo
2010-01-26 1:02 ` Frederic Weisbecker
2010-01-26 1:19 ` Tejun Heo
2010-01-26 2:01 ` Frederic Weisbecker
2010-01-26 2:10 ` Frederic Weisbecker
2010-01-26 2:13 ` Tejun Heo
2010-01-26 2:18 ` Frederic Weisbecker
2010-01-26 2:22 ` Frederic Weisbecker
2010-01-26 2:34 ` Tejun Heo
2010-01-26 2:35 ` Frederic Weisbecker
2010-01-26 2:47 ` Tejun Heo
2010-01-26 1:02 ` H. Peter Anvin
2010-01-26 2:06 ` Tejun Heo
2010-01-26 2:04 ` Al Viro
2010-01-26 2:16 ` Tejun Heo
2010-01-26 2:32 ` Al Viro
2010-01-26 2:43 ` Tejun Heo
2010-01-26 2:48 ` Al Viro
2010-01-26 3:10 ` Tejun Heo
2010-01-26 3:56 ` Al Viro
2010-01-26 1:06 ` H. Peter Anvin
2010-01-26 1:12 ` Frederic Weisbecker
2010-01-26 2:10 ` Tejun Heo
2010-01-25 15:22 ` [PATCH 8/8] percpu: add __percpu sparse annotations to what's left Tejun Heo
2010-01-25 15:22 ` Tejun Heo
2010-01-25 15:54 ` Borislav Petkov
2010-01-25 23:14 ` [PATCHSET] percpu: add __percpu sparse annotations Al Viro
2010-01-26 0:30 ` Tejun Heo
2010-02-02 5:37 ` Tejun Heo
2010-02-02 5:37 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1264432935-10453-8-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=Trond.Myklebust@netapp.com \
--cc=aelder@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=borislav.petkov@amd.com \
--cc=cl@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.