From: Minchan Kim <minchan@kernel.org>
To: "Yin, Fengwei" <fengwei.yin@intel.com>
Cc: "Matthew Wilcox" <willy@infradead.org>,
"Yang Shi" <shy828301@gmail.com>, "Yu Zhao" <yuzhao@google.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
Linux-MM <linux-mm@kvack.org>, 韩天硕 <hantianshuo@iie.ac.cn>,
mawupeng <mawupeng1@huawei.com>
Subject: Re: (resend)WARNING: trying to isolate tail page in isolate_lru_page
Date: Fri, 26 Aug 2022 09:56:08 -0700 [thread overview]
Message-ID: <Ywj7KGs1YR5W/Hdo@google.com> (raw)
In-Reply-To: <ffd043b9-8cc6-4b94-7e9f-a697669f16ac@intel.com>
On Fri, Aug 26, 2022 at 11:20:58AM +0800, Yin, Fengwei wrote:
>
>
> On 8/26/2022 2:46 AM, Matthew Wilcox wrote:
> >>> Looks like my analysis from yesterday was dropped:
> >>>
> >>> : This all seems quite plausible. The reproducer seems to (correct me
> >>> : if I'm wrong) create an AF_PACKET socket and mmap it. af_packet.c
> >>> : seems to create compound pages and mmap them. This isn't folio-related
> >>> : at all; I just moved the code that warns about it from mm/vmscan.c to
> >>> : folio-compat.c.
> >>> :
> >>> : Looks like a long-standing bug in MADV_PAGEOUT to me.
> >> Such page should never be on lru, right? We could test lru before
> >> calling isolate_lru_page() for this case? I know isolate_lru_page()
> >> does the check, but the tail page warning is raised before the check.
> >>
> >> Could the tail page warning be moved under the lru flag test? Seems
> >> possible, but it should need extra handling (re-set lru flag). Seems a
> >> little bit overkilling.
> > There's a number of ways of solving this. I'm interested in seeing
> > which one Minchan thinks is best.
> >
>
> My understanding is:
> PageTransCompound() return false for compound page if THP is disabled
> in kernel config. Replacing PageTransCompound() with PageCompound()
> could work here. But for the long term, folio should be the answer. :).
Thanks for reporting and analysis, folks,
I agree with Yang since the MADV_PAGEOUT should work with only
LRU pages.
From 0a43ac31c903bc23299a868a6d6724ff5b807e3d Mon Sep 17 00:00:00 2001
From: Minchan Kim <minchan@kernel.org>
Date: Fri, 26 Aug 2022 09:37:34 -0700
Subject: [PATCH] mm: fix madivse_pageout mishandling on non-LRU page
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
MADV_PAGEOUT tries to isolate non-LRU pages and get the warning
from isolate_lru_page below.
Fix it with checking PageLRU in advance.
------------[ cut here ]------------
trying to isolate tail page
WARNING: CPU: 0 PID: 6175 at mm/folio-compat.c:158 isolate_lru_page+0x130/0x140
Modules linked in:
CPU: 0 PID: 6175 Comm: syz-executor.0 Not tainted 5.18.12 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
RIP: 0010:isolate_lru_page+0x130/0x140
Link: https://lore.kernel.org/linux-mm/485f8c33.2471b.182d5726afb.Coremail.hantianshuo@iie.ac.cn/
Reported-by: 韩天硕 <hantianshuo@iie.ac.cn>
Suggested-by: Yang Shi <shy828301@gmail.com>
Fixes: 1a4e58cce84e ("mm: introduce MADV_PAGEOUT")
Cc: stable@vger.kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
mm/madvise.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mm/madvise.c b/mm/madvise.c
index 682e1d161aef..a3fc4cd32ed3 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -452,8 +452,11 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
continue;
}
- /* Do not interfere with other mappings of this page */
- if (page_mapcount(page) != 1)
+ /*
+ * Do not interfere with other mappings of this page and
+ * non-LRU page.
+ */
+ if (!PageLRU(page) || page_mapcount(page) != 1)
continue;
VM_BUG_ON_PAGE(PageTransCompound(page), page);
--
2.37.2.672.g94769d06f0-goog
next prev parent reply other threads:[~2022-08-26 16:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 14:40 韩天硕
2022-08-25 16:50 ` Yu Zhao
2022-08-25 18:23 ` Matthew Wilcox
2022-08-25 18:37 ` Yu Zhao
2022-08-25 18:40 ` Yang Shi
2022-08-25 18:46 ` Matthew Wilcox
2022-08-26 3:20 ` Yin, Fengwei
2022-08-26 16:56 ` Minchan Kim [this message]
2022-08-26 18:23 ` Yang Shi
2022-08-26 22:58 ` Minchan Kim
2022-08-27 0:48 ` Yin, Fengwei
2022-08-26 17:15 ` Matthew Wilcox
2022-08-26 17:27 ` Yu Zhao
2022-08-26 17:53 ` Minchan Kim
2022-08-26 17:58 ` Yu Zhao
2022-08-26 18:02 ` Matthew Wilcox
2022-08-26 18:19 ` Yang Shi
2022-08-26 23:12 ` Minchan Kim
2022-08-27 0:24 ` Yin, Fengwei
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=Ywj7KGs1YR5W/Hdo@google.com \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=fengwei.yin@intel.com \
--cc=hantianshuo@iie.ac.cn \
--cc=linux-mm@kvack.org \
--cc=mawupeng1@huawei.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=yuzhao@google.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