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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 544BDC433FE for ; Mon, 11 Oct 2021 03:22:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE75C60EE7 for ; Mon, 11 Oct 2021 03:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DE75C60EE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 624306B006C; Sun, 10 Oct 2021 23:22:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D389900002; Sun, 10 Oct 2021 23:22:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 475176B0072; Sun, 10 Oct 2021 23:22:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id 34F2D6B006C for ; Sun, 10 Oct 2021 23:22:24 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D252A181AC9C6 for ; Mon, 11 Oct 2021 03:22:23 +0000 (UTC) X-FDA: 78682708566.32.991FD7F Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf09.hostedemail.com (Postfix) with ESMTP id 8DBD330008FD for ; Mon, 11 Oct 2021 03:22:20 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=rongwei.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UrJgEv6_1633922535; Received: from 30.240.97.150(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0UrJgEv6_1633922535) by smtp.aliyun-inc.com(127.0.0.1); Mon, 11 Oct 2021 11:22:16 +0800 Message-ID: <4da91be0-7370-9ae7-d294-8ddd9859bf58@linux.alibaba.com> Date: Mon, 11 Oct 2021 11:22:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Thunderbird/93.0 Subject: Re: [PATCH v4 2/2] mm, thp: bail out early in collapse_file for writeback page Content-Language: en-US To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, song@kernel.org, william.kucharski@oracle.com, hughd@google.com, shy828301@gmail.com References: <20210906121200.57905-1-rongwei.wang@linux.alibaba.com> <20211011022241.97072-1-rongwei.wang@linux.alibaba.com> <20211011022241.97072-3-rongwei.wang@linux.alibaba.com> From: Rongwei Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8DBD330008FD X-Stat-Signature: ryi8c93irer6pxu9ydck688krxynhyko Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf09.hostedemail.com: domain of rongwei.wang@linux.alibaba.com designates 115.124.30.42 as permitted sender) smtp.mailfrom=rongwei.wang@linux.alibaba.com X-HE-Tag: 1633922540-701363 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 10/11/21 11:08 AM, Matthew Wilcox wrote: > On Mon, Oct 11, 2021 at 10:22:41AM +0800, Rongwei Wang wrote: >> Currently collapse_file does not explicitly check PG_writeback, instead, >> page_has_private and try_to_release_page are used to filter writeback >> pages. This does not work for xfs with blocksize equal to or larger >> than pagesize, because in such case xfs has no page->private. >> >> This makes collapse_file bail out early for writeback page. Otherwise, >> xfs end_page_writeback will panic as follows. >> >> Fixes: eb6ecbed0aa2 ("mm, thp: relax the VM_DENYWRITE constraint on file-backed THPs") > > This is the wrong Fixes line. This same bug exists earlier than this. > Your testing may not show it before then, but if you mmap something > that isn't an executable, you can provoke it. It should be: > > Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS") > > (unless there's something I'm missing?) Hi, Matthew I forget the Patch #2 fix the bug that is different with Patch #1. I will update this. Thanks for your remind! > > Also, this should surely have a Cc: stable@vger.kernel.org in the > tags section? It's a user-visible bug, we want it backported. OK, Thanks! > >> Suggested-by: Yang Shi >> Signed-off-by: Xu Yu >> Signed-off-by: Rongwei Wang >> Reviewed-by: Matthew Wilcox (Oracle) >> Reviewed-by: Yang Shi >> --- >> mm/khugepaged.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/mm/khugepaged.c b/mm/khugepaged.c >> index 045cc579f724..48de4e1b0783 100644 >> --- a/mm/khugepaged.c >> +++ b/mm/khugepaged.c >> @@ -1763,6 +1763,10 @@ static void collapse_file(struct mm_struct *mm, >> filemap_flush(mapping); >> result = SCAN_FAIL; >> goto xa_unlocked; >> + } else if (PageWriteback(page)) { >> + xas_unlock_irq(&xas); >> + result = SCAN_FAIL; >> + goto xa_unlocked; >> } else if (trylock_page(page)) { >> get_page(page); >> xas_unlock_irq(&xas); >> @@ -1798,7 +1802,8 @@ static void collapse_file(struct mm_struct *mm, >> goto out_unlock; >> } >> >> - if (!is_shmem && PageDirty(page)) { >> + if (!is_shmem && (PageDirty(page) || >> + PageWriteback(page))) { >> /* >> * khugepaged only works on read-only fd, so this >> * page is dirty because it hasn't been flushed >> -- >> 2.27.0 >>