All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Andi Kleen <ak@linux.intel.com>, linux-kernel@vger.kernel.org
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	x86@kernel.org, Andi Kleen <ak@linux.intel.com>,
	ggherdovich@suse.cz, Peter Zijlstra <peterz@infradead.org>,
	rafael.j.wysocki@intel.com
Subject: Re: [PATCH] x86/aperfmperf: Don't disable scheduler APERF/MPERF on bad samples
Date: Fri, 5 Dec 2025 06:37:09 +0800	[thread overview]
Message-ID: <202512050606.C8pVgbHT-lkp@intel.com> (raw)
In-Reply-To: <20251204180914.1855553-1-ak@linux.intel.com>

Hi Andi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/master peterz-queue/sched/core linus/master v6.18 next-20251204]
[cannot apply to tip/auto-latest]
[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/Andi-Kleen/x86-aperfmperf-Don-t-disable-scheduler-APERF-MPERF-on-bad-samples/20251205-021657
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/20251204180914.1855553-1-ak%40linux.intel.com
patch subject: [PATCH] x86/aperfmperf: Don't disable scheduler APERF/MPERF on bad samples
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20251205/202512050606.C8pVgbHT-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512050606.C8pVgbHT-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/202512050606.C8pVgbHT-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/cpu/aperfmperf.c:428:6: warning: variable 'freq_scale' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     428 |         if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt))
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:198:37: note: expanded from macro 'check_shl_overflow'
     198 | #define check_shl_overflow(a, s, d) __must_check_overflow(({            \
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     199 |         typeof(a) _a = a;                                               \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     200 |         typeof(s) _s = s;                                               \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     201 |         typeof(d) _d = d;                                               \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     202 |         unsigned long long _a_full = _a;                                \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     203 |         unsigned int _to_shift =                                        \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     204 |                 is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0;    \
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     205 |         *_d = (_a_full << _to_shift);                                   \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     206 |         (_to_shift != _s || is_negative(*_d) || is_negative(_a) ||      \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     207 |         (*_d >> _to_shift) != _a);                                      \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     208 | }))
         | ~~~
   arch/x86/kernel/cpu/aperfmperf.c:449:34: note: uninitialized use occurs here
     449 |         this_cpu_write(arch_freq_scale, freq_scale);
         |                                         ^~~~~~~~~~
   include/linux/percpu-defs.h:500:73: note: expanded from macro 'this_cpu_write'
     500 | #define this_cpu_write(pcp, val)        __pcpu_size_call(this_cpu_write_, pcp, val)
         |                                                                                ^~~
   include/linux/percpu-defs.h:372:29: note: expanded from macro '__pcpu_size_call'
     372 |                 case 8: stem##8(variable, __VA_ARGS__);break;           \
         |                                           ^~~~~~~~~~~
   arch/x86/include/asm/percpu.h:528:72: note: expanded from macro 'this_cpu_write_8'
     528 | #define this_cpu_write_8(pcp, val)                      __raw_cpu_write(8, volatile, pcp, val)
         |                                                                                           ^~~
   arch/x86/include/asm/percpu.h:165:52: note: expanded from macro '__raw_cpu_write'
     165 |         __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val);        \
         |                                                           ^~~~
   arch/x86/include/asm/percpu.h:118:35: note: expanded from macro '__pcpu_cast_8'
     118 | #define __pcpu_cast_8(val)      ((u64)(val))
         |                                        ^~~
   arch/x86/kernel/cpu/aperfmperf.c:428:2: note: remove the 'if' if its condition is always false
     428 |         if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt))
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     429 |                 goto out;
         |                 ~~~~~~~~
   arch/x86/kernel/cpu/aperfmperf.c:418:16: note: initialize the variable 'freq_scale' to silence this warning
     418 |         u64 freq_scale, freq_ratio;
         |                       ^
         |                        = 0
   1 warning generated.


vim +428 arch/x86/kernel/cpu/aperfmperf.c

5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  415  
73a5fa7d51366a5 Thomas Gleixner   2022-04-15  416  static void scale_freq_tick(u64 acnt, u64 mcnt)
55cb0b70749361d Thomas Gleixner   2022-04-15  417  {
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  418  	u64 freq_scale, freq_ratio;
55cb0b70749361d Thomas Gleixner   2022-04-15  419  
bb6e89df9028b2f Thomas Gleixner   2022-04-15  420  	if (!arch_scale_freq_invariant())
bb6e89df9028b2f Thomas Gleixner   2022-04-15  421  		return;
bb6e89df9028b2f Thomas Gleixner   2022-04-15  422  
b4366dd91793d58 Andi Kleen        2025-12-04  423  	/*
b4366dd91793d58 Andi Kleen        2025-12-04  424  	 * On any over/underflow just ignore the sample. It could
b4366dd91793d58 Andi Kleen        2025-12-04  425  	 * be due to an unlucky NMI or similar between the
b4366dd91793d58 Andi Kleen        2025-12-04  426  	 * APERF and MPERF reads.
b4366dd91793d58 Andi Kleen        2025-12-04  427  	 */
55cb0b70749361d Thomas Gleixner   2022-04-15 @428  	if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt))
b4366dd91793d58 Andi Kleen        2025-12-04  429  		goto out;
55cb0b70749361d Thomas Gleixner   2022-04-15  430  
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  431  	if (static_branch_unlikely(&arch_hybrid_cap_scale_key))
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  432  		freq_ratio = READ_ONCE(this_cpu_ptr(arch_cpu_scale)->freq_ratio);
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  433  	else
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  434  		freq_ratio = arch_max_freq_ratio;
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  435  
b4366dd91793d58 Andi Kleen        2025-12-04  436  	freq_scale = SCHED_CAPACITY_SCALE;
b4366dd91793d58 Andi Kleen        2025-12-04  437  
5a9d10145a54f7a Rafael J. Wysocki 2024-08-28  438  	if (check_mul_overflow(mcnt, freq_ratio, &mcnt) || !mcnt)
b4366dd91793d58 Andi Kleen        2025-12-04  439  		goto out;
55cb0b70749361d Thomas Gleixner   2022-04-15  440  
55cb0b70749361d Thomas Gleixner   2022-04-15  441  	freq_scale = div64_u64(acnt, mcnt);
55cb0b70749361d Thomas Gleixner   2022-04-15  442  	if (!freq_scale)
b4366dd91793d58 Andi Kleen        2025-12-04  443  		goto out;
55cb0b70749361d Thomas Gleixner   2022-04-15  444  
55cb0b70749361d Thomas Gleixner   2022-04-15  445  	if (freq_scale > SCHED_CAPACITY_SCALE)
55cb0b70749361d Thomas Gleixner   2022-04-15  446  		freq_scale = SCHED_CAPACITY_SCALE;
55cb0b70749361d Thomas Gleixner   2022-04-15  447  
b4366dd91793d58 Andi Kleen        2025-12-04  448  out:
55cb0b70749361d Thomas Gleixner   2022-04-15  449  	this_cpu_write(arch_freq_scale, freq_scale);
55cb0b70749361d Thomas Gleixner   2022-04-15  450  }
bb6e89df9028b2f Thomas Gleixner   2022-04-15  451  #else
bb6e89df9028b2f Thomas Gleixner   2022-04-15  452  static inline void bp_init_freq_invariance(void) { }
bb6e89df9028b2f Thomas Gleixner   2022-04-15  453  static inline void scale_freq_tick(u64 acnt, u64 mcnt) { }
bb6e89df9028b2f Thomas Gleixner   2022-04-15  454  #endif /* CONFIG_X86_64 && CONFIG_SMP */
73a5fa7d51366a5 Thomas Gleixner   2022-04-15  455  

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

  parent reply	other threads:[~2025-12-04 22:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04 18:09 [PATCH] x86/aperfmperf: Don't disable scheduler APERF/MPERF on bad samples Andi Kleen
2025-12-04 20:02 ` Andrew Cooper
2025-12-04 21:16   ` Andi Kleen
2025-12-04 22:37 ` kernel test robot [this message]
2025-12-05 16:10 ` Peter Zijlstra
2025-12-07 20:38   ` Andi Kleen

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=202512050606.C8pVgbHT-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=ak@linux.intel.com \
    --cc=ggherdovich@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=x86@kernel.org \
    /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.