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 538AAC433EF for ; Mon, 20 Jun 2022 13:56:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2BA46B0071; Mon, 20 Jun 2022 09:56:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB3016B0073; Mon, 20 Jun 2022 09:56:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C53AA8E0001; Mon, 20 Jun 2022 09:56:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AFD546B0071 for ; Mon, 20 Jun 2022 09:56:49 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 79342120D98 for ; Mon, 20 Jun 2022 13:56:49 +0000 (UTC) X-FDA: 79598764938.24.2E90A61 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 501F6400A5 for ; Mon, 20 Jun 2022 13:56:48 +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=PYXWT45O2QXt5JLaMGu49TiGJ6rDftCh2i/usCEQB10=; b=doYnSRzu68+NayHMHBTnYWuxD4 WDceezRtBNRAPnvRj/oAbtHagSuSs1axL2/6cWDM+XedNBuvkYXVkIPrSDuj2FTKmXUnBw4YeQ+oy v4Dab8s2Yfg1uivYWOaxJX1kg4E0jeAGpScz9JwMgVBM+Ygql3rY4sIHCJeKvU0tM20ops0G67Jq3 hoh0xIQOMR7faZJ7olsy5U6DKHTysNZxSSSvjYqSKwWCqXADtMGq1mFQHsjOFhKsOo9rYEUpC36wr pdt5RQgPgNkEuf1YGFAkyNrNYInW7V7/4cu6hSj1pBrEX1Ago+DjTk6UujM1SuxTN8MvoMWiNbFaG p4PxtdLw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3HtP-005CiH-QK; Mon, 20 Jun 2022 13:56:39 +0000 Date: Mon, 20 Jun 2022 14:56:39 +0100 From: Matthew Wilcox To: Alistair Popple Cc: akpm@linux-foundation.org, linux-mm@kvack.org, jack@suse.cz, david@fromorbit.com, jhubbard@nvidia.com Subject: Re: [PATCH] mm: Fix serialization adding transparent huge pages to page cache Message-ID: References: <20220620090536.1474002-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220620090536.1474002-1-apopple@nvidia.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655733408; a=rsa-sha256; cv=none; b=KTQFqLW7ZalLzkZWWAfz8GZZgAJ/LaoRHuNwzkDLDzqvjxSTcw2wC3g8dTiXY4U9Dhp2dd 2AhGPEyhsEldp5+zgOm2Qm6k6DyaLJd3yUS0jjV/UniD6zdVNGdVR0erER2vM84QtsfnwL E5kxff+VWA1hLoPbPz0FwZWa6qjHmu0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=doYnSRzu; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655733408; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PYXWT45O2QXt5JLaMGu49TiGJ6rDftCh2i/usCEQB10=; b=ahcyqzQ4IWhH9loKEdlLzh4Rv3MeVk8LcpavI/IoUSlZAqUm9sFFoQNlXsyqPoekivR9mW vufsdrhEPrllnsMjsAisJ1Oh7tTodO39heXd/jqzNIyvus15nrcKLGWdbyN/o4u9XS/dht KJ8e2dJKgNE4sBiRr0OWc4mgsdwFB8s= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=doYnSRzu; 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-Rspam-User: X-Stat-Signature: 9mpni8hd6up3g1kdmb3hfgi479jpizwn X-Rspamd-Queue-Id: 501F6400A5 X-Rspamd-Server: rspam08 X-HE-Tag: 1655733408-234694 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 20, 2022 at 07:05:36PM +1000, Alistair Popple wrote: > Commit 793917d997df ("mm/readahead: Add large folio readahead") > introduced support for using large folios for filebacked pages if the > filesystem supports it. > > page_cache_ra_order() was introduced to allocate and add these large > folios to the page cache. However adding pages to the page cache should > be serialized against truncation and hole punching by taking > invalidate_lock. Not doing so can lead to data races resulting in stale > data getting added to the page cache and marked up-to-date. See commit > 730633f0b7f9 ("mm: Protect operations adding pages to page cache with > invalidate_lock") for more details. > > This issue was found by inspection but a testcase revealed it was > possible to observe in practice on XFS. Fix this by taking > invalidate_lock in page_cache_ra_order(), to mirror what is done for the > non-thp case in page_cache_ra_unbounded(). Thanks, added to pagecache:for-next and I'll be including it as part of the pull request for -rc4.