[PATCH] mm, memcg: avoid recycling when there is no more recyclable memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When the number of alloc anonymous pages exceeds the memory.high,
exc_page_fault successfully alloc code pages,
and is released by mem_cgroup_handle_over_high before return to user mode.
As a result, the program is trapped in a loop to exc page fault and reclaim
pages.

Here is an example of test code(do_alloc_memory is static compilation):
Execution Procedure:
	mkdir -p /sys/fs/cgroup/memory/memcg_high_A
	echo 50M > /sys/fs/cgroup/memory/memcg_high_A/memory.high
	cgexec -g memory:memcg_high_A ./common/do_alloc_memory anon 100M &
Phenomenon:
	[root@localhost memcg_high_A]# cat memory.usage_in_bytes
	53903360

The test result shows that the program frequently sync iCache & dcache.
As a result, 
the number of anon pages requested by the program cannot increase.

This patch changes the behavior of retry recycling.
As long as the number of successfully reclaimed pages is 
less than the target number of reclaimed pages,
memory reclamation exits, 
indicating that there is no more memory to reclaim directly.

Signed-off-by: Ruifeng Su <suruifeng1@xxxxxxxxxx>
---
 mm/memcontrol.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5b009b233ab8..e6b5d2ddb4d2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2561,7 +2561,6 @@ void mem_cgroup_handle_over_high(gfp_t gfp_mask)
 	unsigned long pflags;
 	unsigned long nr_reclaimed;
 	unsigned int nr_pages = current->memcg_nr_pages_over_high;
-	int nr_retries = MAX_RECLAIM_RETRIES;
 	struct mem_cgroup *memcg;
 	bool in_retry = false;
 
@@ -2616,7 +2615,7 @@ void mem_cgroup_handle_over_high(gfp_t gfp_mask)
 	 * memory.high, we want to encourage that rather than doing allocator
 	 * throttling.
 	 */
-	if (nr_reclaimed || nr_retries--) {
+	if (nr_reclaimed >= (in_retry ? SWAP_CLUSTER_MAX : nr_pages)) {
 		in_retry = true;
 		goto retry_reclaim;
 	}
-- 
2.33.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux