* [martin-lau-bpf-next:ls.rqspin.v2.2 3/3] kernel/bpf/bpf_local_storage.c:497:29: warning: variable 'owner_storage_ptr' set but not used
@ 2025-10-29 0:20 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-10-29 0:20 UTC (permalink / raw)
To: Martin KaFai Lau; +Cc: oe-kbuild-all, Martin KaFai Lau
tree: https://git.kernel.org/pub/scm/linux/kernel/git/martin.lau/bpf-next.git ls.rqspin.v2.2
head: b735af227349c9ef167cae8acf8bc8864e13f636
commit: b735af227349c9ef167cae8acf8bc8864e13f636 [3/3] [DONT PUSH]
config: sparc64-randconfig-r054-20251029 (https://download.01.org/0day-ci/archive/20251029/202510290843.DB4DN2Fk-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251029/202510290843.DB4DN2Fk-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/202510290843.DB4DN2Fk-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/bpf/bpf_local_storage.c: In function 'bpf_local_storage_alloc':
>> kernel/bpf/bpf_local_storage.c:497:29: warning: variable 'owner_storage_ptr' set but not used [-Wunused-but-set-variable]
struct bpf_local_storage **owner_storage_ptr;
^~~~~~~~~~~~~~~~~
vim +/owner_storage_ptr +497 kernel/bpf/bpf_local_storage.c
450af8d0f6be2e KP Singh 2020-08-25 490
450af8d0f6be2e KP Singh 2020-08-25 491 int bpf_local_storage_alloc(void *owner,
450af8d0f6be2e KP Singh 2020-08-25 492 struct bpf_local_storage_map *smap,
b00fa38a9c1cba Joanne Koong 2022-03-17 493 struct bpf_local_storage_elem *first_selem,
b00fa38a9c1cba Joanne Koong 2022-03-17 494 gfp_t gfp_flags)
450af8d0f6be2e KP Singh 2020-08-25 495 {
450af8d0f6be2e KP Singh 2020-08-25 496 struct bpf_local_storage *prev_storage, *storage;
450af8d0f6be2e KP Singh 2020-08-25 @497 struct bpf_local_storage **owner_storage_ptr;
16b59442646c80 Amery Hung 2025-10-02 498 struct bpf_local_storage_map_bucket *b;
16b59442646c80 Amery Hung 2025-10-02 499 unsigned long flags;
450af8d0f6be2e KP Singh 2020-08-25 500 int err;
450af8d0f6be2e KP Singh 2020-08-25 501
450af8d0f6be2e KP Singh 2020-08-25 502 err = mem_charge(smap, owner, sizeof(*storage));
450af8d0f6be2e KP Singh 2020-08-25 503 if (err)
450af8d0f6be2e KP Singh 2020-08-25 504 return err;
450af8d0f6be2e KP Singh 2020-08-25 505
4855a75ebf485f Hou Tao 2025-01-08 506 if (smap->bpf_ma)
6ae9d5e99e1dd2 Martin KaFai Lau 2023-03-22 507 storage = bpf_mem_cache_alloc_flags(&smap->storage_ma, gfp_flags);
4855a75ebf485f Hou Tao 2025-01-08 508 else
e9aae8beba825e Roman Gushchin 2020-12-01 509 storage = bpf_map_kzalloc(&smap->map, sizeof(*storage),
b00fa38a9c1cba Joanne Koong 2022-03-17 510 gfp_flags | __GFP_NOWARN);
450af8d0f6be2e KP Singh 2020-08-25 511 if (!storage) {
450af8d0f6be2e KP Singh 2020-08-25 512 err = -ENOMEM;
450af8d0f6be2e KP Singh 2020-08-25 513 goto uncharge;
450af8d0f6be2e KP Singh 2020-08-25 514 }
450af8d0f6be2e KP Singh 2020-08-25 515
fc6652aab6ad54 Martin KaFai Lau 2023-03-07 516 RCU_INIT_POINTER(storage->smap, smap);
450af8d0f6be2e KP Singh 2020-08-25 517 INIT_HLIST_HEAD(&storage->list);
fe3c7ea310ef41 Amery Hung 2025-10-02 518 raw_res_spin_lock_init(&storage->lock);
450af8d0f6be2e KP Singh 2020-08-25 519 storage->owner = owner;
b735af227349c9 Martin KaFai Lau 2025-10-22 520 storage->bpf_ma = smap->bpf_ma;
b735af227349c9 Martin KaFai Lau 2025-10-22 521 storage->owner_storage_ptr = owner_storage(smap, owner);
450af8d0f6be2e KP Singh 2020-08-25 522 bpf_selem_link_storage_nolock(storage, first_selem);
16b59442646c80 Amery Hung 2025-10-02 523
16b59442646c80 Amery Hung 2025-10-02 524 b = select_bucket(smap, storage);
fe3c7ea310ef41 Amery Hung 2025-10-02 525 err = raw_res_spin_lock_irqsave(&b->lock, flags);
fe3c7ea310ef41 Amery Hung 2025-10-02 526 if (err)
fe3c7ea310ef41 Amery Hung 2025-10-02 527 goto uncharge;
fe3c7ea310ef41 Amery Hung 2025-10-02 528
16b59442646c80 Amery Hung 2025-10-02 529 bpf_selem_link_map_nolock(smap, first_selem, b);
450af8d0f6be2e KP Singh 2020-08-25 530
b735af227349c9 Martin KaFai Lau 2025-10-22 531 owner_storage_ptr = storage->owner_storage_ptr;
b735af227349c9 Martin KaFai Lau 2025-10-22 532
450af8d0f6be2e KP Singh 2020-08-25 533 /* Publish storage to the owner.
450af8d0f6be2e KP Singh 2020-08-25 534 * Instead of using any lock of the kernel object (i.e. owner),
450af8d0f6be2e KP Singh 2020-08-25 535 * cmpxchg will work with any kernel object regardless what
450af8d0f6be2e KP Singh 2020-08-25 536 * the running context is, bh, irq...etc.
450af8d0f6be2e KP Singh 2020-08-25 537 *
450af8d0f6be2e KP Singh 2020-08-25 538 * From now on, the owner->storage pointer (e.g. sk->sk_bpf_storage)
450af8d0f6be2e KP Singh 2020-08-25 539 * is protected by the storage->lock. Hence, when freeing
450af8d0f6be2e KP Singh 2020-08-25 540 * the owner->storage, the storage->lock must be held before
450af8d0f6be2e KP Singh 2020-08-25 541 * setting owner->storage ptr to NULL.
450af8d0f6be2e KP Singh 2020-08-25 542 */
b735af227349c9 Martin KaFai Lau 2025-10-22 543 prev_storage = cmpxchg(unrcu_pointer(storage->owner_storage_ptr), NULL, storage);
450af8d0f6be2e KP Singh 2020-08-25 544 if (unlikely(prev_storage)) {
16b59442646c80 Amery Hung 2025-10-02 545 bpf_selem_unlink_map_nolock(first_selem);
fe3c7ea310ef41 Amery Hung 2025-10-02 546 raw_res_spin_unlock_irqrestore(&b->lock, flags);
450af8d0f6be2e KP Singh 2020-08-25 547 err = -EAGAIN;
450af8d0f6be2e KP Singh 2020-08-25 548 goto uncharge;
450af8d0f6be2e KP Singh 2020-08-25 549
450af8d0f6be2e KP Singh 2020-08-25 550 /* Note that even first_selem was linked to smap's
450af8d0f6be2e KP Singh 2020-08-25 551 * bucket->list, first_selem can be freed immediately
450af8d0f6be2e KP Singh 2020-08-25 552 * (instead of kfree_rcu) because
450af8d0f6be2e KP Singh 2020-08-25 553 * bpf_local_storage_map_free() does a
0fe4b381a59ebc KP Singh 2021-12-24 554 * synchronize_rcu_mult (waiting for both sleepable and
0fe4b381a59ebc KP Singh 2021-12-24 555 * normal programs) before walking the bucket->list.
450af8d0f6be2e KP Singh 2020-08-25 556 * Hence, no one is accessing selem from the
450af8d0f6be2e KP Singh 2020-08-25 557 * bucket->list under rcu_read_lock().
450af8d0f6be2e KP Singh 2020-08-25 558 */
450af8d0f6be2e KP Singh 2020-08-25 559 }
fe3c7ea310ef41 Amery Hung 2025-10-02 560 raw_res_spin_unlock_irqrestore(&b->lock, flags);
450af8d0f6be2e KP Singh 2020-08-25 561
450af8d0f6be2e KP Singh 2020-08-25 562 return 0;
450af8d0f6be2e KP Singh 2020-08-25 563
450af8d0f6be2e KP Singh 2020-08-25 564 uncharge:
b735af227349c9 Martin KaFai Lau 2025-10-22 565 bpf_local_storage_free(storage, smap, true);
450af8d0f6be2e KP Singh 2020-08-25 566 mem_uncharge(smap, owner, sizeof(*storage));
450af8d0f6be2e KP Singh 2020-08-25 567 return err;
450af8d0f6be2e KP Singh 2020-08-25 568 }
450af8d0f6be2e KP Singh 2020-08-25 569
:::::: The code at line 497 was first introduced by commit
:::::: 450af8d0f6be2e7dd2a528a3fb054bb726bf1747 bpf: Split bpf_local_storage to bpf_sk_storage
:::::: TO: KP Singh <kpsingh@google.com>
:::::: CC: Alexei Starovoitov <ast@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* [martin-lau-bpf-next:ls.rqspin.v2.2 3/3] kernel/bpf/bpf_local_storage.c:497:29: warning: variable 'owner_storage_ptr' set but not used
@ 2025-10-30 16:10 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-10-30 16:10 UTC (permalink / raw)
To: Martin KaFai Lau; +Cc: llvm, oe-kbuild-all, Martin KaFai Lau
tree: https://git.kernel.org/pub/scm/linux/kernel/git/martin.lau/bpf-next.git ls.rqspin.v2.2
head: b735af227349c9ef167cae8acf8bc8864e13f636
commit: b735af227349c9ef167cae8acf8bc8864e13f636 [3/3] [DONT PUSH]
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20251030/202510301735.G36o9EqL-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/20251030/202510301735.G36o9EqL-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/202510301735.G36o9EqL-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/bpf/bpf_local_storage.c:497:29: warning: variable 'owner_storage_ptr' set but not used [-Wunused-but-set-variable]
497 | struct bpf_local_storage **owner_storage_ptr;
| ^
1 warning generated.
vim +/owner_storage_ptr +497 kernel/bpf/bpf_local_storage.c
450af8d0f6be2e7 KP Singh 2020-08-25 490
450af8d0f6be2e7 KP Singh 2020-08-25 491 int bpf_local_storage_alloc(void *owner,
450af8d0f6be2e7 KP Singh 2020-08-25 492 struct bpf_local_storage_map *smap,
b00fa38a9c1cba0 Joanne Koong 2022-03-17 493 struct bpf_local_storage_elem *first_selem,
b00fa38a9c1cba0 Joanne Koong 2022-03-17 494 gfp_t gfp_flags)
450af8d0f6be2e7 KP Singh 2020-08-25 495 {
450af8d0f6be2e7 KP Singh 2020-08-25 496 struct bpf_local_storage *prev_storage, *storage;
450af8d0f6be2e7 KP Singh 2020-08-25 @497 struct bpf_local_storage **owner_storage_ptr;
16b59442646c808 Amery Hung 2025-10-02 498 struct bpf_local_storage_map_bucket *b;
16b59442646c808 Amery Hung 2025-10-02 499 unsigned long flags;
450af8d0f6be2e7 KP Singh 2020-08-25 500 int err;
450af8d0f6be2e7 KP Singh 2020-08-25 501
450af8d0f6be2e7 KP Singh 2020-08-25 502 err = mem_charge(smap, owner, sizeof(*storage));
450af8d0f6be2e7 KP Singh 2020-08-25 503 if (err)
450af8d0f6be2e7 KP Singh 2020-08-25 504 return err;
450af8d0f6be2e7 KP Singh 2020-08-25 505
4855a75ebf485f7 Hou Tao 2025-01-08 506 if (smap->bpf_ma)
6ae9d5e99e1dd26 Martin KaFai Lau 2023-03-22 507 storage = bpf_mem_cache_alloc_flags(&smap->storage_ma, gfp_flags);
4855a75ebf485f7 Hou Tao 2025-01-08 508 else
e9aae8beba825e4 Roman Gushchin 2020-12-01 509 storage = bpf_map_kzalloc(&smap->map, sizeof(*storage),
b00fa38a9c1cba0 Joanne Koong 2022-03-17 510 gfp_flags | __GFP_NOWARN);
450af8d0f6be2e7 KP Singh 2020-08-25 511 if (!storage) {
450af8d0f6be2e7 KP Singh 2020-08-25 512 err = -ENOMEM;
450af8d0f6be2e7 KP Singh 2020-08-25 513 goto uncharge;
450af8d0f6be2e7 KP Singh 2020-08-25 514 }
450af8d0f6be2e7 KP Singh 2020-08-25 515
fc6652aab6ad545 Martin KaFai Lau 2023-03-07 516 RCU_INIT_POINTER(storage->smap, smap);
450af8d0f6be2e7 KP Singh 2020-08-25 517 INIT_HLIST_HEAD(&storage->list);
fe3c7ea310ef417 Amery Hung 2025-10-02 518 raw_res_spin_lock_init(&storage->lock);
450af8d0f6be2e7 KP Singh 2020-08-25 519 storage->owner = owner;
b735af227349c9e Martin KaFai Lau 2025-10-22 520 storage->bpf_ma = smap->bpf_ma;
b735af227349c9e Martin KaFai Lau 2025-10-22 521 storage->owner_storage_ptr = owner_storage(smap, owner);
450af8d0f6be2e7 KP Singh 2020-08-25 522 bpf_selem_link_storage_nolock(storage, first_selem);
16b59442646c808 Amery Hung 2025-10-02 523
16b59442646c808 Amery Hung 2025-10-02 524 b = select_bucket(smap, storage);
fe3c7ea310ef417 Amery Hung 2025-10-02 525 err = raw_res_spin_lock_irqsave(&b->lock, flags);
fe3c7ea310ef417 Amery Hung 2025-10-02 526 if (err)
fe3c7ea310ef417 Amery Hung 2025-10-02 527 goto uncharge;
fe3c7ea310ef417 Amery Hung 2025-10-02 528
16b59442646c808 Amery Hung 2025-10-02 529 bpf_selem_link_map_nolock(smap, first_selem, b);
450af8d0f6be2e7 KP Singh 2020-08-25 530
b735af227349c9e Martin KaFai Lau 2025-10-22 531 owner_storage_ptr = storage->owner_storage_ptr;
b735af227349c9e Martin KaFai Lau 2025-10-22 532
450af8d0f6be2e7 KP Singh 2020-08-25 533 /* Publish storage to the owner.
450af8d0f6be2e7 KP Singh 2020-08-25 534 * Instead of using any lock of the kernel object (i.e. owner),
450af8d0f6be2e7 KP Singh 2020-08-25 535 * cmpxchg will work with any kernel object regardless what
450af8d0f6be2e7 KP Singh 2020-08-25 536 * the running context is, bh, irq...etc.
450af8d0f6be2e7 KP Singh 2020-08-25 537 *
450af8d0f6be2e7 KP Singh 2020-08-25 538 * From now on, the owner->storage pointer (e.g. sk->sk_bpf_storage)
450af8d0f6be2e7 KP Singh 2020-08-25 539 * is protected by the storage->lock. Hence, when freeing
450af8d0f6be2e7 KP Singh 2020-08-25 540 * the owner->storage, the storage->lock must be held before
450af8d0f6be2e7 KP Singh 2020-08-25 541 * setting owner->storage ptr to NULL.
450af8d0f6be2e7 KP Singh 2020-08-25 542 */
b735af227349c9e Martin KaFai Lau 2025-10-22 543 prev_storage = cmpxchg(unrcu_pointer(storage->owner_storage_ptr), NULL, storage);
450af8d0f6be2e7 KP Singh 2020-08-25 544 if (unlikely(prev_storage)) {
16b59442646c808 Amery Hung 2025-10-02 545 bpf_selem_unlink_map_nolock(first_selem);
fe3c7ea310ef417 Amery Hung 2025-10-02 546 raw_res_spin_unlock_irqrestore(&b->lock, flags);
450af8d0f6be2e7 KP Singh 2020-08-25 547 err = -EAGAIN;
450af8d0f6be2e7 KP Singh 2020-08-25 548 goto uncharge;
450af8d0f6be2e7 KP Singh 2020-08-25 549
450af8d0f6be2e7 KP Singh 2020-08-25 550 /* Note that even first_selem was linked to smap's
450af8d0f6be2e7 KP Singh 2020-08-25 551 * bucket->list, first_selem can be freed immediately
450af8d0f6be2e7 KP Singh 2020-08-25 552 * (instead of kfree_rcu) because
450af8d0f6be2e7 KP Singh 2020-08-25 553 * bpf_local_storage_map_free() does a
0fe4b381a59ebc5 KP Singh 2021-12-24 554 * synchronize_rcu_mult (waiting for both sleepable and
0fe4b381a59ebc5 KP Singh 2021-12-24 555 * normal programs) before walking the bucket->list.
450af8d0f6be2e7 KP Singh 2020-08-25 556 * Hence, no one is accessing selem from the
450af8d0f6be2e7 KP Singh 2020-08-25 557 * bucket->list under rcu_read_lock().
450af8d0f6be2e7 KP Singh 2020-08-25 558 */
450af8d0f6be2e7 KP Singh 2020-08-25 559 }
fe3c7ea310ef417 Amery Hung 2025-10-02 560 raw_res_spin_unlock_irqrestore(&b->lock, flags);
450af8d0f6be2e7 KP Singh 2020-08-25 561
450af8d0f6be2e7 KP Singh 2020-08-25 562 return 0;
450af8d0f6be2e7 KP Singh 2020-08-25 563
450af8d0f6be2e7 KP Singh 2020-08-25 564 uncharge:
b735af227349c9e Martin KaFai Lau 2025-10-22 565 bpf_local_storage_free(storage, smap, true);
450af8d0f6be2e7 KP Singh 2020-08-25 566 mem_uncharge(smap, owner, sizeof(*storage));
450af8d0f6be2e7 KP Singh 2020-08-25 567 return err;
450af8d0f6be2e7 KP Singh 2020-08-25 568 }
450af8d0f6be2e7 KP Singh 2020-08-25 569
:::::: The code at line 497 was first introduced by commit
:::::: 450af8d0f6be2e7dd2a528a3fb054bb726bf1747 bpf: Split bpf_local_storage to bpf_sk_storage
:::::: TO: KP Singh <kpsingh@google.com>
:::::: CC: Alexei Starovoitov <ast@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-30 16:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 0:20 [martin-lau-bpf-next:ls.rqspin.v2.2 3/3] kernel/bpf/bpf_local_storage.c:497:29: warning: variable 'owner_storage_ptr' set but not used kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-10-30 16:10 kernel test robot
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.