From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94CD9ECAAA3 for ; Fri, 26 Aug 2022 18:23:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DA9B6B0073; Fri, 26 Aug 2022 14:23:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28A6F940008; Fri, 26 Aug 2022 14:23:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15203940007; Fri, 26 Aug 2022 14:23:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 077B56B0073 for ; Fri, 26 Aug 2022 14:23:24 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C6F931A05DB for ; Fri, 26 Aug 2022 18:23:23 +0000 (UTC) X-FDA: 79842566286.16.1850817 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf15.hostedemail.com (Postfix) with ESMTP id 888E6A0021 for ; Fri, 26 Aug 2022 18:23:23 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id t5so2393796pjs.0 for ; Fri, 26 Aug 2022 11:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=eyuLkMEstGDjQiQIN1fkZDKoWu32teRg/sZuM1hfCl0=; b=bb4uumJGCcYymK0qty96TeyqThvq6ZWfQ4AKQwZzrf4BS+r+OBrAZb0Vy4xKrbm3ct kN2OAok80qTftdZ2qlLdC/1aPlVoRSTH+gCTUC4PIYzQe+Ho3N9oOsNC+S4lb8xGcx9t yrJXQW7qprxrIUfjzHp3pf0vYblifEdQzH26F13s90AwCU9BAcybuiQGYv5stIiQZfP0 ojtfWgbODyzxuUSfXZmSRYx9YV8ytoY0NmoO91maVyZ6YzG37VU03BeMugC2EseAjQjr j11SsD5+8X3vVVwM2Po+Xad0bjvi48O3Pp55NUk14GJx0pZnBlPHvFf6SM+JadayO38J OUfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=eyuLkMEstGDjQiQIN1fkZDKoWu32teRg/sZuM1hfCl0=; b=Cpwm2TVog5jpfiRBUcYcnqIPEYzPoTno2bXpDpZKakZBQcG5pw70KPoKW/97rgggJZ PvVFWglXUnEcKXzss3U4WQx4vPy7GktwFxwkjnrupCE3iFzIL+5di6nniNHEKB9mscll tEML9YWb3GYkZkmlXpJvWi8XK2tjFY9vOCbv/1ElTLwE1eY5TeYInYr89fAcgkbDObys ArPl4n2yQb1ZWxzKSkT67JFHyy9pvohXex7vEaVHXDj1e9Sjj3aEte480wtGIlIfJ9Bq up+VPDJBsBzM1F5QWTj0fI9VEAgKhjUgdr3Pbe+XEHKsT7q3q5l99orHJg6FunS2Ctjf 97EQ== X-Gm-Message-State: ACgBeo0v66CJpSJhuG2Gtl0TFf7p84EG5lq6NZAp8P5woIQOJ97B3IVZ ZyLZD7AmpaC/Cl+1Rwfp+Te5+ipr2rIQF2T0PgE= X-Google-Smtp-Source: AA6agR7yAxl8tvzjZ1E2Zs1ugzqhKINUOQK9V5vnZC2lhVQWEm4X4yO8jNOQkR5D5RzbWdj7Amp6OtEKkFzPMVN0jgk= X-Received: by 2002:a17:903:32c4:b0:172:f641:c324 with SMTP id i4-20020a17090332c400b00172f641c324mr4938227plr.117.1661538202615; Fri, 26 Aug 2022 11:23:22 -0700 (PDT) MIME-Version: 1.0 References: <485f8c33.2471b.182d5726afb.Coremail.hantianshuo@iie.ac.cn> In-Reply-To: From: Yang Shi Date: Fri, 26 Aug 2022 11:23:10 -0700 Message-ID: Subject: Re: (resend)WARNING: trying to isolate tail page in isolate_lru_page To: Minchan Kim Cc: "Yin, Fengwei" , Matthew Wilcox , Yu Zhao , Andrew Morton , Linux-MM , =?UTF-8?B?6Z+p5aSp56GV?= , mawupeng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661538203; a=rsa-sha256; cv=none; b=lrHqDomDT6wqzdsLYOwXZuTKMbyNj27VEHPX/HtqW9j8vMkIyYxghefOQLYv2W7YZoLe1u 0bdRbhiuqf1ttGXipINEhzXZfs3J2Viqikom/vZkLszU7S3DXmMyyI5NAMS5nicOHdBnvc F6AJHW7Oa+SZZRS83fP+kgUt7Y5RKYc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bb4uumJG; spf=pass (imf15.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661538203; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eyuLkMEstGDjQiQIN1fkZDKoWu32teRg/sZuM1hfCl0=; b=41A9eLW/wJZGPAQBxu5dI/G62Wl1ZmTS+1/YFjq4K/EjIxlo4KeAbNp5HZaj6Bc1oW8q05 QdxUsZcSLqVs0tJXpLEVQAFbCQP4H1stTx2TWVwUurlAFNNYWK/FQnhxuK6PdToOZvyTsd vI59pbIc964+Reb+xpZEXThzo+jZDWI= X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bb4uumJG; spf=pass (imf15.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam08 X-Stat-Signature: 5peixcfif9qrm3jjdxosusuwf1nezpsb X-Rspamd-Queue-Id: 888E6A0021 X-HE-Tag: 1661538203-522357 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Aug 26, 2022 at 9:56 AM Minchan Kim wrote: > > 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-r= elated > > >>> : 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 > 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=3DUTF-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-1ubunt= u1.1 04/01/2014 > RIP: 0010:isolate_lru_page+0x130/0x140 > > Link: https://lore.kernel.org/linux-mm/485f8c33.2471b.182d5726afb.Coremai= l.hantianshuo@iie.ac.cn/ > Reported-by: =E9=9F=A9=E5=A4=A9=E7=A1=95 > Suggested-by: Yang Shi > Fixes: 1a4e58cce84e ("mm: introduce MADV_PAGEOUT") > Cc: stable@vger.kernel.org > Signed-off-by: Minchan Kim Thanks for the patch, looks good to me. Will you post it to the mailing list? Anyway you could have my ack. > --- > 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) !=3D 1) > + /* > + * Do not interfere with other mappings of this page and > + * non-LRU page. > + */ > + if (!PageLRU(page) || page_mapcount(page) !=3D 1) > continue; > > VM_BUG_ON_PAGE(PageTransCompound(page), page); > -- > 2.37.2.672.g94769d06f0-goog >