* [ast-bpf:kmalloc_nolock 6/7] mm/slub.c:3326:2: warning: variable 'flags' is used uninitialized whenever '&&' condition is false
@ 2025-07-18 4:51 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-07-18 4:51 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: llvm, oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git kmalloc_nolock
head: de3de6fc810275dad0998ffed42d921690c667ec
commit: 8e58427a2c80d3a9be8b6f2f9ccc4319d1f27906 [6/7] slab: Introduce kmalloc_nolock() and kfree_nolock().
config: x86_64-buildonly-randconfig-004-20250718 (https://download.01.org/0day-ci/archive/20250718/202507181229.QStFKxIY-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507181229.QStFKxIY-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/202507181229.QStFKxIY-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/slub.c:3326:2: warning: variable 'flags' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
3326 | local_lock_cpu_slab(s, flags);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/slub.c:3236:2: note: expanded from macro 'local_lock_cpu_slab'
3236 | lockdep_assert(local_trylock_irqsave(&(s)->cpu_slab->lock, flags))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lockdep.h:279:15: note: expanded from macro 'lockdep_assert'
279 | do { WARN_ON(debug_locks && !(cond)); } while (0)
| ^~~~~~~~~~~
include/asm-generic/bug.h:123:25: note: expanded from macro 'WARN_ON'
123 | int __ret_warn_on = !!(condition); \
| ^~~~~~~~~
mm/slub.c:3351:27: note: uninitialized use occurs here
3351 | local_unlock_cpu_slab(s, flags);
| ^~~~~
mm/slub.c:3240:48: note: expanded from macro 'local_unlock_cpu_slab'
3240 | local_unlock_irqrestore(&(s)->cpu_slab->lock, flags)
| ^~~~~
include/linux/local_lock.h:52:34: note: expanded from macro 'local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~
include/linux/local_lock_internal.h:202:21: note: expanded from macro '__local_unlock_irqrestore'
202 | local_irq_restore(flags); \
| ^~~~~
include/linux/irqflags.h:240:61: note: expanded from macro 'local_irq_restore'
240 | #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
| ^~~~~
include/linux/irqflags.h:179:26: note: expanded from macro 'raw_local_irq_restore'
179 | arch_local_irq_restore(flags); \
| ^~~~~
mm/slub.c:3326:2: note: remove the '&&' if its condition is always true
3326 | local_lock_cpu_slab(s, flags);
| ^
mm/slub.c:3236:2: note: expanded from macro 'local_lock_cpu_slab'
3236 | lockdep_assert(local_trylock_irqsave(&(s)->cpu_slab->lock, flags))
| ^
include/linux/lockdep.h:279:15: note: expanded from macro 'lockdep_assert'
279 | do { WARN_ON(debug_locks && !(cond)); } while (0)
| ^
mm/slub.c:3323:21: note: initialize the variable 'flags' to silence this warning
3323 | unsigned long flags;
| ^
| = 0
1 warning generated.
vim +3326 mm/slub.c
3312
3313 /*
3314 * Put a slab into a partial slab slot if available.
3315 *
3316 * If we did not find a slot then simply move all the partials to the
3317 * per node partial list.
3318 */
3319 static void put_cpu_partial(struct kmem_cache *s, struct slab *slab, int drain)
3320 {
3321 struct slab *oldslab;
3322 struct slab *slab_to_put = NULL;
3323 unsigned long flags;
3324 int slabs = 0;
3325
> 3326 local_lock_cpu_slab(s, flags);
3327
3328 oldslab = this_cpu_read(s->cpu_slab->partial);
3329
3330 if (oldslab) {
3331 if (drain && oldslab->slabs >= s->cpu_partial_slabs) {
3332 /*
3333 * Partial array is full. Move the existing set to the
3334 * per node partial list. Postpone the actual unfreezing
3335 * outside of the critical section.
3336 */
3337 slab_to_put = oldslab;
3338 oldslab = NULL;
3339 } else {
3340 slabs = oldslab->slabs;
3341 }
3342 }
3343
3344 slabs++;
3345
3346 slab->slabs = slabs;
3347 slab->next = oldslab;
3348
3349 this_cpu_write(s->cpu_slab->partial, slab);
3350
3351 local_unlock_cpu_slab(s, flags);
3352
3353 if (slab_to_put) {
3354 __put_partials(s, slab_to_put);
3355 stat(s, CPU_PARTIAL_DRAIN);
3356 }
3357 }
3358
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-07-18 4:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18 4:51 [ast-bpf:kmalloc_nolock 6/7] mm/slub.c:3326:2: warning: variable 'flags' is used uninitialized whenever '&&' condition is false 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).