Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp968934rdb; Fri, 9 Feb 2024 06:41:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/KKfs7oGmX4yPfvSfXJKGtFHoQSg67nFjaSO4vVJPa+/ZutC2SnE4gp3hndoJhGk7Z1Ko X-Received: by 2002:a05:6a00:2d16:b0:6e0:4e4c:572 with SMTP id fa22-20020a056a002d1600b006e04e4c0572mr1849022pfb.28.1707489705034; Fri, 09 Feb 2024 06:41:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489705; cv=pass; d=google.com; s=arc-20160816; b=rvuX8fm0y0OP5DeRn5AAeBW5+58aE7A/B6pZTqoomltPjJKHI9DsMn31z/I+oNf7G9 OLHZnr+8iRJ1DDYXDUvEX5ipcbVZSr39Dj7IulsUb0oJYs84bM3v1qkjg4PmXlyxg13F 1QA9aISDIDG0GF+hKuFoxaEs16ff5FBjExay+DeoFejX/sNObvjsI/qnWMzIXy5HrwT8 +vxRuZQKM5zQ7U7/wGDcSD0TnPYaZZ1r/EfGA2hESkXTjU+xQLrowgk2LOS1bBGPwD/q QtZdX/O1TpVuJRBbmKcsgGtVHdbQCA4X9Y/SCE5bnkbqRGRKBuFAHMYySNrEWeTokb59 RumQ== 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=yzLVEVoC51q0kiEHcn5lFzpeprpnxNh9RSZm3CgLznw=; fh=XbTwignpyAA7Zs5qkRsKdl14qT9gr6Qs+5RtiRcsM8o=; b=be+ftMWux2EGuNntPT87IB7IIYQPg8pfCgHjIXVBCBxUikww8XYLOqJ3iw4CI1Ng6q cphpliErBMsuuPj9xxHIM4B8dfzVWM/hqfzWJ+fL9+lobqqN55MrxgzXtjsF/cerSd1M Re3Og/aGV/gnzKCkOjL7WcW16gRCMvIpXdSyH93LkKP1sb6RApp/pP17g1VjyjT0HysD 90sCAQ77WK/zZbUNraCxrwqSsJYTudN6slgch9guW8G4stzydFsjiT1rbXUgpNFhMela EhjFrV8m9NM5Zwm77gkIRZbFEVoIFQdvM8uNzamrlcV7PkmvuI4b+RQ0SS/RQAx348ad LRMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YapIIPGe; 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-59453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCX9LmK2j6eQ01/30tsOGJ7FxbeGAxgUr92PjtQN1b75zc/ejKX2yXrTbjFeeaasp94W2+6gzd2cmP35tyRCSRT/0N0QcngRfWuhbU7XzQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x27-20020a63b21b000000b005cd7c0a35c2si1777105pge.480.2024.02.09.06.41.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:41:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59453-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=@samsung.com header.s=mail20170921 header.b=YapIIPGe; 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-59453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 43819B2258F for ; Fri, 9 Feb 2024 14:29:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E37D69DF2; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="YapIIPGe" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (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 1884169962 for ; Fri, 9 Feb 2024 14:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; cv=none; b=iGXE52079O2y0YbYS0IaBhEW9Jab+uJUuNYYkrCV1dNvkKJ6NMqLzuOk6osORUnBWvUCWxfKR4uCoBPkmKtkQSCnaqBdqhXJQtKlDAzGhC+CCX4V7EmmA2cY0YnxuTOb//iulLZwEnpjNlaSsNO0S9fZ+zwfWImTWh42EMYjMK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; c=relaxed/simple; bh=0O3RfgYbkdJ1kGWT2lEPHUEzW3Hv7N5M06u8M3HTzN0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=sow1HMQAW+7SkcuCNwlA552UnBXIdZoOPot7wQDAdRm9fLKF/pHHHvj3nGl9WCXcgSg1umvI0npGQEVOA7GJsorYBy/JCQuj3bqxaLNHMdUjClraPZ//KEayUdTHyxz4fgBU/5WwLXaM1E0cPslddCMUPhXxedXcKr7agG3mwpA= 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=YapIIPGe; arc=none smtp.client-ip=210.118.77.12 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 eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp028948e1c930ef39c538739c1bd0b44e1e~yOCZvgqR32144221442euoutp02d for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142906euoutp028948e1c930ef39c538739c1bd0b44e1e~yOCZvgqR32144221442euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488946; bh=yzLVEVoC51q0kiEHcn5lFzpeprpnxNh9RSZm3CgLznw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=YapIIPGeo6UtoKnrOw0E2jh3ReyHWKrHHmEiQyUInlp4KSlYxp/L/OiXftCBNIToZ NdbeJmuIhweJNqmEp5GcJEurA5vwyFzz+vWs/MgtuF8bRGPGRlAWqS0ntDKKKMMxGj 2UqNrOu58jjXE2KQXhaCvloLIoReTt24Jj5nLy78= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142906eucas1p2d99cf5db5353012f5c7e394c72654656~yOCZbd3hY2346823468eucas1p2b; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6B.2E.09552.1B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b~yOCY9kYJh0934709347eucas1p1k; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142905eusmtrp1db904eebec0428be2c7c1271c40b4f46~yOCY86pwm0528405284eusmtrp10; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) X-AuditID: cbfec7f5-853ff70000002550-97-65c636b12cf7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 10.B3.10702.1B636C56; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eusmtip1bbccce327c924057684231d1edcf32cc~yOCYv0MCC3127531275eusmtip1c; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:04 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:04 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 4/9] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Topic: [RFC PATCH 4/9] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Index: AQHaW2RUvpPeBHpDT0yQa2xBM9HYnQ== Date: Fri, 9 Feb 2024 14:29:03 +0000 Message-ID: <20240209142901.126894-5-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-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+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGvQcZbSYs34Nm8Xrw58Y Lc72/WazOD1hEZPF0099LBazpzczWezZe5LF4vKuOWwW99b8Z7W4MeEpo8X5v8dZLX7/mMPm wOOxc9Zddo8Fm0o9Nq/Q8ti0qpPNY9OnSeweJ2b8ZvE4s+AIu8fnTXIem568ZQrgjOKySUnN ySxLLdK3S+DK6Nl9ga1gG1fF0kVr2RsY93J0MXJySAiYSPzoP8XUxcjFISSwglHi0K9djBDO F0aJJe0P2SCcz4wSOy/NYe5i5ABrmX9BBSK+nFFi4dQ3zHBFm9bPguo4zShxec5PdrjBRxf+ ZQfZyCagKbHv5CawhIjAc0aJ1t0fwRxmgZvMEteunmcDqRIWCJT4OO8xE4gtIhAmsXrCMXYI W0/i/ru9LCA2i4CKxLwpK1lAjuIVsJJoa6wACX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SLdWeYuhg5geIyEhu/XGWFsIUl/lzrYoMo +sgosbt7BliRkMBpRomL50ohEisYJboWrQRLsAloSuw7uYkdJCEi8JRRYvrvQywgCWaBm8wS X96IgdjCAoESH+c9BmsQEQiT6D/XzwZh60ncf7cXrJ5FQEVi3pSVLCCn8gpYSbQ1VkAstpKY tv00WDmngLXEvEfrwWxGAVmJRyt/sUOsEpe49WQ+1DcCEkv2nGeGsEUlXj7+B/WZjsTZ608Y IWwDia1L97FA2IoSHcduskHM0ZO4MXUKlK0tsWzha7A5vAKCEidnPmGZwCg9C8m6WUhaZiFp mYWkZQEjyypGkdTS4tz03GIjveLE3OLSvHS95PzcTYzAFLXt2M8tOxhXvvqod4iRiYPxEKME B7OSCG/IkiOpQrwpiZVVqUX58UWlOanFhxhNgUE0kVlKNDkfmCTzSuINzQxMDU3MLA1MLc2M lcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYJvBIXfz2wOyYmnndl92bzx85trB8vd6cPV2H k98umZs256ByTdDzA2rF0qlvp3rtd6y5fKhp8d6csuUtIg7z1nKYbbxxauVyq1UGpzgvhZ07 frcw/9phERGNNuF1O7Yys606IDyjfHFzZr3rP7HrLOd3iS+av+OwR/GssGu6Oo5ymSf7T9nf C3vJxeqskzsnd997x9svn2VYlMwsuXxHJ5bPfcKZKe9/FF9x1E4tsF5pr/Sbe0JE6vzPt85v tZdgMavf8c7sfXL4+bYpAndVd3zjP7ct3PaKo8i1wlqRb1N954Xwbryoe/nNHsfTBmGGc2f/ f8m/Ze2Snca6gs5zr9dWJHmf+5wssHa59yTmzplKLMUZiYZazEXFiQDLC80l2gMAAA== X-CMS-MailID: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b X-Msg-Generator: CA X-RootMTR: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b References: <20240209142901.126894-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 3bddf7a89c18..614cda767298 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) { @@ -2143,7 +2153,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