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 D5470ECAAA3 for ; Fri, 26 Aug 2022 16:56:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 418DE6B0074; Fri, 26 Aug 2022 12:56:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C8976B0075; Fri, 26 Aug 2022 12:56:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 269C5940007; Fri, 26 Aug 2022 12:56:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 17EDB6B0074 for ; Fri, 26 Aug 2022 12:56:12 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DB0A21C54A4 for ; Fri, 26 Aug 2022 16:56:11 +0000 (UTC) X-FDA: 79842346542.04.5B7BE68 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf07.hostedemail.com (Postfix) with ESMTP id 827A640012 for ; Fri, 26 Aug 2022 16:56:11 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id 142so2068103pfu.10 for ; Fri, 26 Aug 2022 09:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc; bh=HxO0tMUoh0FHKLcOxVIrfvBEqTcGgLqzpoUKvzgD4+0=; b=CoMaqGgmLp3P9YF7Rn39qmKJ0Ul2YZB9ccsAHETsF+RtJ3ol3EEeJmNadUbloFQ6BA 9HGAnn7dRfhvKRWfFw9V227aUzzXdJPisp0oaPTNUngGWHpElLo30kg8U+WP9ap6AMxl OBxU0gRqEv/nhOQm6XZJJuFDLZcCzWBrqJx8NLDv1uH0n2+WMxesFvusj19TpieR7nF7 9aognZ1HFg9MiMjJHdNsMaC90KObCjg6YaZMBmcfnY4wW9XBUgLlHqJRGMOPU99QQ+zl Ez4Z7gvf0MleEKRMJXLLhpR7PL2yAo5TnY/BNYu+a+gzJdoqavmkt4ZjroE433GXl83u Au/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc; bh=HxO0tMUoh0FHKLcOxVIrfvBEqTcGgLqzpoUKvzgD4+0=; b=X/3mnXJY9NGQq/Dlnau0k+C2CUaPLqzOr0C38ZAsrXquSffJDLpX0FmLHk60yK+yoE 940XY37/k5QR/oX3XKEHPYd2x7LmAkUkrnwnXTuGrIxkIh0LARFmyml7ARY41Gs7oS75 XCsAEQILdX7DeZuSIaG5Dh3V8ppGE/FOHZTQayT0azoM6McFCxH4utpch7pVYSbTinZT T6K92Mjov5FEqUI21GkEssyEhl6S3ACm1GIgX9rhMDnzhEMSYXeUSqeoYPw/hFcL11Iz 3lqYXPGspNoUo7LIMrchleckGJUpYl7Gqu4oHjLX/f2CNpcTmDX+lYL81FQfO+KJlcPg bNpA== X-Gm-Message-State: ACgBeo1TewMgylda74LeLMRS6cTNFPDCY3VxMamquIibyMcHgKzO76Wz jY8F/j9vAzuHDiTrRvzczas= X-Google-Smtp-Source: AA6agR7uXJhvfySoqEH8A3xUJ5VEuEQeYOb8F7+nYGr4ML/MXOUKh664vswDybIDtldEQbmXhiVCdA== X-Received: by 2002:a63:2bc5:0:b0:41d:9b5f:acb0 with SMTP id r188-20020a632bc5000000b0041d9b5facb0mr3910211pgr.439.1661532970373; Fri, 26 Aug 2022 09:56:10 -0700 (PDT) Received: from google.com ([2620:15c:211:201:60eb:6401:167f:b157]) by smtp.gmail.com with ESMTPSA id y131-20020a62ce89000000b005327281cb8dsm1692971pfg.97.2022.08.26.09.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 09:56:09 -0700 (PDT) Date: Fri, 26 Aug 2022 09:56:08 -0700 From: Minchan Kim To: "Yin, Fengwei" Cc: Matthew Wilcox , Yang Shi , Yu Zhao , Andrew Morton , Linux-MM , =?utf-8?B?6Z+p5aSp56GV?= , mawupeng Subject: Re: (resend)WARNING: trying to isolate tail page in isolate_lru_page Message-ID: References: <485f8c33.2471b.182d5726afb.Coremail.hantianshuo@iie.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661532971; h=from:from:sender: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=HxO0tMUoh0FHKLcOxVIrfvBEqTcGgLqzpoUKvzgD4+0=; b=k8dXEosNw4kY2xCKSYO66u6r0X/g5AwXFjcX+Oi68yBeSZtci5RAfdcolGvTycbY+0A+W/ tQDLsOQsdEpe4J4fzA72GS+cZooHQTD96CKiqFV2BXWrgpKmkL8RQbQF+DwOpvtPodmvib iHPaNXr1RLp8kyqj9ANywm1tJ0Nm++4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CoMaqGgm; spf=pass (imf07.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661532971; a=rsa-sha256; cv=none; b=AG0LlZ/CvUXyGlIEWAHEGEClmBLOBuk6qi1fArkeg4wHK8ic4liPbi0LOqR9L3I9YQOXt6 xDMJnikPb8G/Bg2XboIPy8551LX9XfEZ0TBw0qlcelvSjm0+LQRSHbDDCspEMXvM1G51HE X6oxbPY3wGbxjq/LEHRp+RjJUQTeR6M= X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CoMaqGgm; spf=pass (imf07.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam05 X-Stat-Signature: ymec86o7dio9985g48f9fzg8ebitunin X-Rspamd-Queue-Id: 827A640012 X-HE-Tag: 1661532971-614190 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 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 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: 韩天硕 Suggested-by: Yang Shi Fixes: 1a4e58cce84e ("mm: introduce MADV_PAGEOUT") Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim --- 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