The patch titled Subject: mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6 has been added to the -mm mm-unstable branch. Its filename is mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Liu Shixin <liushixin2@xxxxxxxxxx> Subject: mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6 Date: Fri, 15 Sep 2023 16:34:17 +0800 fix NULL pointing derefence and hung task problem reported by Sachin Link: https://lkml.kernel.org/r/20230915083417.3190512-1-liushixin2@xxxxxxxxxx Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx> Tested-by: Yosry Ahmed <yosryahmed@xxxxxxxxxx> Reviewed-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Reviewed-by: Yosry Ahmed <yosryahmed@xxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Sachin Sant <sachinp@xxxxxxxxxxxxx> Cc: Yosry Ahmed <yosryahmed@xxxxxxxxxx> Cc: Muchun Song <muchun.song@xxxxxxxxx> Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmscan.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) --- a/mm/vmscan.c~mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6 +++ a/mm/vmscan.c @@ -618,7 +618,8 @@ static inline bool can_reclaim_anon_page return true; /* Is there any swapcache pages to reclaim? */ if (total_swapcache_pages() > 0) { - sc->swapcache_only = 1; + if (sc) + sc->swapcache_only = 1; return true; } } else { @@ -627,7 +628,8 @@ static inline bool can_reclaim_anon_page return true; /* Is there any swapcache pages in memcg to reclaim? */ if (mem_cgroup_get_nr_swapcache_pages(memcg) > 0) { - sc->swapcache_only = 1; + if (sc) + sc->swapcache_only = 1; return true; } } @@ -2293,19 +2295,6 @@ static bool skip_cma(struct folio *folio } #endif -static bool skip_isolate(struct folio *folio, struct scan_control *sc, - enum lru_list lru) -{ - if (folio_zonenum(folio) > sc->reclaim_idx) - return true; - if (skip_cma(folio, sc)) - return true; - if (unlikely(sc->swapcache_only && !is_file_lru(lru) && - !folio_test_swapcache(folio))) - return true; - return false; -} - /* * Isolating page from the lruvec to fill in @dst list by nr_to_scan times. * @@ -2352,7 +2341,8 @@ static unsigned long isolate_lru_folios( nr_pages = folio_nr_pages(folio); total_scan += nr_pages; - if (skip_isolate(folio, sc, lru)) { + if (folio_zonenum(folio) > sc->reclaim_idx || + skip_cma(folio, sc)) { nr_skipped[folio_zonenum(folio)] += nr_pages; move_to = &folios_skipped; goto move; @@ -2367,6 +2357,15 @@ static unsigned long isolate_lru_folios( */ scan += nr_pages; + /* + * Count non-swapcache too because the swapcache pages may + * be rare and it takes too much times here if not count + * the non-swapcache pages. + */ + if (unlikely(sc->swapcache_only && !is_file_lru(lru) && + !folio_test_swapcache(folio))) + goto move; + if (!folio_test_lru(folio)) goto move; if (!sc->may_unmap && folio_mapped(folio)) _ Patches currently in -mm which might be from liushixin2@xxxxxxxxxx are mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space.patch mm-vmscan-try-to-reclaim-swapcache-pages-if-no-swap-space-v6.patch