From patchwork Fri Feb 9 14:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 198916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp893499dyd; Fri, 9 Feb 2024 06:33:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRqur6ejEqpR6Gz+cEoV5asIsI4x1PGmc9iGAxAJIyJklUjHjh97okIEL8f+Qpy0yZvkVf X-Received: by 2002:aa7:8c4e:0:b0:6e0:9da7:8cfd with SMTP id e14-20020aa78c4e000000b006e09da78cfdmr439403pfd.5.1707489220531; Fri, 09 Feb 2024 06:33:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489220; cv=pass; d=google.com; s=arc-20160816; b=rfT3hQLJ1ytwRtIjVivYJ0jYznK9xzj7rKtLK4PjDIoWbOdPP4QxxE9Xw7+PltLcl8 9gO4o7Zqq7hutzjq8YQJYhUBpIk+IKOyr8WHOtTUNfm/mpbfNj1d22BLIadzVtJVslsh F5YNPTWF3oOsWPHq26p7ecgDZitGTnVPpkLEpYsWz86W3266eoXcZXINNutU1p0u+OxB t3vFONvl8xzhduJZ2gadK4zbJAWBZ9j7HJcft0hkfr3m7+4nFIjaFqe/pQBdz03+fcGG GarYzvli8tAqCXr2Yn1CP8Ztc9uMK2PLIn71TbTHKwIHiKm1la0hp+p8v9SIRP9Th4RZ BIaw== 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=bQVlJT9KITpqyd8NkmDnmGSqe9fEW3hkORtDX+BozwU=; b=yKOxZhchLAbDLklAJsc0cVCV2tdf4zbnYUMFPUOmvbYivgL4eYIGzA2ckExBLUw8A9 KRJwGurToL0AR5g6BZYPXumuZxaWQIH4Nww8m9/MXiNR3oaIsOgj+4Te3DYGkMT8W9Nh YlUfNYl6oQTGMD98aSsdROl+VPnDbu1rYcvw+4Wecdbs25Tj3ZoNCyWLdnKRCbzOY8WY lWvtla9JZLD1x86CFrMqboHwX+bZDxak7X+7VVxUosXmXWmb5jIjNK/vv/Rf6AhUjSOx PaXjCOlv6FQhZwD8aFsUHYATZFYj/15RotgEyWMcjeAoivVF745Dsn1+mfQw8nyyA0Wg Mg1w==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCX3g6rqPai+FQEg4aJVXKvwMV8ojf40cBOXma5+/9aJWdmhdBHP02GZdkZ+/sYvjUEnMbeZ2cI/Xo/5tW3VXM0QYqvy9g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fh5-20020a056a00390500b006dfe269c8b3si398962pfb.151.2024.02.09.06.33.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:33:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59453-ouuuleilei=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=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-ouuuleilei=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 0BEA8289D88 for ; Fri, 9 Feb 2024 14:31:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1170D6BFD6; Fri, 9 Feb 2024 14:29:14 +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 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+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pKqkJFfXGKrFG1oYaRnaGmhZ2RiqWdobB5rZWSqpG9nk5Kak1mWWqRvl6CX0bP7AlvBNq6K pYvWsjcw7uXoYuTgkBAwkZh/QaWLkYtDSGApo8SLdWeYuhg5geIyEhu/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> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432216943928832 X-GMAIL-MSGID: 1790432216943928832 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); } +static inline bool shmem_is_block_uptodate(struct folio *folio, + unsigned int block) +{ + struct shmem_folio_state *sfs = 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, pgoff_t index, } if (sgp == 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 != SGP_READ)