From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, Muchun Song <songmuchun@bytedance.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
David Hildenbrand <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: [akpm-mm:mm-new 331/335] mm/memcontrol-v1.c:685 memcg1_swapout() warn: inconsistent returns 'rcu_read'.
Date: Sun, 18 Jan 2026 14:58:41 +0300 [thread overview]
Message-ID: <202601151810.ie4EgP4S-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-new
head: 78d5565acc4516dfe1fe5a3779a53bc7aaedc2e1
commit: 8e5f42f2bf326f0efb1e565fa57b5ef99b40e646 [331/335] mm: memcontrol: eliminate the problem of dying memory cgroup for LRU folios
config: parisc-randconfig-r072-20260115 (https://download.01.org/0day-ci/archive/20260115/202601151810.ie4EgP4S-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 13.4.0
smatch version: v0.5.0-8985-g2614ff1a
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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202601151810.ie4EgP4S-lkp@intel.com/
smatch warnings:
mm/memcontrol-v1.c:685 memcg1_swapout() warn: inconsistent returns 'rcu_read'.
vim +/rcu_read +685 mm/memcontrol-v1.c
89ce924f0bd447 Johannes Weiner 2025-01-24 613 void memcg1_swapout(struct folio *folio, swp_entry_t entry)
f7d49ba03ae755 Shakeel Butt 2024-08-14 614 {
89ce924f0bd447 Johannes Weiner 2025-01-24 615 struct mem_cgroup *memcg, *swap_memcg;
8e5f42f2bf326f Muchun Song 2026-01-14 616 struct obj_cgroup *objcg;
89ce924f0bd447 Johannes Weiner 2025-01-24 617 unsigned int nr_entries;
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 618 unsigned short oldid;
89ce924f0bd447 Johannes Weiner 2025-01-24 619
89ce924f0bd447 Johannes Weiner 2025-01-24 620 VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
89ce924f0bd447 Johannes Weiner 2025-01-24 621 VM_BUG_ON_FOLIO(folio_ref_count(folio), folio);
89ce924f0bd447 Johannes Weiner 2025-01-24 622
89ce924f0bd447 Johannes Weiner 2025-01-24 623 if (mem_cgroup_disabled())
89ce924f0bd447 Johannes Weiner 2025-01-24 624 return;
89ce924f0bd447 Johannes Weiner 2025-01-24 625
89ce924f0bd447 Johannes Weiner 2025-01-24 626 if (!do_memsw_account())
89ce924f0bd447 Johannes Weiner 2025-01-24 627 return;
89ce924f0bd447 Johannes Weiner 2025-01-24 628
8e5f42f2bf326f Muchun Song 2026-01-14 629 objcg = folio_objcg(folio);
8e5f42f2bf326f Muchun Song 2026-01-14 630 VM_WARN_ON_ONCE_FOLIO(!objcg, folio);
8e5f42f2bf326f Muchun Song 2026-01-14 631 if (!objcg)
89ce924f0bd447 Johannes Weiner 2025-01-24 632 return;
89ce924f0bd447 Johannes Weiner 2025-01-24 633
8e5f42f2bf326f Muchun Song 2026-01-14 634 rcu_read_lock();
8e5f42f2bf326f Muchun Song 2026-01-14 635 memcg = obj_cgroup_memcg(objcg);
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 636 /*
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 637 * Check if this swap entry is already recorded. This can happen
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 638 * when MADV_PAGEOUT is called multiple times on pages that remain
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 639 * in swapcache, reusing the same swap entries.
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 640 */
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 641 oldid = lookup_swap_cgroup_id(entry);
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 642 if (oldid == mem_cgroup_id(memcg))
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 643 return;
rcu_read_unlock() before returning
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 644 VM_WARN_ON_ONCE(oldid != 0);
8cb494d6e92a26 Deepanshu Kartikey 2026-01-10 645
89ce924f0bd447 Johannes Weiner 2025-01-24 646 /*
89ce924f0bd447 Johannes Weiner 2025-01-24 647 * In case the memcg owning these pages has been offlined and doesn't
89ce924f0bd447 Johannes Weiner 2025-01-24 648 * have an ID allocated to it anymore, charge the closest online
89ce924f0bd447 Johannes Weiner 2025-01-24 649 * ancestor for the swap instead and transfer the memory+swap charge.
89ce924f0bd447 Johannes Weiner 2025-01-24 650 */
1d7634095c770c Shakeel Butt 2025-12-25 651 swap_memcg = mem_cgroup_private_id_get_online(memcg);
89ce924f0bd447 Johannes Weiner 2025-01-24 652 nr_entries = folio_nr_pages(folio);
89ce924f0bd447 Johannes Weiner 2025-01-24 653 /* Get references for the tail pages, too */
89ce924f0bd447 Johannes Weiner 2025-01-24 654 if (nr_entries > 1)
1d7634095c770c Shakeel Butt 2025-12-25 655 mem_cgroup_private_id_get_many(swap_memcg, nr_entries - 1);
89ce924f0bd447 Johannes Weiner 2025-01-24 656 mod_memcg_state(swap_memcg, MEMCG_SWAP, nr_entries);
89ce924f0bd447 Johannes Weiner 2025-01-24 657
1d7634095c770c Shakeel Butt 2025-12-25 658 swap_cgroup_record(folio, mem_cgroup_private_id(swap_memcg), entry);
89ce924f0bd447 Johannes Weiner 2025-01-24 659
89ce924f0bd447 Johannes Weiner 2025-01-24 660 folio_unqueue_deferred_split(folio);
89ce924f0bd447 Johannes Weiner 2025-01-24 661 folio->memcg_data = 0;
89ce924f0bd447 Johannes Weiner 2025-01-24 662
8e5f42f2bf326f Muchun Song 2026-01-14 663 if (!obj_cgroup_is_root(objcg))
89ce924f0bd447 Johannes Weiner 2025-01-24 664 page_counter_uncharge(&memcg->memory, nr_entries);
89ce924f0bd447 Johannes Weiner 2025-01-24 665
89ce924f0bd447 Johannes Weiner 2025-01-24 666 if (memcg != swap_memcg) {
89ce924f0bd447 Johannes Weiner 2025-01-24 667 if (!mem_cgroup_is_root(swap_memcg))
89ce924f0bd447 Johannes Weiner 2025-01-24 668 page_counter_charge(&swap_memcg->memsw, nr_entries);
89ce924f0bd447 Johannes Weiner 2025-01-24 669 page_counter_uncharge(&memcg->memsw, nr_entries);
89ce924f0bd447 Johannes Weiner 2025-01-24 670 }
89ce924f0bd447 Johannes Weiner 2025-01-24 671
f7d49ba03ae755 Shakeel Butt 2024-08-14 672 /*
f7d49ba03ae755 Shakeel Butt 2024-08-14 673 * Interrupts should be disabled here because the caller holds the
f7d49ba03ae755 Shakeel Butt 2024-08-14 674 * i_pages lock which is taken with interrupts-off. It is
f7d49ba03ae755 Shakeel Butt 2024-08-14 675 * important here to have the interrupts disabled because it is the
f7d49ba03ae755 Shakeel Butt 2024-08-14 676 * only synchronisation we have for updating the per-CPU variables.
f7d49ba03ae755 Shakeel Butt 2024-08-14 677 */
f7d49ba03ae755 Shakeel Butt 2024-08-14 678 preempt_disable_nested();
f7d49ba03ae755 Shakeel Butt 2024-08-14 679 VM_WARN_ON_IRQS_ENABLED();
f7d49ba03ae755 Shakeel Butt 2024-08-14 680 memcg1_charge_statistics(memcg, -folio_nr_pages(folio));
f7d49ba03ae755 Shakeel Butt 2024-08-14 681 preempt_enable_nested();
f7d49ba03ae755 Shakeel Butt 2024-08-14 682 memcg1_check_events(memcg, folio_nid(folio));
89ce924f0bd447 Johannes Weiner 2025-01-24 683
8e5f42f2bf326f Muchun Song 2026-01-14 684 rcu_read_unlock();
8e5f42f2bf326f Muchun Song 2026-01-14 @685 obj_cgroup_put(objcg);
89ce924f0bd447 Johannes Weiner 2025-01-24 686 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-01-18 11:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202601151810.ie4EgP4S-lkp@intel.com \
--to=dan.carpenter@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=songmuchun@bytedance.com \
--cc=zhengqi.arch@bytedance.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox