On Sat, 2013-03-02 at 15:41 +0800, kbuild test robot wrote:
> tree: git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git tip/perf/core
> head: f44f8638e47c89fa5c612a18f324ba6222b69597
> commit: 50b85fe13be0878f13eecd36d1219828ba73316d [5/15] tracing: Replace the static global per_cpu arrays with allocated per_cpu
>
>
> sparse warnings: (new ones prefixed by >>)
>
> >> kernel/trace/trace_functions.c:79:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_functions.c:79:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_functions.c:79:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_functions.c:110:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_functions.c:110:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_functions.c:110:16: got struct trace_array_cpu *<noident>
I'm confused to exactly what sparse is complaining about?
It's barfing on every instance of my code that references a dynamically
allocated 'per_cpu' instance. Did I do that wrong?
Hmm, actually it seems to be complaining everywhere but in trace.c which
is where the per_cpu was allocated. Do I need to annotate the trace.h
header to specify (at least to sparse) that the pointer is allocated per
cpu?
-- Steve
> --
> kernel/trace/trace_functions_graph.c:187:15: sparse: symbol 'ftrace_return_to_handler' was not declared. Should it be static?
> >> kernel/trace/trace_functions_graph.c:268:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_functions_graph.c:268:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_functions_graph.c:268:16: got struct trace_array_cpu *<noident>
> kernel/trace/trace_functions_graph.c:283:5: sparse: symbol 'trace_graph_thresh_entry' was not declared. Should it be static?
> >> kernel/trace/trace_functions_graph.c:353:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_functions_graph.c:353:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_functions_graph.c:353:16: got struct trace_array_cpu *<noident>
> kernel/trace/trace_functions_graph.c:372:6: sparse: symbol 'trace_graph_thresh_return' was not declared. Should it be static?
> kernel/trace/trace_functions_graph.c:1358:6: sparse: symbol 'print_graph_headers' was not declared. Should it be static?
> --
> kernel/trace/trace_irqsoff.c:24:8: sparse: symbol 'tracing_cpu' was not declared. Should it be static?
> >> kernel/trace/trace_irqsoff.c:124:17: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_irqsoff.c:124:17: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_irqsoff.c:124:17: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_irqsoff.c:383:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_irqsoff.c:383:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_irqsoff.c:383:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_irqsoff.c:421:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_irqsoff.c:421:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_irqsoff.c:421:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_irqsoff.c:421:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_irqsoff.c:421:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_irqsoff.c:421:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_irqsoff.c:383:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_irqsoff.c:383:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_irqsoff.c:383:16: got struct trace_array_cpu *<noident>
> --
> >> kernel/trace/trace_kdb.c:29:29: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_kdb.c:29:29: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_kdb.c:29:29: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_kdb.c:86:29: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_kdb.c:86:29: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_kdb.c:86:29: got struct trace_array_cpu *<noident>
> --
> >> kernel/trace/trace_mmiotrace.c:333:40: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_mmiotrace.c:333:40: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_mmiotrace.c:333:40: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_mmiotrace.c:366:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_mmiotrace.c:366:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_mmiotrace.c:366:16: got struct trace_array_cpu *<noident>
> --
> >> kernel/trace/trace_sched_switch.c:72:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_switch.c:72:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_switch.c:72:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_switch.c:126:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_switch.c:126:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_switch.c:126:16: got struct trace_array_cpu *<noident>
> --
> >> kernel/trace/trace_sched_wakeup.c:92:17: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:92:17: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:92:17: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:356:20: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:356:20: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:356:20: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:368:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:368:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:368:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:390:21: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:390:21: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:390:21: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:438:20: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:438:20: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:438:20: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:461:16: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:461:16: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:461:16: got struct trace_array_cpu *<noident>
> >> kernel/trace/trace_sched_wakeup.c:475:21: sparse: incorrect type in initializer (different address spaces)
> kernel/trace/trace_sched_wakeup.c:475:21: expected void const [noderef] <asn:3>*__vpp_verify
> kernel/trace/trace_sched_wakeup.c:475:21: got struct trace_array_cpu *<noident>
>
> vim +79 kernel/trace/trace_functions.c
>
> 73
> 74 bit = trace_test_and_set_recursion(TRACE_FTRACE_START, TRACE_FTRACE_MAX);
> 75 if (bit < 0)
> 76 goto out;
> 77
> 78 cpu = smp_processor_id();
> > 79 data = per_cpu_ptr(tr->data, cpu);
> 80 if (!atomic_read(&data->disabled)) {
> 81 local_save_flags(flags);
> 82 trace_function(tr, ip, parent_ip, flags, pc);
> 83 }
> 84 trace_clear_recursion(bit);
> 85
> 86 out:
> 87 preempt_enable_notrace();
> 88 }
> 89
> 90 static void
> 91 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
> 92 struct ftrace_ops *op, struct pt_regs *pt_regs)
> 93 {
> 94 struct trace_array *tr = func_trace;
> 95 struct trace_array_cpu *data;
> 96 unsigned long flags;
> 97 long disabled;
> 98 int cpu;
> 99 int pc;
> 100
> 101 if (unlikely(!ftrace_function_enabled))
> 102 return;
> 103
> 104 /*
> 105 * Need to use raw, since this must be called before the
> 106 * recursive protection is performed.
> 107 */
> 108 local_irq_save(flags);
> 109 cpu = raw_smp_processor_id();
> > 110 data = per_cpu_ptr(tr->data, cpu);
> 111 disabled = atomic_inc_return(&data->disabled);
> 112
> 113 if (likely(disabled == 1)) {
>
> ---
> 0-DAY kernel build testing backend Open Source Technology Center
> http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
On Sat, 2013-03-02 at 08:12 -0500, Steven Rostedt wrote:
> Hmm, actually it seems to be complaining everywhere but in trace.c which
> is where the per_cpu was allocated. Do I need to annotate the trace.h
> header to specify (at least to sparse) that the pointer is allocated per
> cpu?
I guess I need this patch:
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index c597523..50a9c81 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -198,7 +198,7 @@ struct trace_array {
struct list_head systems;
struct list_head events;
struct task_struct *waiter;
- struct trace_array_cpu *data;
+ struct trace_array_cpu __percpu *data;
};
enum {
-- Steve
// add CC to Christopher.
On Sat, Mar 02, 2013 at 08:12:52AM -0500, Steven Rostedt wrote:
> On Sat, 2013-03-02 at 15:41 +0800, kbuild test robot wrote:
> > tree: git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git tip/perf/core
> > head: f44f8638e47c89fa5c612a18f324ba6222b69597
> > commit: 50b85fe13be0878f13eecd36d1219828ba73316d [5/15] tracing: Replace the static global per_cpu arrays with allocated per_cpu
> >
> >
> > sparse warnings: (new ones prefixed by >>)
> >
> > >> kernel/trace/trace_functions.c:79:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_functions.c:79:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_functions.c:79:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_functions.c:110:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_functions.c:110:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_functions.c:110:16: got struct trace_array_cpu *<noident>
>
> I'm confused to exactly what sparse is complaining about?
>
> It's barfing on every instance of my code that references a dynamically
> allocated 'per_cpu' instance. Did I do that wrong?
>
> Hmm, actually it seems to be complaining everywhere but in trace.c which
> is where the per_cpu was allocated. Do I need to annotate the trace.h
> header to specify (at least to sparse) that the pointer is allocated per
> cpu?
>
> -- Steve
>
>
> > --
> > kernel/trace/trace_functions_graph.c:187:15: sparse: symbol 'ftrace_return_to_handler' was not declared. Should it be static?
> > >> kernel/trace/trace_functions_graph.c:268:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_functions_graph.c:268:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_functions_graph.c:268:16: got struct trace_array_cpu *<noident>
> > kernel/trace/trace_functions_graph.c:283:5: sparse: symbol 'trace_graph_thresh_entry' was not declared. Should it be static?
> > >> kernel/trace/trace_functions_graph.c:353:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_functions_graph.c:353:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_functions_graph.c:353:16: got struct trace_array_cpu *<noident>
> > kernel/trace/trace_functions_graph.c:372:6: sparse: symbol 'trace_graph_thresh_return' was not declared. Should it be static?
> > kernel/trace/trace_functions_graph.c:1358:6: sparse: symbol 'print_graph_headers' was not declared. Should it be static?
> > --
> > kernel/trace/trace_irqsoff.c:24:8: sparse: symbol 'tracing_cpu' was not declared. Should it be static?
> > >> kernel/trace/trace_irqsoff.c:124:17: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_irqsoff.c:124:17: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_irqsoff.c:124:17: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_irqsoff.c:383:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_irqsoff.c:383:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_irqsoff.c:383:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_irqsoff.c:421:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_irqsoff.c:421:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_irqsoff.c:421:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_irqsoff.c:421:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_irqsoff.c:421:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_irqsoff.c:421:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_irqsoff.c:383:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_irqsoff.c:383:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_irqsoff.c:383:16: got struct trace_array_cpu *<noident>
> > --
> > >> kernel/trace/trace_kdb.c:29:29: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_kdb.c:29:29: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_kdb.c:29:29: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_kdb.c:86:29: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_kdb.c:86:29: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_kdb.c:86:29: got struct trace_array_cpu *<noident>
> > --
> > >> kernel/trace/trace_mmiotrace.c:333:40: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_mmiotrace.c:333:40: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_mmiotrace.c:333:40: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_mmiotrace.c:366:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_mmiotrace.c:366:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_mmiotrace.c:366:16: got struct trace_array_cpu *<noident>
> > --
> > >> kernel/trace/trace_sched_switch.c:72:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_switch.c:72:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_switch.c:72:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_switch.c:126:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_switch.c:126:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_switch.c:126:16: got struct trace_array_cpu *<noident>
> > --
> > >> kernel/trace/trace_sched_wakeup.c:92:17: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:92:17: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:92:17: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:356:20: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:356:20: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:356:20: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:368:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:368:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:368:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:390:21: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:390:21: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:390:21: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:438:20: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:438:20: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:438:20: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:461:16: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:461:16: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:461:16: got struct trace_array_cpu *<noident>
> > >> kernel/trace/trace_sched_wakeup.c:475:21: sparse: incorrect type in initializer (different address spaces)
> > kernel/trace/trace_sched_wakeup.c:475:21: expected void const [noderef] <asn:3>*__vpp_verify
> > kernel/trace/trace_sched_wakeup.c:475:21: got struct trace_array_cpu *<noident>
> >
> > vim +79 kernel/trace/trace_functions.c
> >
> > 73
> > 74 bit = trace_test_and_set_recursion(TRACE_FTRACE_START, TRACE_FTRACE_MAX);
> > 75 if (bit < 0)
> > 76 goto out;
> > 77
> > 78 cpu = smp_processor_id();
> > > 79 data = per_cpu_ptr(tr->data, cpu);
> > 80 if (!atomic_read(&data->disabled)) {
> > 81 local_save_flags(flags);
> > 82 trace_function(tr, ip, parent_ip, flags, pc);
> > 83 }
> > 84 trace_clear_recursion(bit);
> > 85
> > 86 out:
> > 87 preempt_enable_notrace();
> > 88 }
> > 89
> > 90 static void
> > 91 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
> > 92 struct ftrace_ops *op, struct pt_regs *pt_regs)
> > 93 {
> > 94 struct trace_array *tr = func_trace;
> > 95 struct trace_array_cpu *data;
> > 96 unsigned long flags;
> > 97 long disabled;
> > 98 int cpu;
> > 99 int pc;
> > 100
> > 101 if (unlikely(!ftrace_function_enabled))
> > 102 return;
> > 103
> > 104 /*
> > 105 * Need to use raw, since this must be called before the
> > 106 * recursive protection is performed.
> > 107 */
> > 108 local_irq_save(flags);
> > 109 cpu = raw_smp_processor_id();
> > > 110 data = per_cpu_ptr(tr->data, cpu);
> > 111 disabled = atomic_inc_return(&data->disabled);
> > 112
> > 113 if (likely(disabled == 1)) {
> >
> > ---
> > 0-DAY kernel build testing backend Open Source Technology Center
> > http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
>
On Sat, Mar 02, 2013 at 08:15:22AM -0500, Steven Rostedt wrote:
> On Sat, 2013-03-02 at 08:12 -0500, Steven Rostedt wrote:
>
> > Hmm, actually it seems to be complaining everywhere but in trace.c which
> > is where the per_cpu was allocated. Do I need to annotate the trace.h
> > header to specify (at least to sparse) that the pointer is allocated per
> > cpu?
>
> I guess I need this patch:
That's it! Verified with
make C=1 kernel/trace/trace_functions.o
Thanks,
Fengguang
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index c597523..50a9c81 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -198,7 +198,7 @@ struct trace_array {
> struct list_head systems;
> struct list_head events;
> struct task_struct *waiter;
> - struct trace_array_cpu *data;
> + struct trace_array_cpu __percpu *data;
> };
>
> enum {
>
> -- Steve
>
On Sat, Mar 2, 2013 at 5:23 AM, Fengguang Wu <[email protected]> wrote:
> That's it! Verified with
>
> make C=1 kernel/trace/trace_functions.o
You can use C=2 to run sparse without recompile the obj file.
Chris
On Sat, Mar 02, 2013 at 10:12:40PM -0800, Christopher Li wrote:
> On Sat, Mar 2, 2013 at 5:23 AM, Fengguang Wu <[email protected]> wrote:
> > That's it! Verified with
> >
> > make C=1 kernel/trace/trace_functions.o
>
> You can use C=2 to run sparse without recompile the obj file.
Got it, thanks!
Fengguang