Message ID | 20240208061825.36640-1-byungchul@sk.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2718645dyb; Wed, 7 Feb 2024 22:19:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3NFXjZlOtMUXabvH3WkeGZ/vqUAZS/Qlb7ZcaWl1JJFce965h+CXBzN84sRXps4s7+dGIod7nD3BvyN5r08541mO1HQ== X-Google-Smtp-Source: AGHT+IHPtD4ZtNR6OMbd5B+MXie/tH1xVo3UKVNwMEPQgLOTSkai7neCeVlOhrRoXxCCa8KjrACN X-Received: by 2002:a05:6e02:1542:b0:363:cbb8:53c7 with SMTP id j2-20020a056e02154200b00363cbb853c7mr11644988ilu.23.1707373160938; Wed, 07 Feb 2024 22:19:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707373160; cv=pass; d=google.com; s=arc-20160816; b=s5j5+ob+ThxcJqyH7yR/vaaHVsMLMDUtgFdVNGuHWe1qe1qi/ta90OOlym0BDXkfxL +SqlgU9LSwR0CSlCK+4gIhppIhmnMCCxobn8sfp+Qv4ea6dwg5JLPr5rC3BD9YXKMRSm ski7P02irmPAPS0LggV4iQrP1db6nHN/ta7Y5j25yLe4YO7oCB6PzJB9b2/WdpMmQMvl jqTkFx8jw9CTo/ND6lsRT7xy8Wz89XSPF4WyqlIECAFVQ3LkoikFdGHd70o0fD9S+JmG mHY7okPksCx+tSk8uUgsExSM6nzGvuXzI6fWVzWbQsPladty0kG+kLYv6RcE7Gqvryix jGDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=h8k0LVJhT/AtzswsIjpIerLLyRxbwWIQLpCIIUwzTPg=; fh=b9CCgozO7ilsS4I0G+rlKd0maMpxU4eqeK1TPyfzB6Y=; b=myhgzgOAmS3AVMiyVimFqXPCj/wlG3fZYTvqxHpeCl5kV7oQBPnYrV5VslbrNNJ90z VdjS7B8OqbI2arYu6Op8bAPFbJANRNXHzluBobvhck082QGUXL/Gwas0eHcYNWu5RgB+ sU7oz2joefc47adWOMcIRH+EwXJKiq4DNqcba+jT4XVUa0ljXLgSeHN1GxMrZIPB4HrZ BWy6XLg2sxmBBNVvZnmbYl9daealNgaXmhlGBkCMHHlBimdQqRZ6bN8mCDcTJnXSrZu+ glwrXyEKXzKL+dL3yqsb6lsRmSr6JETh9OvWgE4sD2ODMlMf8/yFgfwC2q6KRItVUkMO 8xcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVy4jB3ADwp9qY5jxBvMFF3t235K4nLqwIl0NJF74IwXagagSyH7jRqFhX2TJze7w/pKDm+u17uVX5keTufhJRtNZRI2Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k3-20020a632403000000b005dc3563fc44si2936376pgk.236.2024.02.07.22.19.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 22:19:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57503-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 045CF283961 for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 06:19:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6298D67E7B; Thu, 8 Feb 2024 06:18:51 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEF7D67C70 for <linux-kernel@vger.kernel.org>; Thu, 8 Feb 2024 06:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707373129; cv=none; b=DYa6ivFnb19gySzfmFwyyiooe1p28kWyKoN84qgf46wihTgrvp0BpCtYD8JKq9uUpJN6NfXOAfbqdVVvB9gnThJitt+Dz2myZAeePeQBjHx44rSYpIG1KI3fidIWP8pVqFLEOjOKNDcfiTlreevirPdqM3+lbLdlhWoyyCzM3Go= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707373129; c=relaxed/simple; bh=jrWzJay/sTsuzrPvK8L2TqysXsAVN52IkjoORxSCyoc=; h=From:To:Cc:Subject:Date:Message-Id; b=C+u7d8nvzz+xzGqzEmccynIHnwzH4Gev4JRDNGQJzfZZdIoJnu7kTFX+6dR8HWLfMmFtnIsDL32Mw8endgCsQd95GhMU6mDo7xQpdpxYOxwnppGLCpW+iww//oBXudfdWGvsyMtzMw/NakZFPVCSeCVLdP3aw/VnH34cMRpHGHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d85ff70000001748-2b-65c4723b6356 From: Byungchul Park <byungchul@sk.com> To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com Subject: [PATCH] mm, vmscan: Don't turn on cache_trim_mode at the highest scan priority Date: Thu, 8 Feb 2024 15:18:25 +0900 Message-Id: <20240208061825.36640-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFJMWRmVeSWpSXmKPExsXC9ZZnka5N0ZFUg1UfJCzmrF/DZnF51xw2 i3tr/rM6MHts+jSJ3ePEjN8sHp83yQUwR3HZpKTmZJalFunbJXBlHJu8jr3gCkfFod4zTA2M vexdjJwcEgImEjOm9MHZ6+eeZwWx2QTUJW7c+MkMYosIyEpM/XueBcRmFgiUWH5oDVhcWCBc Ysm9TkYQm0VAVeLB0+Ngc3gFTCWu/v7MCjFTXmL1hgNA9VxA9jpWiQffT7FAJCQlDq64wTKB kXsBI8MqRqHMvLLcxMwcE72MyrzMCr3k/NxNjEAfL6v9E72D8dOF4EOMAhyMSjy8J8oPpwqx JpYVV+YeYpTgYFYS4TXbcSBViDclsbIqtSg/vqg0J7X4EKM0B4uSOK/Rt/IUIYH0xJLU7NTU gtQimCwTB6dUA6ON5jHj7zvaa002/furxs4g9rbkQf+cmC+JpfENlXLTXD/82N36YGJJZ/Oa eSsfVh7vivDMCJjEIMn1rWFlX8yPpikngtJt+TTOKMhanz7OUrlH8sUvHe0XaS+5u5dfTD6f p5Gmr58Qk+qhZTDT1iBFSPra5kU7765o/al/kX9O9BeZbg1eEyWW4oxEQy3mouJEAIWV+Ert AQAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIJMWRmVeSWpSXmKPExsXC5WfdrGtddCTVYM05OYs569ewWRyee5LV 4vKuOWwW99b8Z3Vg8dj0aRK7x4kZv1k8Fr/4wOTxeZNcAEsUl01Kak5mWWqRvl0CV8axyevY C65wVBzqPcPUwNjL3sXIySEhYCKxfu55VhCbTUBd4saNn8wgtoiArMTUv+dZQGxmgUCJ5YfW gMWFBcIlltzrZASxWQRUJR48PQ42h1fAVOLq78+sEDPlJVZvOMA8gZFjASPDKkaRzLyy3MTM HFO94uyMyrzMCr3k/NxNjECPLav9M3EH45fL7ocYBTgYlXh4T5QfThViTSwrrsw9xCjBwawk wmu240CqEG9KYmVValF+fFFpTmrxIUZpDhYlcV6v8NQEIYH0xJLU7NTUgtQimCwTB6dUA6PF 05Ip4pI/TQUn5RtKPZt3KYdnUirbYhurZNYkxw+3XvbV5ske+K15iedigu/M6qKUtC+xO4x2 PpNeVO4lqDyj9/yGZ3qnu8Xfnd1zLvDhqZOVi1ZImWawKV9WEcuUKIgylsm4lb+CLzwk7UVA bekXiZsb5xyRjHO9bbH0aPLZZ0/POMQ/jFViKc5INNRiLipOBAC6SBcS1AEAAA== X-CFilter-Loop: Reflected Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790310519590349517 X-GMAIL-MSGID: 1790310519590349517 |
Series |
mm, vmscan: Don't turn on cache_trim_mode at the highest scan priority
|
|
Commit Message
Byungchul Park
Feb. 8, 2024, 6:18 a.m. UTC
With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon
pages. However, it should be more careful to turn on the mode because
it's going to prevent anon pages from reclaimed even if there are huge
ammount of anon pages that are very cold so should be reclaimed. Even
worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop
until direct reclaim eventually works to resume kswapd.
Signed-off-by: Byungchul Park <byungchul@sk.com>
---
mm/vmscan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Thu, Feb 8, 2024 at 1:18 AM Byungchul Park <byungchul@sk.com> wrote: > > With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon > pages. However, it should be more careful to turn on the mode because > it's going to prevent anon pages from reclaimed even if there are huge > ammount of anon pages that are very cold so should be reclaimed. Even > worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop > until direct reclaim eventually works to resume kswapd. Is a theory or something observed in the real world? If it's the former, would this change risk breaking existing use cases? It's the latter, where are the performance numbers to show what it looks like before and after this patch? > Signed-off-by: Byungchul Park <byungchul@sk.com> > --- > mm/vmscan.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index bba207f41b14..25b55fdc0d41 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2268,7 +2268,8 @@ static void prepare_scan_control(pg_data_t *pgdat, struct scan_control *sc) > * anonymous pages. > */ > file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); > - if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) > + if (sc->priority != 1 && file >> sc->priority & Why 1? > + !(sc->may_deactivate & DEACTIVATE_FILE)) > sc->cache_trim_mode = 1; > else > sc->cache_trim_mode = 0;
On Fri, Feb 16, 2024 at 12:55:17AM -0500, Yu Zhao wrote: > On Thu, Feb 8, 2024 at 1:18 AM Byungchul Park <byungchul@sk.com> wrote: > > > > With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon > > pages. However, it should be more careful to turn on the mode because > > it's going to prevent anon pages from reclaimed even if there are huge > > ammount of anon pages that are very cold so should be reclaimed. Even > > worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop > > until direct reclaim eventually works to resume kswapd. > > Is a theory or something observed in the real world? If it's the > former, would this change risk breaking existing use cases? It's the I faced the latter case. > latter, where are the performance numbers to show what it looks like > before and after this patch? Before: Whenever the system meets the condition to turn on cache_trim_mode but few cache pages to trim, kswapd fails without scanning anon pages that are plenty and cold for sure and it retries 8 times and looks *stopped for ever*. After: When the system meets the condition to turn on cache_trim_mode but few cache pages to trim, kswapd finally works at the highest scan priority. So kswap looks working well even in the same condition. > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > --- > > mm/vmscan.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index bba207f41b14..25b55fdc0d41 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2268,7 +2268,8 @@ static void prepare_scan_control(pg_data_t *pgdat, struct scan_control *sc) > > * anonymous pages. > > */ > > file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); > > - if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) > > + if (sc->priority != 1 && file >> sc->priority & > > Why 1? It means the highest scan priority. The priority goes from DEF_PRIORITY to 1. Byungchul > > + !(sc->may_deactivate & DEACTIVATE_FILE)) > > sc->cache_trim_mode = 1; > > else > > sc->cache_trim_mode = 0;
On Fri, Feb 16, 2024 at 2:24 AM Byungchul Park <byungchul@sk.com> wrote: > > On Fri, Feb 16, 2024 at 12:55:17AM -0500, Yu Zhao wrote: > > On Thu, Feb 8, 2024 at 1:18 AM Byungchul Park <byungchul@sk.com> wrote: > > > > > > With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon > > > pages. However, it should be more careful to turn on the mode because > > > it's going to prevent anon pages from reclaimed even if there are huge > > > ammount of anon pages that are very cold so should be reclaimed. Even > > > worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop > > > until direct reclaim eventually works to resume kswapd. > > > > Is a theory or something observed in the real world? If it's the > > former, would this change risk breaking existing use cases? It's the > > I faced the latter case. > > > latter, where are the performance numbers to show what it looks like > > before and after this patch? Let me ask again: where are the performance numbers to show what it looks like before and after this patch? > Before: > > Whenever the system meets the condition to turn on cache_trim_mode but > few cache pages to trim, kswapd fails without scanning anon pages that > are plenty and cold for sure and it retries 8 times and looks *stopped > for ever*. > > After: > > When the system meets the condition to turn on cache_trim_mode but few > cache pages to trim, kswapd finally works at the highest scan priority. > So kswap looks working well even in the same condition. These are not performance numbers -- what test cases can prove what's described here? > > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > > --- > > > mm/vmscan.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index bba207f41b14..25b55fdc0d41 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -2268,7 +2268,8 @@ static void prepare_scan_control(pg_data_t *pgdat, struct scan_control *sc) > > > * anonymous pages. > > > */ > > > file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); > > > - if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) > > > + if (sc->priority != 1 && file >> sc->priority & > > > > Why 1? > > It means the highest scan priority. The priority goes from DEF_PRIORITY > to 1. This is not true -- sc->priority can go all the way to zero. > Byungchul > > > > + !(sc->may_deactivate & DEACTIVATE_FILE)) > > > sc->cache_trim_mode = 1; > > > else > > > sc->cache_trim_mode = 0;
On Sat, 17 Feb 2024 00:11:25 -0500 Yu Zhao <yuzhao@google.com> wrote: > On Fri, Feb 16, 2024 at 2:24 AM Byungchul Park <byungchul@sk.com> wrote: > > > > On Fri, Feb 16, 2024 at 12:55:17AM -0500, Yu Zhao wrote: > > > On Thu, Feb 8, 2024 at 1:18 AM Byungchul Park <byungchul@sk.com> wrote: > > > > > > > > With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon > > > > pages. However, it should be more careful to turn on the mode because > > > > it's going to prevent anon pages from reclaimed even if there are huge > > > > ammount of anon pages that are very cold so should be reclaimed. Even > > > > worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop > > > > until direct reclaim eventually works to resume kswapd. > > > > > > Is a theory or something observed in the real world? If it's the > > > former, would this change risk breaking existing use cases? It's the > > > > I faced the latter case. > > > > > latter, where are the performance numbers to show what it looks like > > > before and after this patch? > > Let me ask again: where are the performance numbers to show what it > looks like before and after this patch? > > > Before: > > > > Whenever the system meets the condition to turn on cache_trim_mode but > > few cache pages to trim, kswapd fails without scanning anon pages that > > are plenty and cold for sure and it retries 8 times and looks *stopped > > for ever*. Does "stopped for ever" mean that kswapd simply stops functioning? If so, that's a pretty serious issue. Please fully describe all of this in the changelog. Please also address Yu Zhao's review comments and send us a v2 patch? Thanks.
On Wed, Feb 21, 2024 at 02:30:13PM -0800, Andrew Morton wrote: > On Sat, 17 Feb 2024 00:11:25 -0500 Yu Zhao <yuzhao@google.com> wrote: > > > On Fri, Feb 16, 2024 at 2:24 AM Byungchul Park <byungchul@sk.com> wrote: > > > > > > On Fri, Feb 16, 2024 at 12:55:17AM -0500, Yu Zhao wrote: > > > > On Thu, Feb 8, 2024 at 1:18 AM Byungchul Park <byungchul@sk.com> wrote: > > > > > > > > > > With cache_trim_mode on, reclaim logic doesn't bother reclaiming anon > > > > > pages. However, it should be more careful to turn on the mode because > > > > > it's going to prevent anon pages from reclaimed even if there are huge > > > > > ammount of anon pages that are very cold so should be reclaimed. Even > > > > > worse, that can lead kswapd_failures to be MAX_RECLAIM_RETRIES and stop > > > > > until direct reclaim eventually works to resume kswapd. > > > > > > > > Is a theory or something observed in the real world? If it's the > > > > former, would this change risk breaking existing use cases? It's the > > > > > > I faced the latter case. > > > > > > > latter, where are the performance numbers to show what it looks like > > > > before and after this patch? > > > > Let me ask again: where are the performance numbers to show what it > > looks like before and after this patch? > > > > > Before: > > > > > > Whenever the system meets the condition to turn on cache_trim_mode but > > > few cache pages to trim, kswapd fails without scanning anon pages that > > > are plenty and cold for sure and it retries 8 times and looks *stopped > > > for ever*. > > Does "stopped for ever" mean that kswapd simply stops functioning? Yes. kswapd stops its functioning. Even worse, after being stopped, any request to wake up kswapd fails until ->kswapd_failures gets reset to 0 by direct reclaim or something. It's more like a bug fix than a performance improvement. > If so, that's a pretty serious issue. Please fully describe all of > this in the changelog. Please also address Yu Zhao's review comments > and send us a v2 patch? Thanks. I will post v2 with vmstat numbers between before and after. Byungchul
diff --git a/mm/vmscan.c b/mm/vmscan.c index bba207f41b14..25b55fdc0d41 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2268,7 +2268,8 @@ static void prepare_scan_control(pg_data_t *pgdat, struct scan_control *sc) * anonymous pages. */ file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); - if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) + if (sc->priority != 1 && file >> sc->priority && + !(sc->may_deactivate & DEACTIVATE_FILE)) sc->cache_trim_mode = 1; else sc->cache_trim_mode = 0;