mm/slub.c:5551 kmem_cache_reserve_only_alloc_noprof() warn: inconsistent returns '&s->reserve_lock'.
PATCH 6/12 mm/slub.c:5551 kmem_cache_reserve_only_alloc_noprof() warn: inconsistent returns '&s->reserve_lock'.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git slub-reservations head: f5877f7833fc9f8a236be339ae5bbcccdde7c850 commit: 17f60c99bf92fbf1ed52e1c492f46cec91d14cd5 [6/12] mm, slub: implement per-cache reserves config: x86_64-randconfig-161-20240612 (https://download.01.org/0day-ci/archive/20240612/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:mm/slub.c:5551 kmem_cache_reserve_only_alloc_noprof() warn: inconsistent returns '&s->reserve_lock'. mm/slub.c:5551 kmem_cache_reserve_only_alloc_noprof() warn: inconsistent returns 'flags'.
vim +5551 mm/slub.c
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5512
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5513 void *kmem_cache_reserve_only_alloc_noprof(struct kmem_cache_reserve *reserve,
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5514 gfp_t gfp)
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5515 {
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5516 struct kmem_cache *s = reserve->cache;
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5517 unsigned long flags;
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5518 void *obj = NULL;
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5519
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5520 spin_lock_irqsave(&s->reserve_lock, flags);
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5521
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5522 if (!reserve->size && !s->reserve_surplus)
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5523 goto empty_reserve;spin_unlock_irqrestore(&s->reserve_lock, flags);
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5524 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5525 /* 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5526 * Should not happen, the kmem_cache reserve_size should be sum of all 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5527 * active struct kmem_cache_reserve's size and the shared surplus 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5528 */ 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5529 if (WARN_ON_ONCE(!s->reserve_size)) 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5530 goto empty_reserve;
spin_unlock_irqrestore(&s->reserve_lock, flags)
17f60c99bf92fbf Vlastimil Babka 2024-05-31 5531 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5532 obj = s->reserve_freelist; 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5533 s->reserve_freelist = get_freepointer(s, obj); 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5534 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5535 s->reserve_size--; 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5536 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5537 if (s->size) 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5538 reserve->size--; 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5539 else 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5540 s->reserve_surplus--; 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5541 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5542 spin_unlock_irqrestore(&s->reserve_lock, flags); 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5543 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5544 slab_post_alloc_hook(s, NULL, gfp, 1, &obj, 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5545 slab_want_init_on_alloc(gfp, s), s->object_size); 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5546 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5547 /* paired with smp_rmb() in kmem_cache_reserve_free() */ 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5548 smp_wmb(); 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5549 17f60c99bf92fbf Vlastimil Babka 2024-05-31 5550 empty_reserve:
17f60c99bf92fbf Vlastimil Babka 2024-05-31 @5551 return obj;17f60c99bf92fbf Vlastimil Babka 2024-05-31 5552
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki