linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
@ 2026-06-29  9:58 Martin Weiss
  2026-06-29 10:47 ` Steven Rostedt
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Martin Weiss @ 2026-06-29  9:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Martin Weiss, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	linux-trace-kernel

Replace per-task counters with per-cpu increments to avoid race
conditions in the branch profiler fast path.

Fixes FIXME about atomicity.

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 kernel/trace/trace_branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index d8e97ad798f0..960bcb3d7dbf 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -213,11 +213,11 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 	 */
 	trace_likely_condition(f, val, expect);
 
-	/* FIXME: Make this atomic! */
+	/* use per-cpu counters to avoid contention */
 	if (val == expect)
-		f->data.correct++;
+		this_cpu_inc(f->data.correct);
 	else
-		f->data.incorrect++;
+		this_cpu_inc(f->data.incorrect);
 
 	user_access_restore(flags);
 }
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
  2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
@ 2026-06-29 10:47 ` Steven Rostedt
  2026-08-06 16:53 ` kernel test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2026-06-29 10:47 UTC (permalink / raw)
  To: Martin Weiss
  Cc: linux-kernel, Martin Weiss, Masami Hiramatsu, Mathieu Desnoyers,
	linux-trace-kernel

On Mon, 29 Jun 2026 16:58:38 +0700
Martin Weiss <martin.githubacc@gmail.com> wrote:

> Replace per-task counters with per-cpu increments to avoid race
> conditions in the branch profiler fast path.
> 
> Fixes FIXME about atomicity.
> 
> Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
> ---
>  kernel/trace/trace_branch.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
> index d8e97ad798f0..960bcb3d7dbf 100644
> --- a/kernel/trace/trace_branch.c
> +++ b/kernel/trace/trace_branch.c
> @@ -213,11 +213,11 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
>  	 */
>  	trace_likely_condition(f, val, expect);
>  
> -	/* FIXME: Make this atomic! */
> +	/* use per-cpu counters to avoid contention */
>  	if (val == expect)
> -		f->data.correct++;
> +		this_cpu_inc(f->data.correct);
>  	else
> -		f->data.incorrect++;
> +		this_cpu_inc(f->data.incorrect);

I don't think this does what you think it does.

Did you even test this? I'm guessing it would blow up in some fantastic
ways.

NAK.

-- Steve


>  
>  	user_access_restore(flags);
>  }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
  2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
  2026-06-29 10:47 ` Steven Rostedt
@ 2026-08-06 16:53 ` kernel test robot
  2026-08-06 19:38 ` kernel test robot
  2026-08-06 20:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-08-06 16:53 UTC (permalink / raw)
  To: Martin Weiss, linux-kernel
  Cc: oe-kbuild-all, Martin Weiss, Steven Rostedt, Masami Hiramatsu,
	Mathieu Desnoyers, linux-trace-kernel

Hi Martin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v7.2-rc6 next-20260806]
[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/Martin-Weiss/trace_branch-use-per-cpu-counters-for-correct-incorrect-stats/20260806-093445
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20260629095838.601926-1-Martin.weiss2410%40gmail.com
patch subject: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
config: arm64-randconfig-r062-20260806 (https://download.01.org/0day-ci/archive/20260807/202608070005.js0pMRDK-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260807/202608070005.js0pMRDK-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/202608070005.js0pMRDK-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/trace/trace_branch.c: In function 'ftrace_likely_update':
>> kernel/trace/trace_branch.c:198:6: warning: infinite recursion detected [-Winfinite-recursion]
     198 | void ftrace_likely_update(struct ftrace_likely_data *f, int val,
         |      ^~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/array_size.h:5,
                    from include/linux/kernel.h:16,
                    from include/linux/kallsyms.h:11,
                    from kernel/trace/trace_branch.c:7:
   include/linux/compiler.h:33:25: note: recursive call
      33 |                         ftrace_likely_update(&______f, ______r,         \
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      34 |                                              expect, is_constant);      \
         |                                              ~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
      68 |         (cond) ?                                        \
         |          ^~~~
   include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
      55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
         |                            ^~~~~~~~~~~~~~
   include/linux/preempt.h:238:9: note: in expansion of macro 'if'
     238 |         if (unlikely(__preempt_count_dec_and_test())) \
         |         ^~
   include/linux/compiler.h:47:26: note: in expansion of macro '__branch_check__'
      47 | #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
         |                          ^~~~~~~~~~~~~~~~
   include/linux/preempt.h:238:13: note: in expansion of macro 'unlikely'
     238 |         if (unlikely(__preempt_count_dec_and_test())) \
         |             ^~~~~~~~
   arch/arm64/include/asm/percpu.h:160:9: note: in expansion of macro 'preempt_enable_notrace'
     160 |         preempt_enable_notrace();                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/percpu.h:197:9: note: in expansion of macro '_pcp_protect'
     197 |         _pcp_protect(__percpu_add_case_64, pcp, val)
         |         ^~~~~~~~~~~~
   include/linux/percpu-defs.h:372:25: note: in expansion of macro 'this_cpu_add_8'
     372 |                 case 8: stem##8(variable, __VA_ARGS__);break;           \
         |                         ^~~~
   include/linux/percpu-defs.h:501:41: note: in expansion of macro '__pcpu_size_call'
     501 | #define this_cpu_add(pcp, val)          __pcpu_size_call(this_cpu_add_, pcp, val)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:511:41: note: in expansion of macro 'this_cpu_add'
     511 | #define this_cpu_inc(pcp)               this_cpu_add(pcp, 1)
         |                                         ^~~~~~~~~~~~
   kernel/trace/trace_branch.c:218:17: note: in expansion of macro 'this_cpu_inc'
     218 |                 this_cpu_inc(f->data.correct);
         |                 ^~~~~~~~~~~~
   include/linux/compiler.h:33:25: note: recursive call
      33 |                         ftrace_likely_update(&______f, ______r,         \
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      34 |                                              expect, is_constant);      \
         |                                              ~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
      68 |         (cond) ?                                        \
         |          ^~~~
   include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
      55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
         |                            ^~~~~~~~~~~~~~
   include/linux/preempt.h:238:9: note: in expansion of macro 'if'
     238 |         if (unlikely(__preempt_count_dec_and_test())) \
         |         ^~
   include/linux/compiler.h:47:26: note: in expansion of macro '__branch_check__'
      47 | #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
         |                          ^~~~~~~~~~~~~~~~
   include/linux/preempt.h:238:13: note: in expansion of macro 'unlikely'
     238 |         if (unlikely(__preempt_count_dec_and_test())) \
         |             ^~~~~~~~
   arch/arm64/include/asm/percpu.h:160:9: note: in expansion of macro 'preempt_enable_notrace'
     160 |         preempt_enable_notrace();                                       \
         |         ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/percpu.h:197:9: note: in expansion of macro '_pcp_protect'
     197 |         _pcp_protect(__percpu_add_case_64, pcp, val)
         |         ^~~~~~~~~~~~
   include/linux/percpu-defs.h:372:25: note: in expansion of macro 'this_cpu_add_8'
     372 |                 case 8: stem##8(variable, __VA_ARGS__);break;           \
         |                         ^~~~
   include/linux/percpu-defs.h:501:41: note: in expansion of macro '__pcpu_size_call'
     501 | #define this_cpu_add(pcp, val)          __pcpu_size_call(this_cpu_add_, pcp, val)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/percpu-defs.h:511:41: note: in expansion of macro 'this_cpu_add'
     511 | #define this_cpu_inc(pcp)               this_cpu_add(pcp, 1)
         |                                         ^~~~~~~~~~~~
   kernel/trace/trace_branch.c:220:17: note: in expansion of macro 'this_cpu_inc'
     220 |                 this_cpu_inc(f->data.incorrect);
         |                 ^~~~~~~~~~~~


vim +198 kernel/trace/trace_branch.c

52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  197  
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19 @198) void ftrace_likely_update(struct ftrace_likely_data *f, int val,
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  199) 			  int expect, int is_constant)
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  200  {
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  201  	unsigned long flags = user_access_save();
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  202  
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  203) 	/* A constant is always correct */
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  204) 	if (is_constant) {
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  205) 		f->constant++;
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  206) 		val = expect;
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  207) 	}
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  208  	/*
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  209  	 * I would love to have a trace point here instead, but the
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  210  	 * trace point code is so inundated with unlikely and likely
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  211  	 * conditions that the recursive nightmare that exists is too
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  212  	 * much to try to get working. At least for now.
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  213  	 */
068f530b3f274d kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  214) 	trace_likely_condition(f, val, expect);
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  215  
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  216  	/* use per-cpu counters to avoid contention */
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  217  	if (val == expect)
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  218  		this_cpu_inc(f->data.correct);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  219  	else
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  220  		this_cpu_inc(f->data.incorrect);
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  221  
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  222  	user_access_restore(flags);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  223  }
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  224  EXPORT_SYMBOL(ftrace_likely_update);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  225  

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
  2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
  2026-06-29 10:47 ` Steven Rostedt
  2026-08-06 16:53 ` kernel test robot
@ 2026-08-06 19:38 ` kernel test robot
  2026-08-06 20:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-08-06 19:38 UTC (permalink / raw)
  To: Martin Weiss, linux-kernel
  Cc: oe-kbuild-all, Martin Weiss, Steven Rostedt, Masami Hiramatsu,
	Mathieu Desnoyers, linux-trace-kernel

Hi Martin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v7.2-rc6 next-20260806]
[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/Martin-Weiss/trace_branch-use-per-cpu-counters-for-correct-incorrect-stats/20260806-093445
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20260629095838.601926-1-Martin.weiss2410%40gmail.com
patch subject: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
config: um-randconfig-r123-20260806 (https://download.01.org/0day-ci/archive/20260807/202608070304.QNhu3z0S-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260807/202608070304.QNhu3z0S-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/202608070304.QNhu3z0S-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> kernel/trace/trace_branch.c:218:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:218:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:218:17: sparse:     got unsigned long *
>> kernel/trace/trace_branch.c:218:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:218:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:218:17: sparse:     got unsigned long *
>> kernel/trace/trace_branch.c:218:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:218:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:218:17: sparse:     got unsigned long *
>> kernel/trace/trace_branch.c:218:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:218:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:218:17: sparse:     got unsigned long *
>> kernel/trace/trace_branch.c:218:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:218:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:218:17: sparse:     got unsigned long *
   kernel/trace/trace_branch.c:220:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:220:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:220:17: sparse:     got unsigned long *
   kernel/trace/trace_branch.c:220:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:220:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:220:17: sparse:     got unsigned long *
   kernel/trace/trace_branch.c:220:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:220:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:220:17: sparse:     got unsigned long *
   kernel/trace/trace_branch.c:220:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:220:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:220:17: sparse:     got unsigned long *
   kernel/trace/trace_branch.c:220:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got unsigned long * @@
   kernel/trace/trace_branch.c:220:17: sparse:     expected void const [noderef] __percpu *__vpp_verify
   kernel/trace/trace_branch.c:220:17: sparse:     got unsigned long *

vim +218 kernel/trace/trace_branch.c

   197	
   198	void ftrace_likely_update(struct ftrace_likely_data *f, int val,
   199				  int expect, int is_constant)
   200	{
   201		unsigned long flags = user_access_save();
   202	
   203		/* A constant is always correct */
   204		if (is_constant) {
   205			f->constant++;
   206			val = expect;
   207		}
   208		/*
   209		 * I would love to have a trace point here instead, but the
   210		 * trace point code is so inundated with unlikely and likely
   211		 * conditions that the recursive nightmare that exists is too
   212		 * much to try to get working. At least for now.
   213		 */
   214		trace_likely_condition(f, val, expect);
   215	
   216		/* use per-cpu counters to avoid contention */
   217		if (val == expect)
 > 218			this_cpu_inc(f->data.correct);
   219		else
   220			this_cpu_inc(f->data.incorrect);
   221	
   222		user_access_restore(flags);
   223	}
   224	EXPORT_SYMBOL(ftrace_likely_update);
   225	

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
  2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
                   ` (2 preceding siblings ...)
  2026-08-06 19:38 ` kernel test robot
@ 2026-08-06 20:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-08-06 20:04 UTC (permalink / raw)
  To: Martin Weiss, linux-kernel
  Cc: llvm, oe-kbuild-all, Martin Weiss, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel

Hi Martin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master v7.2-rc6 next-20260806]
[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/Martin-Weiss/trace_branch-use-per-cpu-counters-for-correct-incorrect-stats/20260806-093445
base:   https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace for-next
patch link:    https://lore.kernel.org/r/20260629095838.601926-1-Martin.weiss2410%40gmail.com
patch subject: [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats
config: hexagon-randconfig-002-20260807 (https://download.01.org/0day-ci/archive/20260807/202608070317.EiUZyapo-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260807/202608070317.EiUZyapo-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/202608070317.EiUZyapo-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/trace/trace_branch.c:200:1: warning: all paths through this function will call itself [-Winfinite-recursion]
     200 | {
         | ^
   1 warning generated.


vim +200 kernel/trace/trace_branch.c

52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  197  
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  198) void ftrace_likely_update(struct ftrace_likely_data *f, int val,
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  199) 			  int expect, int is_constant)
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12 @200  {
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  201  	unsigned long flags = user_access_save();
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  202  
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  203) 	/* A constant is always correct */
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  204) 	if (is_constant) {
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  205) 		f->constant++;
d45ae1f7041ac5 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-17  206) 		val = expect;
134e6a034cb004 kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  207) 	}
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  208  	/*
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  209  	 * I would love to have a trace point here instead, but the
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  210  	 * trace point code is so inundated with unlikely and likely
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  211  	 * conditions that the recursive nightmare that exists is too
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  212  	 * much to try to get working. At least for now.
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  213  	 */
068f530b3f274d kernel/trace/trace_branch.c   Steven Rostedt (VMware  2017-01-19  214) 	trace_likely_condition(f, val, expect);
52f232cb720a7b kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  215  
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  216  	/* use per-cpu counters to avoid contention */
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  217  	if (val == expect)
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  218  		this_cpu_inc(f->data.correct);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  219  	else
a53c1587fa9e39 kernel/trace/trace_branch.c   Martin Weiss            2026-06-29  220  		this_cpu_inc(f->data.incorrect);
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  221  
4a6c91fbdef846 kernel/trace/trace_branch.c   Peter Zijlstra          2019-03-07  222  	user_access_restore(flags);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  223  }
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  224  EXPORT_SYMBOL(ftrace_likely_update);
1f0d69a9fc815d kernel/trace/trace_unlikely.c Steven Rostedt          2008-11-12  225  

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-06 20:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29  9:58 [PATCH] trace_branch: use per-cpu counters for correct/incorrect stats Martin Weiss
2026-06-29 10:47 ` Steven Rostedt
2026-08-06 16:53 ` kernel test robot
2026-08-06 19:38 ` kernel test robot
2026-08-06 20:04 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).