* [akpm-mm:mm-new 331/335] mm/memcontrol-v1.c:685 memcg1_swapout() warn: inconsistent returns 'rcu_read'.
@ 2026-01-18 11:58 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-01-18 11:58 UTC (permalink / raw)
To: oe-kbuild, Muchun Song
Cc: lkp, oe-kbuild-all, David Hildenbrand, Andrew Morton,
Linux Memory Management List, Qi Zheng
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-18 11:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-18 11:58 [akpm-mm:mm-new 331/335] mm/memcontrol-v1.c:685 memcg1_swapout() warn: inconsistent returns 'rcu_read' Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox