Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp61964lqf; Tue, 26 Mar 2024 14:30:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2dJEYOFMIDeJbZ/M8r4/wjH+b5s90TN0i0n2lb6FY5Ugr3ty0p6D85wPNzC2oUXae1P6cdDflxYNq1wJGYApbswDYEfTkpxJ3TGigBw== X-Google-Smtp-Source: AGHT+IHqyjfNREFt3AotO1iSLSGEzOHRUgEPYSd5caak6QE6DgKy/bxIi1beWvoHEnh6srhB4s/8 X-Received: by 2002:a17:903:18f:b0:1e0:e650:5ab with SMTP id z15-20020a170903018f00b001e0e65005abmr3522925plg.16.1711488608585; Tue, 26 Mar 2024 14:30:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711488608; cv=pass; d=google.com; s=arc-20160816; b=STtHsXlWeC1Ak3yaJa0R3PNmnYID22nt3ymjqfPAJdICB0G61FTn8hrCGc1TI/Rrdk Yq2LhNzHwkVXWRm/vNUYeFWvKdlkLR5goMHLEjZihOxOmZy/+IROgugTytqD1jBizBW2 BjcSa5BGrnJWi4KzJOfbh30Q+0PoEqVFGZl0neaMr4lNM2HBCPmzNOrPls3ehtWDngDl RemKjdRG4DkJ0bp2ZiBrhsekU58itYGXD5K+2LnwyJ/4bgtq5jvLmuYUpIHFAHoJ7p0/ 6Q8YFT3ZQJMT3/DTFRVL0MR+vI/hQsAkuNrv2c3Seb5L8VPpGX4PGyHYHRyXkpBkTUa0 keYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=dnudVfWQxzTlAFAoQoP2heMf6VGlxU+wN2j0E6812eA=; fh=ulHLkfTKjQULe0uvh70gChk6kLsk5IgHMmRwQin6htA=; b=mR2sS6TCsk+Fv50crfo5pyCqqK/+r1bQb/XeJyk3m1jOx0wbao1b9IjdHpjUAITcMD 728SId06RwO02BVJsQPXERAjWFA9VpdSfkduI0A5Ok0s71S7NqW3EmDfTOAQPdrUCUMR x8NLMfDCCRXX3Q3tY3bCxSBbX6ukIuaH9JI2V43sGcSZtJ6mSDLtWntRd8G6yL+dezuM svMNLHigW3IOayw6wGLKg7OEr0DKoJUFWCTWk1N0kg9P7KvyEGECxD/heu/4qYV22goe glIxb2VSEHfSwgmwMZekpNafKUPM7ddhKGFZH9gyiW8O+gzP3Nuucj8TEv70Ak26Bq5Y 0XhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="vcWq09x/"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-119974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119974-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u9-20020a632349000000b005dc3694a2f9si10559091pgm.659.2024.03.26.14.30.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 14:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="vcWq09x/"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-119974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119974-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 989C4B23BD0 for ; Tue, 26 Mar 2024 21:05:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AA5113D538; Tue, 26 Mar 2024 21:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="vcWq09x/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFDE67353B; Tue, 26 Mar 2024 21:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711487134; cv=none; b=E+hOETjvMRwzQeCl1PbNNz1bpic14mDrjyOmLf7j5Sy+0QwD12JIhtsno52DUGCqvpAAMH+9glQm6K5vz4BVvs5yVd6qYFeSY1zVWQw77QadzHOUqYhDBkKyKfyx91vJ/3ZQUkLzknrDRTmp6C7kqLVFU82IihfjxwWmC4yfRKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711487134; c=relaxed/simple; bh=jYAeRqI/a9Wl9HNgHsa8qq4ThtqyFYAJMlxgrSsJjU4=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=VFa8QFinxo4Ek0t6osuY0BAqIsQ3BDjvWWFbiwOZDe/+7Fp4NRCpebt99ti3K7kCFJpMndijkqr1Md1Vczq0ZdRqZc1fxD0eVJkcV02V2AR/HjGKAEtyXSgSUSX27W1bFyhdVWiWnVkXnSshjDOu3kU8Kq/QTkCVLXyszlRoeiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=vcWq09x/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54545C433C7; Tue, 26 Mar 2024 21:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1711487134; bh=jYAeRqI/a9Wl9HNgHsa8qq4ThtqyFYAJMlxgrSsJjU4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vcWq09x/OCqEpGMMd/b85oYWK2rDTnBqZ4ffVYAQjNY8WOHpXqkUbc55i1pKvpkA2 e+pIkYKDcOfnNFhZZkoO6i3pb3tefI9oOJ3vwI7iOutQ4JJwFuuoEGnyYp5nXIDrae lTuMUZ2xEvD//rEGfGB0xo/MgqL78Ksld94KOAZU= Date: Tue, 26 Mar 2024 14:05:33 -0700 From: Andrew Morton To: Soma Nakata Cc: linux-mm@kvack.org, "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/filemap: set folio->mapping to NULL before xas_store() Message-Id: <20240326140533.a0d0041371e21540dd934722@linux-foundation.org> In-Reply-To: <20240322210455.3738-1-soma.nakata01@gmail.com> References: <20240322210455.3738-1-soma.nakata01@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 23 Mar 2024 06:04:54 +0900 Soma Nakata wrote: > Functions such as __filemap_get_folio() check the truncation of > folios based on the mapping field. Therefore setting this field to NULL > earlier prevents unnecessary operations on already removed folios. > > ... > > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -139,11 +139,12 @@ static void page_cache_delete(struct address_space *mapping, > > VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); > > + folio->mapping = NULL; > + /* Leave page->index set: truncation lookup relies upon it */ > + > xas_store(&xas, shadow); > xas_init_marks(&xas); > > - folio->mapping = NULL; > - /* Leave page->index set: truncation lookup relies upon it */ > mapping->nrpages -= nr; > } Seems at least harmless, but I wonder if it can really make any difference. Don't readers of folio->mapping lock the folio first?