Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp59123lqe; Tue, 26 Mar 2024 20:46:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4nYAG5/22Y9OoxUbzwk7lp/1LD9BAM873j+r0RABUrhJ5hBXj2pk57Mf80e7kQMibVuRKBW+5lO8yXRUI+jkB0tP4Oo9Q4TlGDrq5Sg== X-Google-Smtp-Source: AGHT+IH7K9dcrgi6+jUtKZ+ysX1WjEKZe8C7WRqblBmir/ExQtOSCM6dtkYJR5RtNJA0G9/q1dRT X-Received: by 2002:a05:6870:a108:b0:21e:6732:76bb with SMTP id m8-20020a056870a10800b0021e673276bbmr1597140oae.39.1711511194033; Tue, 26 Mar 2024 20:46:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711511193; cv=pass; d=google.com; s=arc-20160816; b=UONop8wmRo6yTljZLonBYy3gXTKLPq+wmaou+5See66W6Yjxm4NV6TmyHqFamhKZsB 8DfCVsOouP9Prn+ZHQZB8nho3/kAOa5LpQRsauwyFe2VxXN3r1nsZ0KW88FljBEXgKqu a6qrL+3YOcBXmvFg0CSyGRb7v6aWwXK2kLwUNRT0hSBRFtB8ZfaisRpjxVPLoWEeoMSA Wgx5Iv1X8sUY3W97yzQSwGhPD2Y/Zf40pmoH483X0KsLbRZgc5yZgtF5n5RDP5ckiyKb o2tAtsp8xQrezaAS7UdQpGXLICPQqHN++8sfOjppUUgHOf135PIPlSmADaSi9IiUE2Br 9Uqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1BmDLCjcFU+KK+3miiP8pR8s3wJrwUpZyPZ3mSRVfH8=; fh=CRoOzBO/ZAqxFhlroOQymux8IhuUIq/4HT6gS/yram0=; b=zo6/HzOUyRORi5bXamE8+4PQWCltXVqeTNVQlteakjTNw0T9e7bmg0m+BpIKNKRus9 rcV+xsVDYN1NieoHC+dWqa4I0pnhDtr+K5S5YKC1DVfsAi9XAGdG02SWyYNiRKx/2O/c 4eLYSot1EB5BemaAew9954B+jsdqMoCLgvw9+a+okwv068FbvcCW5Jn1AlRJIuLUKLF+ vQevCorrlxXae4bvzcvrJLWVxbIJRTff+RpA6D1i1rdWjiysWV28SCSAq0Ols4G97MxN rKX+2lnrKiIOKsx1uHzFuLdatpHGS0KNuf+sWg1yVPIGopFST9FDX2en1v3xn9yD5ATY YjSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=C+6j3WRo; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-120101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120101-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 fh4-20020a056a00390400b006eac41e9672si1439780pfb.326.2024.03.26.20.46.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 20:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120101-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=@infradead.org header.s=casper.20170209 header.b=C+6j3WRo; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-120101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120101-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 8ED93B2146D for ; Tue, 26 Mar 2024 22:51:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CC3213DDC6; Tue, 26 Mar 2024 22:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="C+6j3WRo" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 559C273189; Tue, 26 Mar 2024 22:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711493456; cv=none; b=RDcr9+sIf8KthCGhGYFf94NJvjeIj0HEuSOj/467z7Z8UGVu5ZKYAdulXrLYoiyjkcUMgIUp+YEmnXrYRmZGDBX9RhRxpD6dKows7P8ho2Hba0SeVG0fEEh9h4/BahI8Ca41vAmvPL/8cvPv/veSJdF/BOP77z+8glagipjJMSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711493456; c=relaxed/simple; bh=2NpW39e1yc+jqyCmqsSEeRIUVXVG2Imo9WLoAIyvRs8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l6wb+GUnunjfuPQNXefuQEGSfozbk39c8ALTiYl8bISe2NPyOahtmLlRBRyuvGUjCU+wXOXobbjEL22j2d7U7d78Rs2RbfEmdsiC5Xd/TpwteffqKE1SQjXReVlxkrsp+zdNOUyTYviHL02WSACkxkPNb2A27YGqEZALmZHcgEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=C+6j3WRo; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=1BmDLCjcFU+KK+3miiP8pR8s3wJrwUpZyPZ3mSRVfH8=; b=C+6j3WRotzsiFGicvbn5F7y7/r Pn1CSBfv83JhvbhVpJ2yQQJH38fVLklm1Mx3yhOjNVNYYBoJUh/32kdOIoxMIXdRlOGoWNBx4C0oP eOWFJW3sm70s0Bmnp3Zvp1nacEl97t8akUM+nJAQQX0jGDzzksa6xRYSwPq8rA2DuJCzxSm51uoFr jqMeEmaEnTp+kPvdC+4Sc/uk6lCGvOB2AGOVFSkiv6367PYZI6JaRbKgPDKez0mIRMFgb38D6kvjF CFabzsBTz3CtvM0zPSC7VvOw6ep0Lljng5lmT7SnHhuHqrwz+uwsoEMzA/8865GDpCxw2OoWVhc/I 66l7tF8g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpFd5-00000002STT-0Ja0; Tue, 26 Mar 2024 22:50:51 +0000 Date: Tue, 26 Mar 2024 22:50:50 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Soma Nakata , linux-mm@kvack.org, 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: References: <20240322210455.3738-1-soma.nakata01@gmail.com> <20240326140533.a0d0041371e21540dd934722@linux-foundation.org> 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-Disposition: inline In-Reply-To: <20240326140533.a0d0041371e21540dd934722@linux-foundation.org> On Tue, Mar 26, 2024 at 02:05:33PM -0700, Andrew Morton wrote: > 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? I can't think of anywhere that doesn't ... most of the places that check folio->mapping have "goto unlock" as the very next line. I don't think this patch accomplishes anything.