linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, ying.huang@intel.com,
	tim.c.chen@linux.intel.com, Shakeel Butt <shakeelb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	yuzhao@google.com, wfg@mail.ustc.edu.cn
Subject: Re: [RFC] mm/vmscan.c: avoid possible long latency caused by too_many_isolated()
Date: Thu, 22 Apr 2021 18:23:25 +0800	[thread overview]
Message-ID: <20210422102325.1332-1-hdanton@sina.com> (raw)
In-Reply-To: <7b7a1c09-3d16-e199-15d2-ccea906d4a66@linux.intel.com>

Hi Zhengjun

On Thu, 22 Apr 2021 16:36:19 +0800 Zhengjun Xing wrote:
>     In the system with very few file pages (nr_active_file + 
> nr_inactive_file < 100), it is easy to reproduce "nr_isolated_file > 
> nr_inactive_file",  then too_many_isolated return true, 
> shrink_inactive_list enter "msleep(100)", the long latency will happen.

We should skip reclaiming page cache in this case.
> 
> The test case to reproduce it is very simple: allocate many huge 
> pages(near the DRAM size), then do free, repeat the same operation many 
> times.
> In the test case, the system with very few file pages (nr_active_file + 
> nr_inactive_file < 100), I have dumpped the numbers of 
> active/inactive/isolated file pages during the whole test(see in the 
> attachments) , in shrink_inactive_list "too_many_isolated" is very easy 
> to return true, then enter "msleep(100)",in "too_many_isolated" 
> sc->gfp_mask is 0x342cca ("_GFP_IO" and "__GFP_FS" is masked) , it is 
> also very easy to enter “inactive >>=3”, then “isolated > inactive” will 
> be true.
> 
> So I  have a proposal to set a threshold number for the total file pages 
> to ignore the system with very few file pages, and then bypass the 100ms 
> sleep.
> It is hard to set a perfect number for the threshold, so I just give an 
> example of "256" for it.

Another option seems like we take a nap at the second time of lru tmi
with some allocators in your case served without the 100ms delay.

+++ x/mm/vmscan.c
@@ -118,6 +118,9 @@ struct scan_control {
 	/* The file pages on the current node are dangerously low */
 	unsigned int file_is_tiny:1;
 
+	unsigned int file_tmi:1; /* too many isolated */
+	unsigned int anon_tmi:1;
+
 	/* Allocation order */
 	s8 order;
 
@@ -1905,6 +1908,21 @@ static int current_may_throttle(void)
 		bdi_write_congested(current->backing_dev_info);
 }
 
+static void update_sc_tmi(struct scan_control *sc, bool file, int set)
+{
+	if (file)
+		sc->file_tmi = set;
+	else
+		sc->anon_tmi = set;
+}
+static bool is_sc_tmi(struct scan_control *sc, bool file)
+{
+	if (file)
+		return sc->file_tmi != 0;
+	else
+		return sc->anon_tmi != 0;
+}
+
 /*
  * shrink_inactive_list() is a helper for shrink_node().  It returns the number
  * of reclaimed pages
@@ -1927,6 +1945,11 @@ shrink_inactive_list(unsigned long nr_to
 		if (stalled)
 			return 0;
 
+		if (!is_sc_tmi(sc, file)) {
+			update_sc_tmi(sc, file, 1);
+			return 0;
+		}
+
 		/* wait a bit for the reclaimer. */
 		msleep(100);
 		stalled = true;
@@ -1936,6 +1959,9 @@ shrink_inactive_list(unsigned long nr_to
 			return SWAP_CLUSTER_MAX;
 	}
 
+	if (is_sc_tmi(sc, file))
+		update_sc_tmi(sc, file, 0);
+
 	lru_add_drain();
 
 	spin_lock_irq(&lruvec->lru_lock);


  reply	other threads:[~2021-04-22 10:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16  2:35 zhengjun.xing
2021-04-22  8:36 ` Xing Zhengjun
2021-04-22 10:23   ` Hillf Danton [this message]
2021-04-23  6:55     ` Xing Zhengjun
2021-04-30  5:33     ` Xing Zhengjun
2021-04-30  6:43       ` Hillf Danton
2021-05-10  8:03         ` Xing Zhengjun
2021-05-10  9:46           ` Hillf Danton
2021-04-22 17:13   ` Yu Zhao
2021-04-22 18:51     ` Shakeel Butt
2021-04-22 20:15       ` Yu Zhao
2021-04-22 20:17     ` Tim Chen
2021-04-22 20:30       ` Yu Zhao
2021-04-22 20:38         ` Tim Chen
2021-04-22 20:57           ` Yu Zhao
2021-04-22 21:02             ` Tim Chen
2021-04-23  6:57     ` Xing Zhengjun
2021-04-23 20:23       ` Yu Zhao
2021-04-25  0:48         ` Huang, Ying
2021-04-27 21:53           ` Yu Zhao
2021-04-30  5:57         ` Xing Zhengjun
2021-04-30  6:24           ` Yu Zhao
2021-04-28 11:55     ` Michal Hocko
2021-04-28 15:05       ` Yu Zhao
2021-04-29 10:00         ` Michal Hocko
2021-04-30  8:34           ` Yu Zhao
2021-04-30  9:17             ` Michal Hocko
2021-04-30 17:04               ` Yu Zhao

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=20210422102325.1332-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=shakeelb@google.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=wfg@mail.ustc.edu.cn \
    --cc=ying.huang@intel.com \
    --cc=yuzhao@google.com \
    --cc=zhengjun.xing@linux.intel.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