[PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field

Steven Rostedt posted 12 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field
Posted by Steven Rostedt 9 months, 1 week ago
From: Steven Rostedt <rostedt@goodmis.org>

The branch tracer currently checks the per CPU "disabled" field to know if
tracing is enabled or not for the CPU. As the "disabled" value is not used
anymore to turn of tracing generically, use tracing_tracer_is_on_cpu()
instead.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_branch.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 6d08a5523ce0..2a1a06eb7939 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -32,7 +32,6 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
 {
 	struct trace_array *tr = branch_tracer;
 	struct trace_buffer *buffer;
-	struct trace_array_cpu *data;
 	struct ring_buffer_event *event;
 	struct trace_branch *entry;
 	unsigned long flags;
@@ -54,8 +53,7 @@ probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
 
 	raw_local_irq_save(flags);
 	current->trace_recursion |= TRACE_BRANCH_BIT;
-	data = this_cpu_ptr(tr->array_buffer.data);
-	if (atomic_read(&data->disabled))
+	if (!tracer_tracing_is_on_cpu(tr, raw_smp_process_id()))
 		goto out;
 
 	trace_ctx = tracing_gen_ctx_flags(flags);
-- 
2.47.2
Re: [PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field
Posted by kernel test robot 9 months, 1 week ago
Hi Steven,

kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on linus/master v6.15-rc5 next-20250502]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Steven-Rostedt/tracing-mmiotrace-Remove-reference-to-unused-per-CPU-data-pointer/20250503-050317
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20250502205349.299144667%40goodmis.org
patch subject: [PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field
config: i386-buildonly-randconfig-002-20250505 (https://download.01.org/0day-ci/archive/20250505/202505051827.xKU53TzL-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250505/202505051827.xKU53TzL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505051827.xKU53TzL-lkp@intel.com/

All errors (new ones prefixed by >>):

>> kernel/trace/trace_branch.c:56:36: error: call to undeclared function 'raw_smp_process_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      56 |         if (!tracer_tracing_is_on_cpu(tr, raw_smp_process_id()))
         |                                           ^
   kernel/trace/trace_branch.c:56:36: note: did you mean 'safe_smp_processor_id'?
   arch/x86/include/asm/smp.h:140:12: note: 'safe_smp_processor_id' declared here
     140 | extern int safe_smp_processor_id(void);
         |            ^
   1 error generated.


vim +/raw_smp_process_id +56 kernel/trace/trace_branch.c

    29	
    30	static void
    31	probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
    32	{
    33		struct trace_array *tr = branch_tracer;
    34		struct trace_buffer *buffer;
    35		struct ring_buffer_event *event;
    36		struct trace_branch *entry;
    37		unsigned long flags;
    38		unsigned int trace_ctx;
    39		const char *p;
    40	
    41		if (current->trace_recursion & TRACE_BRANCH_BIT)
    42			return;
    43	
    44		/*
    45		 * I would love to save just the ftrace_likely_data pointer, but
    46		 * this code can also be used by modules. Ugly things can happen
    47		 * if the module is unloaded, and then we go and read the
    48		 * pointer.  This is slower, but much safer.
    49		 */
    50	
    51		if (unlikely(!tr))
    52			return;
    53	
    54		raw_local_irq_save(flags);
    55		current->trace_recursion |= TRACE_BRANCH_BIT;
  > 56		if (!tracer_tracing_is_on_cpu(tr, raw_smp_process_id()))
    57			goto out;
    58	
    59		trace_ctx = tracing_gen_ctx_flags(flags);
    60		buffer = tr->array_buffer.buffer;
    61		event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
    62						  sizeof(*entry), trace_ctx);
    63		if (!event)
    64			goto out;
    65	
    66		entry	= ring_buffer_event_data(event);
    67	
    68		/* Strip off the path, only save the file */
    69		p = f->data.file + strlen(f->data.file);
    70		while (p >= f->data.file && *p != '/')
    71			p--;
    72		p++;
    73	
    74		strscpy(entry->func, f->data.func);
    75		strscpy(entry->file, p);
    76		entry->constant = f->constant;
    77		entry->line = f->data.line;
    78		entry->correct = val == expect;
    79	
    80		trace_buffer_unlock_commit_nostack(buffer, event);
    81	
    82	 out:
    83		current->trace_recursion &= ~TRACE_BRANCH_BIT;
    84		raw_local_irq_restore(flags);
    85	}
    86	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field
Posted by kernel test robot 9 months, 1 week ago
Hi Steven,

kernel test robot noticed the following build errors:

[auto build test ERROR on trace/for-next]
[also build test ERROR on linus/master v6.15-rc4 next-20250502]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Steven-Rostedt/tracing-mmiotrace-Remove-reference-to-unused-per-CPU-data-pointer/20250503-050317
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20250502205349.299144667%40goodmis.org
patch subject: [PATCH 09/12] tracing: branch: Use trace_tracing_is_on_cpu() instead of "disabled" field
config: arc-randconfig-001-20250503 (https://download.01.org/0day-ci/archive/20250503/202505031738.buFg2SBt-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250503/202505031738.buFg2SBt-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505031738.buFg2SBt-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/trace/trace_branch.c: In function 'probe_likely_condition':
>> kernel/trace/trace_branch.c:56:43: error: implicit declaration of function 'raw_smp_process_id'; did you mean 'raw_smp_processor_id'? [-Wimplicit-function-declaration]
      56 |         if (!tracer_tracing_is_on_cpu(tr, raw_smp_process_id()))
         |                                           ^~~~~~~~~~~~~~~~~~
         |                                           raw_smp_processor_id


vim +56 kernel/trace/trace_branch.c

    29	
    30	static void
    31	probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
    32	{
    33		struct trace_array *tr = branch_tracer;
    34		struct trace_buffer *buffer;
    35		struct ring_buffer_event *event;
    36		struct trace_branch *entry;
    37		unsigned long flags;
    38		unsigned int trace_ctx;
    39		const char *p;
    40	
    41		if (current->trace_recursion & TRACE_BRANCH_BIT)
    42			return;
    43	
    44		/*
    45		 * I would love to save just the ftrace_likely_data pointer, but
    46		 * this code can also be used by modules. Ugly things can happen
    47		 * if the module is unloaded, and then we go and read the
    48		 * pointer.  This is slower, but much safer.
    49		 */
    50	
    51		if (unlikely(!tr))
    52			return;
    53	
    54		raw_local_irq_save(flags);
    55		current->trace_recursion |= TRACE_BRANCH_BIT;
  > 56		if (!tracer_tracing_is_on_cpu(tr, raw_smp_process_id()))
    57			goto out;
    58	
    59		trace_ctx = tracing_gen_ctx_flags(flags);
    60		buffer = tr->array_buffer.buffer;
    61		event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
    62						  sizeof(*entry), trace_ctx);
    63		if (!event)
    64			goto out;
    65	
    66		entry	= ring_buffer_event_data(event);
    67	
    68		/* Strip off the path, only save the file */
    69		p = f->data.file + strlen(f->data.file);
    70		while (p >= f->data.file && *p != '/')
    71			p--;
    72		p++;
    73	
    74		strscpy(entry->func, f->data.func);
    75		strscpy(entry->file, p);
    76		entry->constant = f->constant;
    77		entry->line = f->data.line;
    78		entry->correct = val == expect;
    79	
    80		trace_buffer_unlock_commit_nostack(buffer, event);
    81	
    82	 out:
    83		current->trace_recursion &= ~TRACE_BRANCH_BIT;
    84		raw_local_irq_restore(flags);
    85	}
    86	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki