From: Lei Liu <liulei.rjpt@vivo.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Kairui Song <kasong@tencent.com>, Nhat Pham <nphamcs@gmail.com>,
Baoquan He <bhe@redhat.com>, Barry Song <baohua@kernel.org>,
Chris Li <chrisl@kernel.org>, Vlastimil Babka <vbabka@suse.cz>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org (open list:MEMORY MANAGEMENT - SWAP),
linux-kernel@vger.kernel.org (open list)
Cc: Lei Liu <liulei.rjpt@vivo.com>
Subject: [PATCH v0 2/2] mm: swap: Forced swap entries release under memory pressure
Date: Tue, 9 Sep 2025 14:53:41 +0800 [thread overview]
Message-ID: <20250909065349.574894-3-liulei.rjpt@vivo.com> (raw)
In-Reply-To: <20250909065349.574894-1-liulei.rjpt@vivo.com>
When there is memory pressure causing OOM, fully reclaim objects from the
global list that have not reached the threshold.
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
include/linux/swapfile.h | 1 +
mm/page_alloc.c | 4 ++++
mm/swapfile.c | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/swapfile.h b/include/linux/swapfile.h
index dc43464cd838..04c660aae7a0 100644
--- a/include/linux/swapfile.h
+++ b/include/linux/swapfile.h
@@ -5,6 +5,7 @@
extern unsigned long generic_max_swapfile_size(void);
unsigned long arch_max_swapfile_size(void);
int add_to_swap_gather_cache(struct mm_struct *mm, swp_entry_t entry, int nr);
+void flush_cache_if_needed(bool check_ache_entries);
/* Maximum swapfile size supported for the arch (not inclusive). */
extern unsigned long swapfile_maximum_size;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d1d037f97c5f..7c5990c24df7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -55,6 +55,7 @@
#include <linux/delayacct.h>
#include <linux/cacheinfo.h>
#include <linux/pgalloc_tag.h>
+#include <linux/swapfile.h>
#include <asm/div64.h>
#include "internal.h"
#include "shuffle.h"
@@ -3967,6 +3968,9 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
*did_some_progress = 0;
+ /* flash async swap cache pool */
+ flush_cache_if_needed(false);
+
/*
* Acquire the oom lock. If that fails, somebody else is
* making progress for us.
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 7c69e726b075..26640ec34fc6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -229,7 +229,7 @@ static void async_release_func(struct work_struct *work)
kfree(work);
}
-static void flush_cache_if_needed(bool check_cache_count)
+void flush_cache_if_needed(bool check_cache_count)
{
struct work_struct *release_work;
--
2.34.1
next prev parent reply other threads:[~2025-09-09 6:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 6:53 [PATCH v0 0/2] mm: swap: Gather swap entries and batch async release Lei Liu
2025-09-09 6:53 ` [PATCH v0 1/2] mm: swap: Gather swap entries and batch async release core Lei Liu
2025-09-10 1:39 ` kernel test robot
2025-09-10 3:12 ` kernel test robot
2025-09-09 6:53 ` Lei Liu [this message]
2025-09-10 5:36 ` [PATCH v0 2/2] mm: swap: Forced swap entries release under memory pressure kernel test robot
2025-09-09 7:30 ` [PATCH v0 0/2] mm: swap: Gather swap entries and batch async release Kairui Song
2025-09-09 9:24 ` Barry Song
2025-09-09 16:15 ` Chris Li
2025-09-09 18:01 ` Chris Li
2025-09-10 14:07 ` Lei Liu
2025-10-14 20:42 ` Barry Song
2025-09-09 15:38 ` Chris Li
2025-09-10 14:01 ` Lei Liu
2025-09-09 19:21 ` Shakeel Butt
2025-09-09 19:48 ` Suren Baghdasaryan
2025-09-10 14:14 ` Lei Liu
2025-09-10 14:56 ` Suren Baghdasaryan
2025-09-10 16:05 ` Chris Li
2025-09-10 20:12 ` Shakeel Butt
2025-09-11 3:04 ` Lei Liu
2025-09-10 15:40 ` Chris Li
2025-09-10 20:10 ` Shakeel Butt
2025-09-10 20:41 ` Suren Baghdasaryan
2025-09-10 22:10 ` T.J. Mercier
2025-09-10 22:33 ` Shakeel Butt
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=20250909065349.574894-3-liulei.rjpt@vivo.com \
--to=liulei.rjpt@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.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