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 D628FC433F5 for ; Mon, 11 Oct 2021 03:09:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 36B3060F38 for ; Mon, 11 Oct 2021 03:09:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 36B3060F38 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B63596B006C; Sun, 10 Oct 2021 23:09:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B12C36B0071; Sun, 10 Oct 2021 23:09:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A28B2900002; Sun, 10 Oct 2021 23:09:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 92B246B006C for ; Sun, 10 Oct 2021 23:09:16 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3E7FE180AD83E for ; Mon, 11 Oct 2021 03:09:16 +0000 (UTC) X-FDA: 78682675512.39.DFDFF6D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 6E5091002AE5 for ; Mon, 11 Oct 2021 03:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=XctTWDeHDnCbqssJ7+LWVDey5JZcj1NKOhdkWH7mY54=; b=h1kn/eph8rckOBheDKL4QO47Aj PZ2Plmp4fXyonfDChq6FqSb3Lzm/3/i45EnlmXINzkDNDD9QwVI7hv0LhS541Jr2Jm26O7iovHa+z hxFCBDE0APAWpOJSptZODFkdAo1OKcdb1ocXg4v4eXIIR0zk7w6aKFg8AyvBlIgANu7yw6u2kN9KL ENSRbyTJEv3KgWsZ5Y6XdRb26h3jn4DlWuPAq8moX2EdI8+v9dzr1mJ3SwrfwiER0FZhAOdkW22Ui Z6BrgplL8EXnD8A5Hm3GwWz8moMwfQRjWZA+z0iC3Sl9VXJqfZ9XFSuUGQzPjf0LRqVHQJt8Cx8LR yBxCt5nA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZlfq-005DCU-HK; Mon, 11 Oct 2021 03:08:36 +0000 Date: Mon, 11 Oct 2021 04:08:22 +0100 From: Matthew Wilcox To: Rongwei Wang 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 Subject: Re: [PATCH v4 2/2] mm, thp: bail out early in collapse_file for writeback page Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211011022241.97072-3-rongwei.wang@linux.alibaba.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6E5091002AE5 X-Stat-Signature: g39cdq7x39dskhyzpfdfkyat86cgzubk Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="h1kn/eph"; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1633921755-3414 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 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?) 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. > 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 >