Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3110849lqo; Tue, 14 May 2024 22:59:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsJ3/HhoUK988Lv+H+Ryt2KuwuGBx+Q6r1UEA64hfLJT+q1PaKZ2SMAXKMsadOZ1YFam7cfWgro/So59xD2b8oy5XSh10Y9Ad/6E0XqQ== X-Google-Smtp-Source: AGHT+IEdSkvXN+TnA08mpW/6QCLrzi3iWbGOF3KJ/YuF3vKE2Z3kwe6mHIUCgInHTQlsdfb6lY/8 X-Received: by 2002:a05:6358:299:b0:18a:d3d5:f77e with SMTP id e5c5f4694b2df-193bb64d52fmr1500533555d.17.1715752765014; Tue, 14 May 2024 22:59:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715752764; cv=pass; d=google.com; s=arc-20160816; b=jYqG3vmLTho1d7gYPejGvNdXbwthSMAhMWtuQJF2c4/RRSXZlSxpfw7K/umTLvtJ2F kBDDsgdNeRrrs/xilWGFYRyyp6Dd7l6AzuNKOHYhFWsHBxOBG1jaWMdwiZ16ViNgZeuS CJC9K/7w+MEH6Y/21SkUrVv5m8+Oqr1kcD2Lm1iEEPLTuFGB1wrt/lXp8uZrpBmRuHsc AiANwQdvAMWni7pkvAbGJr2VSwJ9NfJNWpaqY/TcmG8Rvs0UeYPcW7mFxCICwSXklzLZ sOiyL4FTJl/bNlwGML4Dfc88IHFpcxvspLUU1b1d60Ptc/ATny6+QVNiLPAY9JCR/uBv V2eQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=TvwQ3/t0rLMlRSFpe0qm/SVRP0obWxz9NLqJPflU2UQ=; fh=boE2T1tfXWhPiAXKUEd+pJodvJpwHMz3xvNd2cVdM48=; b=WvC+8/V1jybrZTC0vmQhh6C1eSCipgmCKDLfD3kGaqIk6IBtXtbeyHu8Z/sxHmAEmW XFLRJByiAmGZjxB4EJEbqyKBEGLCqJM6/APqIhwnYCY4GKf14KEeKbrsxlPZV2Tai+PG Rz9M2xQn5iRhH556wvK5CpTQxGxLekUIPVE8GqRcvUK7Oyf888pAfKWNzGmaaxl+P1ty wvnGV7zOSHYLNtn5qWvZECgChYD61ONfJTVb/MGGpIidgBIOyladn7hMVsYNazhd4lHM RYUGwHtarU+ixsZlR/x/is2X+9tlSpSmISgu9xPX88qOTSNf9u4GEY3qFZkYeYInPMrW eTUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iF9QYRA2; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-64f02bac351si2494595a12.68.2024.05.14.22.59.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iF9QYRA2; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CB75A283A8F for ; Wed, 15 May 2024 05:59:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA2EC481D3; Wed, 15 May 2024 05:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="iF9QYRA2" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (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 C9BF13C060 for ; Wed, 15 May 2024 05:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752656; cv=none; b=UlenmmLtWYhNRc/ecfm5e/rPEmQUz0A7lWYGXCbQsGVczj2tgT3Ofy3xvJ9FaH2E3KQwlCJO0/ezVscSpotQczTKRinfXyZ9e1TGOCt5XBH1tCas6Ju7rcOHnQe/OVune3iVeJ6BrfOFE/vZZcYqHJ10Sh3gQHjz7y3foNvlklo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752656; c=relaxed/simple; bh=KNLDOdcMJHdonJIFbAEgulwCa2Oo/AmJi3h6ziGNLfs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=mPWaTnXbme10/eymWkL0lqeAFbdC6cP6cdIkTjY+mbkO14jocRwxNYhj8dOU6npRc1Mm5SQj3nYUpKvMjQ6+bTEefFikCxFjAz5G/MuVkcXt5G+6eCOFk5UG/7QIlX5K5TnQwu/Z7u9sOL/ifbDtT387+KbMglErp2A1fy6Im4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=iF9QYRA2; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240515055729euoutp019da897e882d6c6d9a0ca9db2e5db3080~Pk-HWQcOP1508515085euoutp01T for ; Wed, 15 May 2024 05:57:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240515055729euoutp019da897e882d6c6d9a0ca9db2e5db3080~Pk-HWQcOP1508515085euoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1715752649; bh=TvwQ3/t0rLMlRSFpe0qm/SVRP0obWxz9NLqJPflU2UQ=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=iF9QYRA2fhupfZkTnrimDqeRi6wjYm0sMeOp0s5h8j692FXl0E3QjwQRodtCpRm64 +G8KcwQ2IAF7D+h2qGkK9eThiOsfeUH3RG8J/ThTzFnEU12i5NpznNNkBZPG70EGIv EaQFp+sLI3WpGCwP9whM6ce+M1zVolcg4HrOvNR4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240515055729eucas1p25a1ae40ac6143a6c66beda0dcd46d6ac~Pk-GwWyTN0594605946eucas1p2R; Wed, 15 May 2024 05:57:29 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 99.BC.09624.8CE44466; Wed, 15 May 2024 06:57:28 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240515055728eucas1p181e0ed81b2663eb0eee6d6134c1c1956~Pk-Fxtmp_2567425674eucas1p1T; Wed, 15 May 2024 05:57:28 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240515055728eusmtrp126de191b60d8f61e2ba129b4a88ba285~Pk-FxIF7h0390703907eusmtrp11; Wed, 15 May 2024 05:57:28 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-51-66444ec865cb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 18.F1.09010.8CE44466; Wed, 15 May 2024 06:57:28 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240515055728eusmtip1e41b862dcb859f62ee1fd12a0cd79248~Pk-Fir1hx0512305123eusmtip1t; Wed, 15 May 2024 05:57:28 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 15 May 2024 06:57:27 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Wed, 15 May 2024 06:57:27 +0100 From: Daniel Gomez To: "hughd@google.com" , "akpm@linux-foundation.org" , "willy@infradead.org" , "jack@suse.cz" , "mcgrof@kernel.org" CC: "linux-mm@kvack.org" , "linux-xfs@vger.kernel.org" , "djwong@kernel.org" , "Pankaj Raghav" , "dagmcr@gmail.com" , "yosryahmed@google.com" , "baolin.wang@linux.alibaba.com" , "ritesh.list@gmail.com" , "lsf-pc@lists.linux-foundation.org" , "david@redhat.com" , "chandan.babu@oracle.com" , "linux-kernel@vger.kernel.org" , "brauner@kernel.org" , Daniel Gomez Subject: [PATCH 04/12] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Topic: [PATCH 04/12] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Index: AQHapozD1A5s10K0O0aGF++xWBxX9g== Date: Wed, 15 May 2024 05:57:27 +0000 Message-ID: <20240515055719.32577-5-da.gomez@samsung.com> In-Reply-To: <20240515055719.32577-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAKsWRmVeSWpSXmKPExsWy7djPc7on/FzSDB58t7SYs34Nm8X/vccY LV4f/sRocemonMXZvt9sFl/X/2K2uPyEz+Lppz4Wi9nTm5ksLu+aw2Zxb81/Votdf3awW+x7 vZfZ4saEp4wWB091sFv8/gGU3b4r0kHQY+esu+weCzaVemxeoeWxaVUnm8emT5PYPU7M+M3i sfOhpcfkG8sZPT4+vcXi8X7fVTaPMwuOsHt83iQXwBPFZZOSmpNZllqkb5fAlbHi+hXmgm1c FXuuLGRvYNzL0cXIySEhYCLx+2YjWxcjF4eQwApGiffT7rJDOF8YJX7vnMcM4XxmlJh3uYsJ puVQ43tWiMRyRonW3j4muKo3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p181e0ed81b2663eb0eee6d6134c1c1956 X-Msg-Generator: CA X-RootMTR: 20240515055728eucas1p181e0ed81b2663eb0eee6d6134c1c1956 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240515055728eucas1p181e0ed81b2663eb0eee6d6134c1c1956 References: <20240515055719.32577-1-da.gomez@samsung.com> When we get a folio from the page cache with filemap_get_entry() and is uptodate we exit from shmem_get_folio_gfp(). Replicate the same behaviour if the block is uptodate in the index we are operating on. Signed-off-by: Daniel Gomez --- mm/shmem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 86ad539b6a0f..69f3b98fdf7c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -256,6 +256,16 @@ static inline bool shmem_is_any_uptodate(struct folio = *folio) return folio_test_uptodate(folio); } =20 +static inline bool shmem_is_block_uptodate(struct folio *folio, + unsigned int block) +{ + struct shmem_folio_state *sfs =3D folio->private; + + if (folio_test_large(folio) && sfs) + return sfs_is_block_uptodate(sfs, block); + return folio_test_uptodate(folio); +} + static void shmem_set_range_uptodate(struct folio *folio, size_t off, size_t len) { @@ -2146,7 +2156,7 @@ static int shmem_get_folio_gfp(struct inode *inode, p= goff_t index, } if (sgp =3D=3D SGP_WRITE) folio_mark_accessed(folio); - if (folio_test_uptodate(folio)) + if (shmem_is_block_uptodate(folio, index - folio_index(folio))) goto out; /* fallocated folio */ if (sgp !=3D SGP_READ) --=20 2.43.0