From: kernel test robot <lkp@intel.com>
To: Martin KaFai Lau <martin.lau@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev, Martin KaFai Lau <martin.lau@linux.dev>
Subject: [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
Date: Wed, 29 Oct 2025 08:20:14 +0800 [thread overview]
Message-ID: <202510290843.DB4DN2Fk-lkp@intel.com> (raw)
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
next reply other threads:[~2025-10-29 0:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 0:20 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-10-30 16:10 [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
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=202510290843.DB4DN2Fk-lkp@intel.com \
--to=lkp@intel.com \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/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.