mm/slub.c:3905:29: error: variable 'obj_exts' set but not used

From: kernel test robot
Date: Fri Jun 14 2024 - 17:09:34 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c286c21ff94252f778515b21b6bebe749454a852
commit: 4b8736964640fe160724e7135dc62883bddcdace mm/slab: add allocation accounting into slab allocation and free paths
date: 7 weeks ago
config: x86_64-sof-customedconfig-atom-defconfig (https://download.01.org/0day-ci/archive/20240615/202406150444.F6neSaiy-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Ubuntu 11.4.0-4ubuntu1) 11.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240615/202406150444.F6neSaiy-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406150444.F6neSaiy-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

mm/slub.c: In function 'slab_post_alloc_hook':
>> mm/slub.c:3905:29: error: variable 'obj_exts' set but not used [-Werror=unused-but-set-variable]
3905 | struct slabobj_ext *obj_exts;
| ^~~~~~~~
cc1: all warnings being treated as errors


vim +/obj_exts +3905 mm/slub.c

3898
3899 static __fastpath_inline
3900 void slab_post_alloc_hook(struct kmem_cache *s, struct obj_cgroup *objcg,
3901 gfp_t flags, size_t size, void **p, bool init,
3902 unsigned int orig_size)
3903 {
3904 unsigned int zero_size = s->object_size;
> 3905 struct slabobj_ext *obj_exts;
3906 bool kasan_init = init;
3907 size_t i;
3908 gfp_t init_flags = flags & gfp_allowed_mask;
3909
3910 /*
3911 * For kmalloc object, the allocated memory size(object_size) is likely
3912 * larger than the requested size(orig_size). If redzone check is
3913 * enabled for the extra space, don't zero it, as it will be redzoned
3914 * soon. The redzone operation for this extra space could be seen as a
3915 * replacement of current poisoning under certain debug option, and
3916 * won't break other sanity checks.
3917 */
3918 if (kmem_cache_debug_flags(s, SLAB_STORE_USER | SLAB_RED_ZONE) &&
3919 (s->flags & SLAB_KMALLOC))
3920 zero_size = orig_size;
3921
3922 /*
3923 * When slab_debug is enabled, avoid memory initialization integrated
3924 * into KASAN and instead zero out the memory via the memset below with
3925 * the proper size. Otherwise, KASAN might overwrite SLUB redzones and
3926 * cause false-positive reports. This does not lead to a performance
3927 * penalty on production builds, as slab_debug is not intended to be
3928 * enabled there.
3929 */
3930 if (__slub_debug_enabled())
3931 kasan_init = false;
3932
3933 /*
3934 * As memory initialization might be integrated into KASAN,
3935 * kasan_slab_alloc and initialization memset must be
3936 * kept together to avoid discrepancies in behavior.
3937 *
3938 * As p[i] might get tagged, memset and kmemleak hook come after KASAN.
3939 */
3940 for (i = 0; i < size; i++) {
3941 p[i] = kasan_slab_alloc(s, p[i], init_flags, kasan_init);
3942 if (p[i] && init && (!kasan_init ||
3943 !kasan_has_integrated_init()))
3944 memset(p[i], 0, zero_size);
3945 kmemleak_alloc_recursive(p[i], s->object_size, 1,
3946 s->flags, init_flags);
3947 kmsan_slab_alloc(s, p[i], init_flags);
3948 if (need_slab_obj_ext()) {
3949 obj_exts = prepare_slab_obj_exts_hook(s, flags, p[i]);
3950 #ifdef CONFIG_MEM_ALLOC_PROFILING
3951 /*
3952 * Currently obj_exts is used only for allocation profiling.
3953 * If other users appear then mem_alloc_profiling_enabled()
3954 * check should be added before alloc_tag_add().
3955 */
3956 if (likely(obj_exts))
3957 alloc_tag_add(&obj_exts->ref, current->alloc_tag, s->size);
3958 #endif
3959 }
3960 }
3961
3962 memcg_slab_post_alloc_hook(s, objcg, flags, size, p);
3963 }
3964

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