From patchwork Fri Sep 15 09:51:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD26EEE644B for ; Fri, 15 Sep 2023 09:51:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66AAD6B0201; Fri, 15 Sep 2023 05:51:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CD186B0248; Fri, 15 Sep 2023 05:51:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F7E66B024A; Fri, 15 Sep 2023 05:51:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 30FB56B0201 for ; Fri, 15 Sep 2023 05:51:31 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 08A9540F76 for ; Fri, 15 Sep 2023 09:51:31 +0000 (UTC) X-FDA: 81238364382.27.9A1003A Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf25.hostedemail.com (Postfix) with ESMTP id 10BE0A0007 for ; Fri, 15 Sep 2023 09:51:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RQwu1oOK; spf=pass (imf25.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771487; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9t9ULkMuBq/epaiWHGp5SMiuW3po0qdU7nTNfWyOmvY=; b=omfsPvQgUFz9D3ScLqMA8S06Ekw7rNdo91TKvDsPXDuNZKEiT2ssBVekXOpn+auqAKudCZ yVdl2LrgYCqzkoCZ6phPpodsJnti+hDQjoBltaUKYDO3+K6w26gDWduJGYm341HYraUyOU yyX66zqZxP9exUpj1f+KEUc08ecu2BE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771487; a=rsa-sha256; cv=none; b=OGgPqCr0UXc3LQwbWhigBWarahRhikmoiaC8Rxc80/bVeVY7JcnFmh2zaljSUAQZRrgTXu Oz9HIBJ4lXPjJks17+8fg+OvTrGC0PzXJgipQfQV9r8RLOX9x3GaYmv2d6MUUkLSqyFIle C8TOGGRKwcJFQ8ATcJfEWj/6qORffNs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RQwu1oOK; spf=pass (imf25.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095124euoutp019b3067c0c11e93b92905f501b684ee5b~FCa_dlyWY0839808398euoutp01O for ; Fri, 15 Sep 2023 09:51:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230915095124euoutp019b3067c0c11e93b92905f501b684ee5b~FCa_dlyWY0839808398euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771484; bh=9t9ULkMuBq/epaiWHGp5SMiuW3po0qdU7nTNfWyOmvY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=RQwu1oOKOP/OHNYx/6DeTA5c7ndiENxNu0XN99GO9cPncv7eY9AC1RxPHE2y/6W35 tdfnjH8d+Cba1a31UkfrqxlHUNaemIKiqY0oZ75ZnWAYO2Df7GMhEx1jyIjF0sIwam b7ZpPMSXL58XOLa1lrWEu1AAJ4/ZP/KrK6BYEbnk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230915095124eucas1p2b20cd2623e776492e070e7d7757fe49b~FCa_N49lA0862308623eucas1p2V; Fri, 15 Sep 2023 09:51:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E7.E7.11320.C1924056; Fri, 15 Sep 2023 10:51:24 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230915095124eucas1p1eb0e0ef883f6316cf14c349404a51150~FCa93UCLR2203022030eucas1p1Q; Fri, 15 Sep 2023 09:51:23 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230915095123eusmtrp1c3cce7f6f7a5eb736598ffae8ecc3ca0~FCa92ilDZ1836118361eusmtrp17; Fri, 15 Sep 2023 09:51:23 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-1c-6504291cfd59 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5A.D6.14344.B1924056; Fri, 15 Sep 2023 10:51:23 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230915095123eusmtip267ceaaeebbabd3d66cf4aa80ead14236~FCa9rj4DM0935009350eusmtip2G; Fri, 15 Sep 2023 09:51:23 +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, 15 Sep 2023 10:51:23 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 15 Sep 2023 10:51:23 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 1/6] filemap: make the folio order calculation shareable Thread-Topic: [PATCH 1/6] filemap: make the folio order calculation shareable Thread-Index: AQHZ57ovaMdf9q/cjECRh1BbWSoXsQ== Date: Fri, 15 Sep 2023 09:51:23 +0000 Message-ID: <20230915095042.1320180-2-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNKsWRmVeSWpSXmKPExsWy7djP87oymiypBr+OC1vMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blN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C27dKy5cCu3EktxRqKhFnNRcSIANnSnRtcDAAA= X-CMS-MailID: 20230915095124eucas1p1eb0e0ef883f6316cf14c349404a51150 X-Msg-Generator: CA X-RootMTR: 20230915095124eucas1p1eb0e0ef883f6316cf14c349404a51150 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095124eucas1p1eb0e0ef883f6316cf14c349404a51150 References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 10BE0A0007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: myiknp6jodmzyuu5prys3i95mxwpaasf X-HE-Tag: 1694771486-189334 X-HE-Meta: U2FsdGVkX18ZlpTfpSsUX8Nemqc2Mhwcdck7m5iRTRyND16tev/3D4maeEhoHewehe4k2raQ2K43cPcE0PPF7hmVc2KeAMo3bS29ajKfkkCcFoA1UBeocrOcPnaPvpJtg5O28DcCPWhlalT1Ll63GMcmzhGuTRmLr1CCvV0IZxkFWwCSqoSmUltcBYQwIYUGVRAt0XUuiFn6I9FFOLUb3wjXAWch3Va98fY4bDAfAiilWFQcDxJyEx/fcAcbUBdVBPYeqwsNuUYJS1KqixI2GdqAj7dfbHyyKvhb1vidc5RqdJNa4rbE7WMQARN35sVtapYTk8ljDEt3aKqjQCy5KEbRgtw0tJcIbwWuQDCwCHJoJzGmiGO/XNcWzdm/G4xeHEFUuM/Odbya4uVFvZZL1qFdRsktFpTRg/FgkddH1bXhkswI5BOs7PV38qKOPZ69u4+eZJj0qcthMuMSWufhgljwjXa3M9hboJL4vRAZg2JQPneVH0kqqfV/EE2miTSLsDYdw3sW9MVCnu2+vYHJeUOLnIEiu6qXmnizig5NTjsxxEm5fMKJ6WKIvW90bvP2dVGHFmV+Uxpi583esJ2lbvbJVyPOB4k1alaRzlX9UL6ao1BifPN9jIo8OYgqV1RRcNoWaHRCwNMkrIyJi5vjB4ourB6WBCK6BjusxOqZWucZD7yMmcviEVUadW++dO2VIEcI10TIk2PyOHZE5j1pZIlWeUB3lZElw6FO+okJOEQxyjxC4n+ApGmSBzjDcLBZzCFWPhVoDVq6tHeXrCp++bVYee5LNkPuPXk4wCix4Qo8NFg78j+OvczZs3ejHH3rbhcogoW28oy55Jr8kXzaAcUfdE2qzzeS7Kh5fjX+rYCaOeyjYtu7UPigxC6++8yNEIO7+UXbGy1s+ufesF82YhjzCyAaPASp1vB6lZcI2I8HTYELKb6baHgu8k6XUSSWN74c4BzA4etsr5Vn8I4 VezfZ1d9 5mywmCMWugSxRvTh+Wcz3Mnpmps270c5ALmanImG4MVDLekPwRvIq5jsucNTvHkzgV1xbXY0Itl/XHi+cL4D+bzqLVY2HCCegha2fAwgiSSCKQAbw9geUirwx1lHCM9YqPP+DtQWqx720PQdMWygIqiRaotlmWi/keZpW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To make the code that clamps the folio order in the __filemap_get_folio routine reusable to others, move and merge it to the fgf_set_order new subroutine (mapping_size_order), so when mapping the size at a given index, the order calculated is already valid and ready to be used when order is retrieved from fgp_flags with FGF_GET_ORDER. Signed-off-by: Daniel Gomez --- fs/iomap/buffered-io.c | 6 ++++-- include/linux/pagemap.h | 42 ++++++++++++++++++++++++++++++++++++----- mm/filemap.c | 8 -------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ae8673ce08b1..bfd9a22a9464 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -546,12 +546,14 @@ EXPORT_SYMBOL_GPL(iomap_is_partially_uptodate); struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len) { fgf_t fgp = FGP_WRITEBEGIN | FGP_NOFS; + pgoff_t index = pos >> PAGE_SHIFT; + struct address_space *mapping = iter->inode->i_mapping; if (iter->flags & IOMAP_NOWAIT) fgp |= FGP_NOWAIT; - fgp |= fgf_set_order(len); + fgp |= fgf_set_order(mapping, index, len); - return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, + return __filemap_get_folio(mapping, index, fgp, mapping_gfp_mask(iter->inode->i_mapping)); } EXPORT_SYMBOL_GPL(iomap_get_folio); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 351c3b7f93a1..7af5636eb32a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -576,6 +576,39 @@ typedef unsigned int __bitwise fgf_t; #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) +/** + * mapping_size_order - Get maximum folio order for the given file size. + * @mapping: Target address_space. + * @index: The page index. + * @size: The suggested size of the folio to create. + * + * This returns a high order for folios (when supported) based on the file size + * which the mapping currently allows at the given index. The index is relevant + * due to alignment considerations the mapping might have. The returned order + * may be less than the size passed. + * + * Return: The order. + */ +static inline unsigned int mapping_size_order(struct address_space *mapping, + pgoff_t index, size_t size) +{ + unsigned int order = ilog2(size); + + if ((order <= PAGE_SHIFT) || (!mapping_large_folio_support(mapping))) + return 0; + else + order = order - PAGE_SHIFT; + + /* If we're not aligned, allocate a smaller folio */ + if (index & ((1UL << order) - 1)) + order = __ffs(index); + + order = min_t(size_t, order, MAX_PAGECACHE_ORDER); + + /* Order-1 not supported due to THP dependency */ + return (order == 1) ? 0 : order; +} + /** * fgf_set_order - Encode a length in the fgf_t flags. * @size: The suggested size of the folio to create. @@ -587,13 +620,12 @@ typedef unsigned int __bitwise fgf_t; * due to alignment constraints, memory pressure, or the presence of * other folios at nearby indices. */ -static inline fgf_t fgf_set_order(size_t size) +static inline fgf_t fgf_set_order(struct address_space *mapping, pgoff_t index, + size_t size) { - unsigned int shift = ilog2(size); + unsigned int order = mapping_size_order(mapping, index, size); - if (shift <= PAGE_SHIFT) - return 0; - return (__force fgf_t)((shift - PAGE_SHIFT) << 26); + return (__force fgf_t)(order << 26); } void *filemap_get_entry(struct address_space *mapping, pgoff_t index); diff --git a/mm/filemap.c b/mm/filemap.c index 582f5317ff71..e285fffa9bcf 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1917,14 +1917,6 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, if (WARN_ON_ONCE(!(fgp_flags & (FGP_LOCK | FGP_FOR_MMAP)))) fgp_flags |= FGP_LOCK; - if (!mapping_large_folio_support(mapping)) - order = 0; - if (order > MAX_PAGECACHE_ORDER) - order = MAX_PAGECACHE_ORDER; - /* If we're not aligned, allocate a smaller folio */ - if (index & ((1UL << order) - 1)) - order = __ffs(index); - do { gfp_t alloc_gfp = gfp; From patchwork Fri Sep 15 09:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB2EEE644C for ; Fri, 15 Sep 2023 09:51:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50B536B024A; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F8A66B032E; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 223BF6B0330; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0DB6E6B024A for ; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ADF41140F8F for ; Fri, 15 Sep 2023 09:51:32 +0000 (UTC) X-FDA: 81238364424.13.BB50892 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf30.hostedemail.com (Postfix) with ESMTP id 49FD980019 for ; Fri, 15 Sep 2023 09:51:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=dRnQE4X3; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf30.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771489; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pQ5HIMyPnnwhcYJ76rc1mPPc+k+o81B2sKXtPyg4zdw=; b=3emwn8XobmyVJSmq7R+wFY7/6LW+/C/zBT76EZ3Ox6FXVKkxkrycKPxPpZdeltDjcrtUML m/v5/iB8XYOPkzlrgf5oLErrXJxb3XN4L6puDcUbxYzn0JIRjp+yBjYrNQnFeLZCfLG66K Zo5HgljrM+00Vxlv3NRV6SONXW97vng= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=dRnQE4X3; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf30.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771489; a=rsa-sha256; cv=none; b=6V6xahOiBXDGTCCMjB2c9fBaXmAioIw1+2MWMxJ9DMZ+ozeId4NwurI4GOKwRnHNcGnYqE j6ft22IWWHzvTb7zFvc6Zn5zMp+stnGBz52cEmoPJ3HKBpboDA+cGsmP4S8XFXovpj/zG5 RLPxX/C36JxZMv7lHzi0tUZDY+sxHRU= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095127euoutp0229001aef2c1fc29bf144af6eb656b34a~FCbAsA5-y1204712047euoutp02S for ; Fri, 15 Sep 2023 09:51:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230915095127euoutp0229001aef2c1fc29bf144af6eb656b34a~FCbAsA5-y1204712047euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771487; bh=pQ5HIMyPnnwhcYJ76rc1mPPc+k+o81B2sKXtPyg4zdw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=dRnQE4X3b17aD2oqDXZH5BTfLC+mfYSYB3NR2dMRflrnrl1BtrmPzKFgseY6oQpbQ ZzkRwa4nIp88Qnirv0XY2Ve9K2j2PL4EIuwJZYmEoBYkHzlKcZliBSpnqcK4cO017M XzHLOtBtiZ3MG74YPPkZIIJXV1cCDwNNHE5/9D/o= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230915095126eucas1p2632b3b07d57634dee3bc87e2526e1769~FCbAZwO811725217252eucas1p2z; Fri, 15 Sep 2023 09:51:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F2.9A.42423.E1924056; Fri, 15 Sep 2023 10:51:26 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230915095126eucas1p2cf75674dab8a81228f493a7200f4a1ba~FCbACyp_W0866108661eucas1p2R; Fri, 15 Sep 2023 09:51:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230915095126eusmtrp29f2fa2307f1978fafd648c484cebcafa~FCa-9WV9v1712217122eusmtrp2z; Fri, 15 Sep 2023 09:51:26 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-f4-6504291e5557 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B1.3B.10549.E1924056; Fri, 15 Sep 2023 10:51:26 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230915095126eusmtip299bf0302eaf2d7781e72b80611f92e41~FCa-x_3a21112711127eusmtip21; Fri, 15 Sep 2023 09:51:26 +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; Fri, 15 Sep 2023 10:51:25 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 15 Sep 2023 10:51:25 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 2/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Topic: [PATCH 2/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Index: AQHZ57owSgjKzHCSYUqzwv9vQRCtyw== Date: Fri, 15 Sep 2023 09:51:24 +0000 Message-ID: <20230915095042.1320180-3-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SfVCLcRzvtz179pSbe1rRj2a0K9S06s65B7WrcPfQddd5u0OHnZ6rWMvt afJ+ORzlpLxdrVLpZSuFJpNUunV6QURRhN7GqFxEE8toPXP67/Pyffl8f/fD2PxmzlwsVpFA KRUyuQh1QvSNP5/6Cr0Ryv/ag8VE9o0ylLj29hxKtBtnEu9HUxGi9rWYqKltQYj26myUeFf2 h0NUT1Rxia6094AoHhvhEvcqrqKEZTwbDeaRWUnPEDJPpyJvaX3I9lYVqStNRknd6Hku2Zxh QchvOmEEttUpMIqSx+6jlH7SnU4xZj2y9xNnv+VYOicJmJAU4IhBfCnUlkyAFOCE8XEtgHWf h1kM+Q6gxvwKYci3SZJhQv+15DZa7YYGwOTC7v9VDfphO3kMoF7fZyclAFb3lnJs/SjuDeta dFyb4YpncWBDwWlgM9j4UVj2QT2VywVfBvXPU1g27IqvhL0VL9gMlsB3D/sndQxDcC944g5l k3mTJT/SLkzJjnggHBlPtMkAnwf7S35xmelu8LUxl8Wc4AyvZtWwGTwbWqv77Kctga2dRsBg f3i7qM7+SiI4cTrfnlICuy5dRBkshsX5Q2wmgjNsyTRO3QtxqyPUm56xbXkgvhoammOZOS5w sKmSy2AB/HM3l5UGxOpp8dTTVqinrVBPW5EHkFLgRqnouGiKDlBQiRJaFkerFNGSXfFxOjD5 2R5Zm0arQM7gV4kBsDBgABBji1x5aBCL4vOiZAcOUsr4HUqVnKINwB1DRG48cVDLLj4eLUug 9lDUXkr5z2VhjnOTWH6CHp+siDeCSBfKsqFyvYPWvL08vujKj4Qkl6/ybto3RhTu/URrXm3x MvV4hhVIIxVyaU5ZQLRoFurhcXZNyMuh39LL9aH9Bq/kAjJg6UbfA7maRN9mzwvPT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j4mDU6qBqbB6f//C1Zwhr5xnrz01bdr361KegsJSb2a9fxgxwfbigj8B k5g/cLGX8vz/cWXK7O8lYdPO77n5KOTx5AIFvp816suWr1D3YtgfEq3tLHg9wXTK9CdbAqSq o/bF2Vkyvd++v22h3qve/pKSsjdmuybrrjvQ8+Oo2dZJ2kvXC888rbH6TERFjc38gP7Qp/6z zzv1Cfq8E9vmJr8qw2HJ0gnJSSkR3HdKbXoX+XzZZ3+h+/UE1bwOzR1K/XPN/15KeRpWvcXk Wlm7tf+TD7vfnVinP/U6j+Yk8/XzHTIVnu2WU1qrmr4v8Is3++FW5VNp3a6zRepbRO/Eaa24 dPW/wVybc3lSVY65Tptmrf776qESS3FGoqEWc1FxIgB/H/s+1QMAAA== X-CMS-MailID: 20230915095126eucas1p2cf75674dab8a81228f493a7200f4a1ba X-Msg-Generator: CA X-RootMTR: 20230915095126eucas1p2cf75674dab8a81228f493a7200f4a1ba X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095126eucas1p2cf75674dab8a81228f493a7200f4a1ba References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 49FD980019 X-Stat-Signature: 4zyze6w7m177b16r6qefk3fyz68yj1ki X-Rspam-User: X-HE-Tag: 1694771489-819830 X-HE-Meta: U2FsdGVkX1/r3RXf979gO52HQfvoKU4CMb/XgCAUZ2+kltTU/6HJpoRCLbYWiRLjXnaiavfhashN0fMjca9fls/SrN29TDrnjlFSKKL0jPPAJtA1jbgqSfN5vbRpMNSwqI7uM8CyrMFISO43cGQndTbMA+2Dy3BPQLmayTq0Wcc5bxp4EsNFADdHUDB8fjZgqwKYB9eqMJYZ1kCwbEpYIEJxKiF5a1jNojbgO8tvCT+q7TzVJ0FF8cVKrUXwFRgZ+ytRF6KU8Fl9+EccOmMHFVdptqIhhkKTZvBFk/vc1skXq6UqqfVJUxOaGsRJrqU33mUUn3uZCj2Ocq6IW1Py2wa9OZsN9GnSsgCkWA1H9Jhd2GVd635itLJfXviZsk/noAKbceg8uO8lGMCAgKTBDMf8sbWyaw21V443EIWvasumxWk8Lj3OuNqCyErxjswP1mRsACNMh07YZjaP7uiqb6L2cSy6mrWT2hj2odfKJYcMIiMRPX4Q3gb9pR9byp0LwtAV3yOH5cmPy3CV38CgrkA93NIuzWH88cS5/93xxVJ5z4TIQEjSPxOqs6pEBeSewoLvqPwTuRHCdVdGzYQ1JZBQs9iHq74wNlihddeVWzcCpbIzNH28US1xB0K2XdDGuzSl4vbubpDToilLvs201c+pMlxE0BWDfQWpt7OKKRJw/u/tA8QxhjXebpC3C+qsdRZ4hE01ooDEwhod1WkYqQ0v0hPgf9wXJ385VytCDUBfTJCnopRTwAUme/vY1Rjvt3++STTj6DWlKAvVwXjh7XexpAckLuKUV+avmUnnRb17b3iKTEACcd0P99LbX2EVxLliF1n07q/pXjWv2+Bfa/t2mnVtbzA65TsfQcq4+peGw+3+pAijLHBa24Sb+TmpIDXirnKYbvcSNyIuYasD7uXLMnd3czLNPuUfcqaYaK5qHuTMwWeXkaMf+eBV9/G9vEJhxU+powl5B89LKml gGWZuRYO /4Xo5+FQDnty9Q3D62pLfH9BTRCj97nPT4zwN3nqCo+ybWUyRx/HHz8bWD4N+1G5vK4pNqbNE644MvSw89JYCw9yqcNeELI5MDtJJY6BEWZinQLwoi/zi0zUee9LQNESJ9U5kzDWr05YE/3TuzKk2ZDi+qHaKmFk4BeEo3sxEL0FUvhez5hphmQ1KABBKVWwNswJjQYUHHIMJmeE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The commit [1] replaced all BLOCKS_PER_PAGE in favor of the generic PAGE_SECTORS but definition was not removed. Drop it as unused macro. [1] e09764cff44b5 ("shmem: quota support"). Signed-off-by: Daniel Gomez Reviewed-by: Luis Chamberlain --- mm/shmem.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 13c27c343820..8b3823e4d344 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -84,7 +84,6 @@ static struct vfsmount *shm_mnt; #include "internal.h" -#define BLOCKS_PER_PAGE (PAGE_SIZE/512) #define VM_ACCT(size) (PAGE_ALIGN(size) >> PAGE_SHIFT) /* Pretend that each entry is of this size in directory's i_size */ From patchwork Fri Sep 15 09:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2220BEE644D for ; Fri, 15 Sep 2023 09:51:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 140F16B032E; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EC2A6B0330; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57D06B0331; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D2BA46B032E for ; Fri, 15 Sep 2023 05:51:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9E0A8120B5A for ; Fri, 15 Sep 2023 09:51:33 +0000 (UTC) X-FDA: 81238364466.06.8A64A3B Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf08.hostedemail.com (Postfix) with ESMTP id 69543160011 for ; Fri, 15 Sep 2023 09:51:30 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=uNcOYwD1; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf08.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771490; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MPvP7/bW/aMWENbqWzpXNJZ4Wgeps0pePFDrgq86iOg=; b=2dABUa+bcCamT7YZCe+wjLh/ZcXyFzL00M5oQ2dYGLAvllnyLAUcpKu0Glpyvts4wS2Wgd PdkZUk8HXt185LV51UrqlI3vxM9mkMzz8XEboHve3dmQqS+ExGsKqk9tnHQwPxCQUTvG3I CoVm02oK2Yd4EcNaLDAUJpTXJq1mCJQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=uNcOYwD1; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf08.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771490; a=rsa-sha256; cv=none; b=b2r/KUFnHqIZhSM3Vr/GBBlg/Pdpndin3yFgackRaV3Gf/GVAQki3PDJpU++hG0RP5Lp6l lKoS6s+Cr3Q6soP2h4UnqXoyOHvDsRDaM5I47FqUZLXX3l3iody8B2AfXJGvGSXpTmQLkw +SFDp40zLzmrSlNrbuwJHm6fjlAeDBM= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095129euoutp01ed7795cfac8e644e4ee637c205860b2b~FCbChYZH_0839808398euoutp01R for ; Fri, 15 Sep 2023 09:51:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230915095129euoutp01ed7795cfac8e644e4ee637c205860b2b~FCbChYZH_0839808398euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771489; bh=MPvP7/bW/aMWENbqWzpXNJZ4Wgeps0pePFDrgq86iOg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=uNcOYwD1KXFgn9ho/vmqx/GG2pljZqP4wWUJe/iAOVXSPVAgPm4bqM8VFV5ieV4ru CbC7HBFUYykz+VdcN8I3F7MfhS7wQogKmSFNon3fHPgSa+5/m0D690BwJavo6RtfUA 8Km3tK7Dl/XcLhl1Dqg+eDb/YI31C7YHaTW7Ko5k= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230915095128eucas1p1c1a3ec9f583e1c28f521e3e197036d1d~FCbCF227V1980119801eucas1p1J; Fri, 15 Sep 2023 09:51:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 20.BC.37758.02924056; Fri, 15 Sep 2023 10:51:28 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230915095128eucas1p2885c3add58d82413d9c1d17832d3d281~FCbBm3leg0860408604eucas1p2N; Fri, 15 Sep 2023 09:51:28 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230915095128eusmtrp2d7b39d9dd999d006e785228e6b920fbd~FCbBmNn_X1716917169eusmtrp2j; Fri, 15 Sep 2023 09:51:28 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-6d-6504292037c2 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 04.3B.10549.F1924056; Fri, 15 Sep 2023 10:51:27 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230915095127eusmtip135d9c0b9a9fdcb2530a0ed2723b2c1c3~FCbBb1Xge2687926879eusmtip18; Fri, 15 Sep 2023 09:51:27 +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; Fri, 15 Sep 2023 10:51: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; Fri, 15 Sep 2023 10:51:27 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 3/6] shmem: account for large order folios Thread-Topic: [PATCH 3/6] shmem: account for large order folios Thread-Index: AQHZ57oxkDDTtuHEck+OwDgOe5Q+ig== Date: Fri, 15 Sep 2023 09:51:26 +0000 Message-ID: <20230915095042.1320180-4-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAA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g113vJPi/jkI/k7fd1t2tux9hQNczlcdvYT9pGqWXfLuOKPlPOla+pVbkcbdIgqf lt3Q8Jg8y5crY9r1x0GfnA9Z9WV9N1/BXuZ+dN51K/8di6bKrfv3+MXT3f/X31k7+Y2Bb/4u BRnRAolN3x+u7Uhe5HIm/pv4Xr1vJs6CVWLvGD1FGxj/OUQEh3xZc//M4zOX9qzv3jK3x5O/ 6ON1ld1PT//6Vz6J/e91J6kTH1OrvS4rsRRnJBpqMRcVJwIADD2h59cDAAA= X-CMS-MailID: 20230915095128eucas1p2885c3add58d82413d9c1d17832d3d281 X-Msg-Generator: CA X-RootMTR: 20230915095128eucas1p2885c3add58d82413d9c1d17832d3d281 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095128eucas1p2885c3add58d82413d9c1d17832d3d281 References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 69543160011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: pnsjsyym7dxj7z4bysph6nbnwwyjer1s X-HE-Tag: 1694771490-565201 X-HE-Meta: U2FsdGVkX1+RZ/8bkA2blTw9sFmFL4jvof8kRjRbIR1PCZ8bghsgdNAv3q5aS0L1PPyPInk1ZAxCRQFw/h5G3V9V2CLC9P1AwK+fARw1MLD0AhvnqFOal/if33IH3cykaZDcyy8ebSQcZ2YKFwAr0ZFAdqX1AAQYB1yyc09QHOXknUjllis29mLoNGnYSNUreCrs1fVazSeepfUoYoN9hEhSeBKjehFfYQCUk2iFXi++lTesX1QsqlkkfNz48GreYlkBiJvcvwiLY+G9+sxWl+WSeFluGI1Cq3KfQaBYsPHaqvQFAIQVNJupA9NsmFMS1kn+LafJgi0rlG1wtGoq1B4SwvO3rsTkB2J1AQNlVp+WLeb0xOAxdBljg8qaE7n4URwzo9Xj+QytFyAYGSB2fFlgQAmUBCbtVomJ7g9539Q7ASb62XakCfklcdSH+82fbC/PBn5dhlOKCk9HXoaJDORYuWscR7iXZYAaSebF6zptbEe0NzJPAvUC6AaKGHXeFEX63rKD0t3tak/19O061A86YqFGonvntdYej8srGH0+8HV9yTtjcVZ/Bo8DeEV3tvASKyPNBiRq1mOSBKWoT8BhqAjJdTT0eA4XnSk4brDDNK3OsHgNa1WYv1bpe955vQmUDG4ZKUOkqbt7J0wfeUbbffScXyZVE/5Y2LDhn/KPBMTJ2FVx/ea2DJrySU3Qq+HdodbfW7EoBKkMJH1srSdBIr/ojTMWuQ6gPWM4+gxbFQIcgcst2xe/j1jcTzVo6Ct9P/SD8PgzPmyLGvKrm1JLYXahM30MUvIQMy1TXQyLJ7Yq5zR9qF//ljJAWYxazpEDLjGGGyvdtlPt76xbc4Y5UWU+xMnw4xaT9KXkEaf5MPo22WoWw/yai8kffaPFqWijlF2GyiED5QOqkygCi6lwJIvJ9sJ3XSiVVA7Q0MnOFszUOyzAJ43sURxD5R3bk81j8MK1XqAh17M6xsa hZUuwvke shWk1knYz3hlgPhgoI8zyYIjJZoOaaCTxI/t8e8zqilqBe2JLaNTy6waTvkma7o8CAKNgFll4Su8SapVtQTEThN0hp0i1KmLRGkfcTBbzv5nyiJzrIGJbhyAsrRxqnJmF+YLFczwFuWGzKTXnwIkLFWRnIxhZlS+bkjdM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Luis Chamberlain shmem uses the shem_info_inode alloced, swapped to account for allocated pages and swapped pages. In preparation for large order folios adjust the accounting to use folio_nr_pages(). This should produce no functional changes yet as larger order folios are not yet used or supported in shmem. Signed-off-by: Luis Chamberlain Signed-off-by: Daniel Gomez --- mm/shmem.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 8b3823e4d344..836d44584796 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -869,16 +869,16 @@ unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end) { XA_STATE(xas, &mapping->i_pages, start); - struct page *page; + struct folio *folio; unsigned long swapped = 0; unsigned long max = end - 1; rcu_read_lock(); - xas_for_each(&xas, page, max) { - if (xas_retry(&xas, page)) + xas_for_each(&xas, folio, max) { + if (xas_retry(&xas, folio)) continue; - if (xa_is_value(page)) - swapped++; + if (xa_is_value(folio)) + swapped += (folio_nr_pages(folio)); if (xas.xa_index == max) break; if (need_resched()) { @@ -1006,10 +1006,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, folio = fbatch.folios[i]; if (xa_is_value(folio)) { + long swaps_freed; if (unfalloc) continue; - nr_swaps_freed += !shmem_free_swap(mapping, - indices[i], folio); + swaps_freed = folio_nr_pages(folio); + if (!shmem_free_swap(mapping, indices[i], folio)) + nr_swaps_freed += swaps_freed; continue; } @@ -1075,14 +1077,16 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, folio = fbatch.folios[i]; if (xa_is_value(folio)) { + long swaps_freed; if (unfalloc) continue; + swaps_freed = folio_nr_pages(folio); if (shmem_free_swap(mapping, indices[i], folio)) { /* Swap was replaced by page: retry */ index = indices[i]; break; } - nr_swaps_freed++; + nr_swaps_freed += swaps_freed; continue; } @@ -1528,7 +1532,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) if (add_to_swap_cache(folio, swap, __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN, NULL) == 0) { - shmem_recalc_inode(inode, 0, 1); + shmem_recalc_inode(inode, 0, folio_nr_pages(folio)); swap_shmem_alloc(swap); shmem_delete_from_page_cache(folio, swp_to_radix_entry(swap)); @@ -1801,6 +1805,7 @@ static void shmem_set_folio_swapin_error(struct inode *inode, pgoff_t index, struct address_space *mapping = inode->i_mapping; swp_entry_t swapin_error; void *old; + long num_swap_pages; swapin_error = make_poisoned_swp_entry(); old = xa_cmpxchg_irq(&mapping->i_pages, index, @@ -1810,13 +1815,14 @@ static void shmem_set_folio_swapin_error(struct inode *inode, pgoff_t index, return; folio_wait_writeback(folio); + num_swap_pages = folio_nr_pages(folio); delete_from_swap_cache(folio); /* * Don't treat swapin error folio as alloced. Otherwise inode->i_blocks * won't be 0 when inode is released and thus trigger WARN_ON(i_blocks) * in shmem_evict_inode(). */ - shmem_recalc_inode(inode, -1, -1); + shmem_recalc_inode(inode, num_swap_pages, num_swap_pages); swap_free(swap); } @@ -1903,7 +1909,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, if (error) goto failed; - shmem_recalc_inode(inode, 0, -1); + shmem_recalc_inode(inode, 0, folio_nr_pages(folio)); if (sgp == SGP_WRITE) folio_mark_accessed(folio); @@ -2663,7 +2669,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (ret) goto out_delete_from_cache; - shmem_recalc_inode(inode, 1, 0); + shmem_recalc_inode(inode, folio_nr_pages(folio), 0); folio_unlock(folio); return 0; out_delete_from_cache: From patchwork Fri Sep 15 09:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBDE4EE644C for ; Fri, 15 Sep 2023 09:51:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A625A6B0330; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A130C6B0331; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83E356B0332; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 71D2A6B0330 for ; Fri, 15 Sep 2023 05:51:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 32CB5120FB9 for ; Fri, 15 Sep 2023 09:51:34 +0000 (UTC) X-FDA: 81238364508.27.610B140 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf06.hostedemail.com (Postfix) with ESMTP id 4646E18001C for ; Fri, 15 Sep 2023 09:51:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=J2oiuKF9; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf06.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771491; a=rsa-sha256; cv=none; b=sg0O7QhtD1cTRegx3r7aO1MGFzHrt4pLZPDlI84HIk3V5el5RvDjrHEEAodEcuvm5q2lXD PyKvvaOpsLKa4wwtb0bw2Q/AJW0tjaS8zBSrrJYYaippzaESjAWWUkln3D8ny5l5UVTdcT Yi53bMhcaVKbL97GgnPfr6uHu98yZGs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=J2oiuKF9; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf06.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771491; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N6Xp9rRcJyqLlmISFymB45Rbo8znf7lO4hyxQ746apU=; b=6ZPGB4Ys6QhnjE2q8exqbEzu3JX6m50UA3KiPRcvWWdIW++KuWc/VIbuyJZMcn43H7lIfA n5tn5OURTuNC91stQOM6Qtw7Z+lD2Kj5ElIZo7jdi4v+TPWS5mkJHZYeIrFpW3jHTmAPJM n+g3NaVSijGVmlginJM2uwqE4RJyV+g= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095130euoutp024b5c416e5bea8bbc9ea16dacad0744b5~FCbDhtvO31230712307euoutp02K for ; Fri, 15 Sep 2023 09:51:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230915095130euoutp024b5c416e5bea8bbc9ea16dacad0744b5~FCbDhtvO31230712307euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771490; bh=N6Xp9rRcJyqLlmISFymB45Rbo8znf7lO4hyxQ746apU=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=J2oiuKF9izy/Cw4x6EnydyqbwSzsnCF2Y0XFOnQ8IlWbu28IVYZHWP6sXeY3XHfUG 193Msihdm4oTg6/gkV33eD2KXYpN7XwTFksMmuEQWDUGFpWSGXCnEyBLb6rHhGaAJB IPHcHFtFpDvNNNWfqxWRKhZ64MxGq4FRAnOOVXYc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230915095129eucas1p185187ba8793eb2c506b0e568c0f6f608~FCbDBzwkA1980119801eucas1p1L; Fri, 15 Sep 2023 09:51:29 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 16.BC.37758.12924056; Fri, 15 Sep 2023 10:51:29 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230915095129eucas1p1383d75c6d62056afbb20b78a3ec15234~FCbCnzYvG2007620076eucas1p1P; Fri, 15 Sep 2023 09:51:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230915095129eusmtrp2e690b2af500d4bb298bad715c8e8eb8f~FCbCmH9Ln1712217122eusmtrp24; Fri, 15 Sep 2023 09:51:29 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-7b-650429212abc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 65.3B.10549.02924056; Fri, 15 Sep 2023 10:51:28 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230915095128eusmtip1ea983b58b5ef15df525d8a7f9a3c571b~FCbCaAFBw2687926879eusmtip19; Fri, 15 Sep 2023 09:51:28 +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, 15 Sep 2023 10:51:28 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 15 Sep 2023 10:51:28 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Topic: [PATCH 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Index: AQHZ57oyL8hoyYlY0kqz+yQTJH6NwQ== Date: Fri, 15 Sep 2023 09:51:28 +0000 Message-ID: <20230915095042.1320180-5-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBKsWRmVeSWpSXmKPExsWy7djPc7qKmiypBi87ZS3mrF/DZrH6bj+b xeUnfBZPP/WxWOy9pW2xZ+9JFovLu+awWdxb85/VYtefHewWNyY8ZbRY9vU9u8XujYvYLH7/ mMPmwOsxu+Eii8eCTaUem1doeVw+W+qxaVUnm8emT5PYPU7M+M3i8XmTXABHFJdNSmpOZllq kb5dAlfGkdfvGQt6ZSqmnJ3G3MD4QKyLkZNDQsBEoudyA2sXIxeHkMAKRonGjxuhnC+MEntX 3IZyPjNKvGw/xNLFyAHWsvahF0i3kMByRonVG9XgalZvu8AO4ZxhlHh9/ysjhLOSUeLUhtnM IC1sApoS+05uAqsSEZjNKnF4cQcjSIJZoE5izbNZLCC2sICPxNQ5W8HiIgLBEqd/zmCHsPUk 3u3vBBvEIqAq8XzSCzYQm1fAWuLKzfOsIOdxCthIvP9RDhJmFJCVeLTyFzvEeHGJW0/mM0E8 LSixaPYeZghbTOLfrodsELaOxNnrTxghbAOJrUv3sUDYShJ/OhZCnakncWPqFDYIW1ti2cLX zBAnCEqcnPmEBeQvCYEmLomWJyegweUiseZbBcQcYYlXx7ewQ9gyEv93zmeawKg9C8l5s5Cs mIVkxSwkKxYwsqxiFE8tLc5NTy02zkst1ytOzC0uzUvXS87P3cQITGyn/x3/uoNxxauPeocY mTgYDzFKcDArifCy2TKlCvGmJFZWpRblxxeV5qQWH2KU5mBREufV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gJFlFaNIamlxbnpusaFecWJucWleul5yfu4mRmBi2nbs5+YdjPNefdQ7xMjEwXiIUYKDWUmE l82WKVWINyWxsiq1KD++qDQntfgQoykwhCYyS4km5wNTY15JvKGZgamhiZmlgamlmbGSOK9n QUeikEB6YklqdmpqQWoRTB8TB6dUA1PKbM6D9f0BZ1tvlSc+uKf93eREg1OWxM9HLfd2ff5X 692x+1zQs4gbIkV35iSpRl58e6ZuZqRhy7dNr4I8sw/ElVd9un059l1IQF390itNZq47tnxX Uv0jM2HLD+svel6GX+9VuzbbHWwWElVjsLXgeO16PUZsl+7ZiOILsb9ur0qxsDAWqFx1Ls/D 2/pxS+HH8mMOl31dOkpX+f57b1+7pmrvZ+2TIVNVrFwfKIo8+8Vaoxu1c4Pjp2ClHae1uz2n +1XdP+KZy1scpHv5UeCeoIvBM3/t2Dbnpq7R9oOTfAUeLHe/uYbVfPoXqxObOedtv7Vi5q63 q236YpeeYLm98UbPTJUwkZ/+b8xvnJ+vxFKckWioxVxUnAgAlvTUeNUDAAA= X-CMS-MailID: 20230915095129eucas1p1383d75c6d62056afbb20b78a3ec15234 X-Msg-Generator: CA X-RootMTR: 20230915095129eucas1p1383d75c6d62056afbb20b78a3ec15234 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095129eucas1p1383d75c6d62056afbb20b78a3ec15234 References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4646E18001C X-Stat-Signature: qhxks9fobb1cb1wqs7e6etdunb44cds4 X-HE-Tag: 1694771491-18316 X-HE-Meta: U2FsdGVkX1/I9TP8nHVgyux2DahhV35MmPhQJ34dhnw1dEHe2ETPoWMgWQKYQtna8eJgicvB3ugGJZ2BDrwMbD8SyDcESfGD6iN+1VeOsaVuRO/nh23EgCOOviv4OvoHZW3NJfjfIam2moETGPmTxnciCH9ptgrjo1u8und8fVkQUBQXbmSciC3My3DI5gr8IpWzoW1QJRcAEcNkK2HsB4CWGOnYnIbj3fTRNflJNNR9GOwI106HBEEn9H0YGywBUkw7zd2Vcs8JlNVsghLtJXQURyymbQo7RSlsmVxW7B8Z9MiJf5IP7IcHldmjroG3bCU28vL7DHX4eCsm6XwI1t0XjgtHHU/iHQCbO9bUJ68pURwA+k0P7+eS+5sIyvTxtSL9uK5c1X5qiESjZCZ5TQhFcx9q9XNTiX9vFfIWi/Zab2Ll+/5BmmMWoV0DEoeCX+lUEZmuzrAenohHsWMgf3kaj6q4WHxBl8BpBLecMGUjIjbYqrNjtKzRb0oJoDSC9BazLlZSqGE2O7be4uI03lcMSwFFQpabNdooG8ZcUY+ZCndBu1/taa3V0LSDAp//iStMZEuFVd5D15U2Yq7fg98wkypoRczlGDm4/azhoCs49mJFXqJwcXcDOAeSPpRieJqpPs92cuDs1Uh42aK67RBw7KiXKlk6HhPeqf/xP64hVcq0zcWgQmNESfDFz0ibKjwcFbuSOpuuMc1ZuETj/YdzBB/corI/CldtAGI0zLfvKhD2lD6dutLfpbc/Qp6vNnfP4IsH4DJ3R0HCWrWEmDVqYKXJmgvx3JS7+N6yn0b3KDw5IwQlcC79ksYlCftow3XVR/dVXIdVLi7kh4PWtqexf4zYE3gThRcBM3jZ4VuTp+y9A7cQWI+6K0PDNgOZT8B5TxWkMw2uj+83UicxmtmyATKPYMMsTVgegfb1ik0yRXq2H7Prnu0MusY2GMbtS1PrKRwXXDBe2picSs0 ei5DMOX8 ySsPQssNymc1tEW21TQDo9egQ6ZzBmCtt+avyFuHYabbeWsmOAGONBSAcMJ1LePX6HvnR74smX0JGYuLBJRWITbivZr+KKn4DK7LY+N5bW1CHQsGzzLKe6jRehHZ0tkzcogQ/djeWts9YhDweeb3SxSOaMn1FxC8H2CxBvti5flKDj09HKhjE2XjrC/7STIa0KDvE8VmOOpYCL7/2/jd6RN+WpQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation for high order folio support for the write path, add order parameter when allocating a folio. This is on the write path when huge support is not enabled or when it is but the huge page allocation fails, the fallback will take advantage of this too. Use order 0 for the non write paths such as reads or swap in as these currently lack high order folios support. Signed-off-by: Daniel Gomez --- mm/shmem.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 836d44584796..ee297d8874d3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1669,20 +1669,21 @@ static struct folio *shmem_alloc_hugefolio(gfp_t gfp, } static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) + struct shmem_inode_info *info, pgoff_t index, + unsigned int order) { struct vm_area_struct pvma; struct folio *folio; shmem_pseudo_vma_init(&pvma, info, index); - folio = vma_alloc_folio(gfp, 0, &pvma, 0, false); + folio = vma_alloc_folio(gfp, order, &pvma, 0, false); shmem_pseudo_vma_destroy(&pvma); return folio; } static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, - pgoff_t index, bool huge) + pgoff_t index, bool huge, unsigned int *order) { struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; @@ -1691,7 +1692,7 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) huge = false; - nr = huge ? HPAGE_PMD_NR : 1; + nr = huge ? HPAGE_PMD_NR : 1U << *order; err = shmem_inode_acct_block(inode, nr); if (err) @@ -1700,7 +1701,7 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, if (huge) folio = shmem_alloc_hugefolio(gfp, info, index); else - folio = shmem_alloc_folio(gfp, info, index); + folio = shmem_alloc_folio(gfp, info, index, *order); if (folio) { __folio_set_locked(folio); __folio_set_swapbacked(folio); @@ -1750,7 +1751,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, */ gfp &= ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new = shmem_alloc_folio(gfp, info, index); + new = shmem_alloc_folio(gfp, info, index, 0); if (!new) return -ENOMEM; @@ -1961,6 +1962,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, int error; int once = 0; int alloced = 0; + unsigned int order = 0; if (index > (MAX_LFS_FILESIZE >> PAGE_SHIFT)) return -EFBIG; @@ -2036,10 +2038,12 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, huge_gfp = vma_thp_gfp_mask(vma); huge_gfp = limit_gfp_mask(huge_gfp, gfp); - folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true); + folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true, + &order); if (IS_ERR(folio)) { alloc_nohuge: - folio = shmem_alloc_and_acct_folio(gfp, inode, index, false); + folio = shmem_alloc_and_acct_folio(gfp, inode, index, false, + &order); } if (IS_ERR(folio)) { int retry = 5; @@ -2602,7 +2606,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (!*foliop) { ret = -ENOMEM; - folio = shmem_alloc_folio(gfp, info, pgoff); + folio = shmem_alloc_folio(gfp, info, pgoff, 0); if (!folio) goto out_unacct_blocks; From patchwork Fri Sep 15 09:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 018A0EE644C for ; Fri, 15 Sep 2023 09:51:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A04E6B0332; Fri, 15 Sep 2023 05:51:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 901936B0333; Fri, 15 Sep 2023 05:51:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E0C76B0334; Fri, 15 Sep 2023 05:51:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5B4716B0332 for ; Fri, 15 Sep 2023 05:51:36 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2D2B8B4398 for ; Fri, 15 Sep 2023 09:51:36 +0000 (UTC) X-FDA: 81238364592.17.EEC79BC Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf20.hostedemail.com (Postfix) with ESMTP id 354921C001F for ; Fri, 15 Sep 2023 09:51:32 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=JOehX4by; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf20.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771493; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KBxqvbiqwxbpjqMz9Z69KDs2z1l+Vy83NL/rF/oYkIA=; b=wqck3eQ+NX9tEjEHGfFRAT4WwNVMxYXGOSet9GvQ+7Dn+K1ji5XOme7JpkUBCCO+h0pM9g 4vHHbA+ugOytxKlrzc3USp5eqQuZpObNrlZu6C7rDNiTO5PS3w+SHX62iFNkPNaMpPn+Uh CLK/v4WCwK5IhyCLF6rgHyHx3lgP3jY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=JOehX4by; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf20.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771493; a=rsa-sha256; cv=none; b=CcUN9A1iirlQcQV/Yx9lFgKdWA/jw6cC7vBwOlruSGF/fk2lGjeciniCXymKNvlORyIJCK RbOBoMOA7Bs5sK8ocvVVDuBwSI0WPn6FAQhcdbMOoUhN7EKEkK4RFv0k8Y3q2/LaGqN4jp 8j6nENl0OJTEHbcPPEzmIX46Bo3pI4I= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095131euoutp02918031175f9c8fd2f4dd43eda8f14eb0~FCbFSC3vY1230712307euoutp02L for ; Fri, 15 Sep 2023 09:51:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230915095131euoutp02918031175f9c8fd2f4dd43eda8f14eb0~FCbFSC3vY1230712307euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771492; bh=KBxqvbiqwxbpjqMz9Z69KDs2z1l+Vy83NL/rF/oYkIA=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=JOehX4by5wtuX/tE/lkY/wGdcZiXjGvV+uvowvsHd2pzTMwEPs6jAg6SaKbGyeYcE iR1US6vyNvUMUR3ILaF+Pv2qAnqLxDu6BYFROC3ouKN35j27QhPrumNlIemiLqUGlG wMaSFWpsfDW+px6/1X9wAnkxvPWX6ewHOlmRMtkE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230915095131eucas1p25cc2b04fd359369a4fc473bf907da57c~FCbFAjAMZ1349613496eucas1p21; Fri, 15 Sep 2023 09:51:31 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2B.9A.42423.32924056; Fri, 15 Sep 2023 10:51:31 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230915095131eucas1p1010e364cd1c351e5b7379954bd237a3d~FCbEmMxFv0060700607eucas1p1L; Fri, 15 Sep 2023 09:51:31 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230915095131eusmtrp24a417d7970c44623708b2e39cfebe5a0~FCbElcNAu1712217122eusmtrp27; Fri, 15 Sep 2023 09:51:31 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-1a-65042923bb09 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 09.3B.10549.22924056; Fri, 15 Sep 2023 10:51:31 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230915095130eusmtip22dc6e7222c8a07a587bf7bef6f55c865~FCbES6n5V0935009350eusmtip2L; Fri, 15 Sep 2023 09:51:30 +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, 15 Sep 2023 10:51:30 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 15 Sep 2023 10:51:30 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 5/6] shmem: add file length in shmem_get_folio path Thread-Topic: [PATCH 5/6] shmem: add file length in shmem_get_folio path Thread-Index: AQHZ57ozxEpCdFcMBk645e2R7dVRyg== Date: Fri, 15 Sep 2023 09:51:29 +0000 Message-ID: <20230915095042.1320180-6-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02SfVBMYRTG57179+7tjtW1Wr2EMduUsZul4Y+LUMNwfczEjDEYg2tdWX1g txX5KoNRI5K+7G6lsJS0WqXUrpJRtpSy+RhGwkY0JopY1abtLtN/v+c553nPOTMvzhNZ+ZNw ZVQ0q4piIiQYgd6pdTyZ6TsDZWdfbJ5G6Y2FGHXjzTmMstnHUh09Z1HK8kpGmS1WlLJV6DGq rXCIT1UMlAuol8kdgDL87BZQlcV5GNX/W48FC2ldXAtKXzJp6NvXpbStUUObChIw2tSTIqAf ZfajdK9p6hp8ExG0g41Q7mdVsxZtI3ZlJBXx9g7KDsTbT4A4cNw3EXjgkJwLu1vf8BIBgYvI 6wDe7/uMceIHgI76QT4negF8m6Xn/4v0vuhyR64BaG06I/jf1Vic484/HhYJ39wiH8BPueWI K4+RM+A9q2kk4kXq+PDB5dPAVeCRR2HhRy3q4vHkEphScnY4jQ830bAqc7nL9iLlsKzAKHDZ KOkHDT9GnhSSC2BNqmPE9iCDYPfvGJcNyCnwff4fAfe4N3xlz0G4C8bBPJ2Zx/EE6Kx4h3Ec ABtf2AHHs2Hp1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EVAVWLZFyaQMK+AtcShKT/BwkJA9qzpXiAm p4CNxPsf5SAVjAKyEo9W/mKH2CMucevJfCaI+wUkluw5zwxhi0q8fPwP6i8dibPXn0D9ayCx dek+FghbSeJPx0Koe/UkbkydwgZha0ssW/iaGeIaQYmTM5+wTGCUnoVk3SwkLbOQtMxC0rKA kWUVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYGraduzn5h2M81591DvEyMTBeIhRgoNZSYSX zZYpVYg3JbGyKrUoP76oNCe1+BCjKTCAJjJLiSbnA5NjXkm8oZmBqaGJmaWBqaWZsZI4r2dB R6KQQHpiSWp2ampBahFMHxMHp1QD09psvsWhSvdN5prPPGOTsv76q4qHvxznfltUwXvXb7FG ve03ZmbPC5pPPAQPpe9umbpgbonXqegVcy7+51BJ5WSferX7nuSlPuaqfKZTzJ92VP7ddLyt uL779Azlw45v1pg+LitjuBTbz3Bx93TFld9ucff8f9h3oDM5MXjFScct3Kxlqicn6+1UujW7 XFo2+nG+o8cCN5/T7hHHk62qcpmyL0w4XPy5bGGKfezyV3EaG55IObOFO0ZIrvKbvjzw2MTX 8ydk/T5vtfjZYrXJWm8Tnl6JZD3GKXG5/FLRsrnzzk7Z+MRH0r3gV+i3mStjnO60TzyS21j4 v3mJxP+vnMmT02c8sTp+3flzua/+XRUlluKMREMt5qLiRABLoVzZ1gMAAA== X-CMS-MailID: 20230915095131eucas1p1010e364cd1c351e5b7379954bd237a3d X-Msg-Generator: CA X-RootMTR: 20230915095131eucas1p1010e364cd1c351e5b7379954bd237a3d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095131eucas1p1010e364cd1c351e5b7379954bd237a3d References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 354921C001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sdc33khhr5ks7jhy9xkqhaarozd3xe4w X-HE-Tag: 1694771492-848673 X-HE-Meta: U2FsdGVkX1+EDJOCqrw6hzhXeUfj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6vuanh2oh3V8+ch/oWjf3MlQhcI3fE+lAHXCwb143U+hYPpYfS3z6t9+B3x1ac27W9u4e3gO1dOMYNf8LLK3HYyBXEextRh6w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To be able to calculate folio order based on the file size when allocation occurs on the write path. Use of length 0 for non write paths. Signed-off-by: Daniel Gomez --- include/linux/shmem_fs.h | 2 +- mm/khugepaged.c | 2 +- mm/shmem.c | 28 ++++++++++++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 6b0c626620f5..b3509e7f1054 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -133,7 +133,7 @@ enum sgp_type { }; int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, - enum sgp_type sgp); + enum sgp_type sgp, size_t len); struct folio *shmem_read_folio_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 88433cc25d8a..e5d3feff6de6 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1856,7 +1856,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, xas_unlock_irq(&xas); /* swap in or instantiate fallocated page */ if (shmem_get_folio(mapping->host, index, - &folio, SGP_NOALLOC)) { + &folio, SGP_NOALLOC, 0)) { result = SCAN_FAIL; goto xa_unlocked; } diff --git a/mm/shmem.c b/mm/shmem.c index ee297d8874d3..adff74751065 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -969,7 +969,7 @@ static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) * (although in some cases this is just a waste of time). */ folio = NULL; - shmem_get_folio(inode, index, &folio, SGP_READ); + shmem_get_folio(inode, index, &folio, SGP_READ, 0); return folio; } @@ -1950,7 +1950,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, - vm_fault_t *fault_type) + vm_fault_t *fault_type, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -2164,10 +2164,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, } int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, - enum sgp_type sgp) + enum sgp_type sgp, size_t len) { return shmem_get_folio_gfp(inode, index, foliop, sgp, - mapping_gfp_mask(inode->i_mapping), NULL, NULL, NULL); + mapping_gfp_mask(inode->i_mapping), + NULL, NULL, NULL, len); } /* @@ -2251,7 +2252,7 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf) } err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, - gfp, vma, vmf, &ret); + gfp, vma, vmf, &ret, i_size_read(inode)); if (err) return vmf_error(err); if (folio) @@ -2702,6 +2703,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping, struct folio *folio; int ret = 0; + if (!mapping_large_folio_support(mapping)) + len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos)); + /* i_rwsem is held by caller */ if (unlikely(info->seals & (F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_FUTURE_WRITE))) { @@ -2711,7 +2715,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping, return -EPERM; } - ret = shmem_get_folio(inode, index, &folio, SGP_WRITE); + ret = shmem_get_folio(inode, index, &folio, SGP_WRITE, len); if (ret) return ret; @@ -2783,7 +2787,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) break; } - error = shmem_get_folio(inode, index, &folio, SGP_READ); + error = shmem_get_folio(inode, index, &folio, SGP_READ, 0); if (error) { if (error == -EINVAL) error = 0; @@ -2960,7 +2964,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, break; error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, - SGP_READ); + SGP_READ, 0); if (error) { if (error == -EINVAL) error = 0; @@ -3147,7 +3151,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, error = -ENOMEM; else error = shmem_get_folio(inode, index, &folio, - SGP_FALLOC); + SGP_FALLOC, 0); if (error) { info->fallocend = undo_fallocend; /* Remove the !uptodate folios we added */ @@ -3502,7 +3506,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_op = &shmem_short_symlink_operations; } else { inode_nohighmem(inode); - error = shmem_get_folio(inode, 0, &folio, SGP_WRITE); + error = shmem_get_folio(inode, 0, &folio, SGP_WRITE, 0); if (error) goto out_remove_offset; inode->i_mapping->a_ops = &shmem_aops; @@ -3550,7 +3554,7 @@ static const char *shmem_get_link(struct dentry *dentry, return ERR_PTR(-ECHILD); } } else { - error = shmem_get_folio(inode, 0, &folio, SGP_READ); + error = shmem_get_folio(inode, 0, &folio, SGP_READ, 0); if (error) return ERR_PTR(error); if (!folio) @@ -4923,7 +4927,7 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, BUG_ON(!shmem_mapping(mapping)); error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, - gfp, NULL, NULL, NULL); + gfp, NULL, NULL, NULL, i_size_read(inode)); if (error) return ERR_PTR(error); From patchwork Fri Sep 15 09:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13386756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CA54EE644C for ; Fri, 15 Sep 2023 09:51:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C2B66B0334; Fri, 15 Sep 2023 05:51:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 225096B0336; Fri, 15 Sep 2023 05:51:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 084156B0334; Fri, 15 Sep 2023 05:51:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E2C896B0334 for ; Fri, 15 Sep 2023 05:51:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BD6621C9FA9 for ; Fri, 15 Sep 2023 09:51:38 +0000 (UTC) X-FDA: 81238364676.25.EBE48D4 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf14.hostedemail.com (Postfix) with ESMTP id C016F10001C for ; Fri, 15 Sep 2023 09:51:35 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=KI2kOdoS; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694771496; a=rsa-sha256; cv=none; b=I3PLrwBAphtrpUpJ3gKhBnjhQ/nmuUtFDKb77Vj3/Nopq0Bk6yMrUeUo1Be449toYuHKnE CUgSrFgI+nsV6YByjptj+nGlPmTSBhyF+vB2DCB3ASGNJzFqVAK56ESnS2cHRCicp1y1en UPRYxrhr6dnf+OhFTXhfGdotKLjHGTo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=KI2kOdoS; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694771496; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nTKXGiIiML3QQW/w2E+mOtcZhHyvpI4/kPyFKr8+glQ=; b=5gbhF7AY8XY57W5BYAZJvAY6svD4uDmBgGOdzG4bH1hEWBH9OpY9WRAF9/dqiwC9f9qjPj oFzyHr7XKbOvHgEAM/CY2fqu2aLcX9nYstijzzHQh3PR3Arf9qU34m+5wIXoQUvbPc9Wq2 WLjVAYXn22QKXGwfeVk+dVEGt2pD6dM= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230915095134euoutp02221b129682b5bc9508ded83b09a03d38~FCbHPvI6J1204712047euoutp02X for ; Fri, 15 Sep 2023 09:51:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230915095134euoutp02221b129682b5bc9508ded83b09a03d38~FCbHPvI6J1204712047euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1694771494; bh=nTKXGiIiML3QQW/w2E+mOtcZhHyvpI4/kPyFKr8+glQ=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=KI2kOdoS2yg7Vh86md6sPK4vwrtx1rr8lkcPGelzTYN+V1wDwjhXbTPHfi1ayADmq SnuX6aSN1YRX5kU7TmhzwLcmfDlEAs/J/VhdqKM/lMU1vn2PXUcHsE0QM7qAuv739c MwIfQURAnIrUaVFqn6+icPbpvOOlVSZ/rhM39T1M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230915095133eucas1p1fc05405567bd735c07ff213d3dff3c85~FCbG_4jQF2007620076eucas1p1T; Fri, 15 Sep 2023 09:51:33 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 63.AA.42423.52924056; Fri, 15 Sep 2023 10:51:33 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230915095133eucas1p267bade2888b7fcd2e1ea8e13e21c495f~FCbGdpbh00862308623eucas1p2c; Fri, 15 Sep 2023 09:51:33 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230915095133eusmtrp2540609b9602d103cb0a1998aeeb2d1b1~FCbGc8gqX1712217122eusmtrp2_; Fri, 15 Sep 2023 09:51:33 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-26-65042925ea5e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5B.3B.10549.52924056; Fri, 15 Sep 2023 10:51:33 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230915095133eusmtip145b39d48e2d4c2b2f0f476f141a1971f~FCbGQl2U92594625946eusmtip1i; Fri, 15 Sep 2023 09:51:33 +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; Fri, 15 Sep 2023 10:51:32 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 15 Sep 2023 10:51:32 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [PATCH 6/6] shmem: add large folios support to the write path Thread-Topic: [PATCH 6/6] shmem: add large folios support to the write path Thread-Index: AQHZ57o0gOj42/h7V0WVSDdaHJaWqA== Date: Fri, 15 Sep 2023 09:51:31 +0000 Message-ID: <20230915095042.1320180-7-da.gomez@samsung.com> In-Reply-To: <20230915095042.1320180-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 x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKKsWRmVeSWpSXmKPExsWy7djP87qqmiypBpfmq1vMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6M/d1mBbuEKv5se8bWwHiar4uRg0NCwETia5tOFyMXh5DACkaJncsWMkM4Xxgl9t9b xgLhfGaUeNZ6mxWmY94rFYj4ckaJoy1b2eCKfmyeDeWcYZRY8vYn1KyVjBLbZr0EmsXJwSag KbHv5CZ2kISIwGxWicOLOxhBEswCdRJrns0CKmLnEBZwk1ijDxIVEfCWeLFzCRuErSfx/tAb sGoWAVWJz7t+soNcxCtgLbH+VjaIySlgI/H+RzlIBaOArMSjlb/YIWaLS9x6Mp8JxJYQEJRY NHsPM4QtJvFv10M2CFtH4uz1J4wQtoHE1qX7WC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4cUdjCAJZoE6iTXPZgEV sXMIC7hJrNEHiYoIeEu82LmEDcLWk3h/6A1YNYuAqsTnXT/ZQQ7lFbCWWH8rG8QUAjJnTfcC MTkFbCTe/ygHKWYUkJV4tPIXO8QacYlbT+YzQVwvILFkz3lmCFtU4uXjf1Bf6Uicvf6EEcI2 kNi6dB8LhK0k8adjIdS5ehI3pk5hg7C1JZYtfA02h1dAUOLkzCcsExilZyFZNwtJyywkLbOQ tCxgZFnFKJJaWpybnltsqFecmFtcmpeul5yfu4kRmJK2Hfu5eQfjvFcf9Q4xMnEwHmKU4GBW EuFls2VKFeJNSaysSi3Kjy8qzUktPsRoCgygicxSosn5wKSYVxJvaGZgamhiZmlgamlmrCTO 61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXAFGb97Euc/wHZOwe2H2d42C6wT9inRO7LFrv2jz5P F+jw6Pd+rmiR+vWiN6yJcdZj/UWebt99mZZpm3FUc8u9iHs94eG6jMblr2Q0rq9tOuBysvnq HqNDv/XmeUz9sMmm9fl6u4v7WCZt+nauo1l/yR1BpU1qlornQqTCTdjnZiWU1r2rlODnvbzW y/y5mNgqoQcvG6a8O3E48N3Ed//ZoxIdvsRvEP6t4OX9WH7C2uygo9XeTnlK3J69P5QXenPc YjKPy5Hg+z9xZ/CXbD2xu1ucfZzSnzWK+9ucKK07vLfk5Url5KaYKNUCptfdS40XvdXc07yx feHuG8fPJVYcFP399u7Tmcvfdkzx73g/VYmlOCPRUIu5qDgRACdVhs7SAwAA X-CMS-MailID: 20230915095133eucas1p267bade2888b7fcd2e1ea8e13e21c495f X-Msg-Generator: CA X-RootMTR: 20230915095133eucas1p267bade2888b7fcd2e1ea8e13e21c495f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230915095133eucas1p267bade2888b7fcd2e1ea8e13e21c495f References: <20230915095042.1320180-1-da.gomez@samsung.com> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C016F10001C X-Stat-Signature: 4ahf6wt3yzu4r6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UbF6dQWfMGptKZyJEoeJMDNaJCu0QUHA2H6RVBoewITlCMSCq/VNIAOgzicPhO3/OQ5R4ENnRpKj1cXr+bVmu+MEm8v/MtbpcqAr1Ze30OSFzUoU95+eP1gm7NgGkz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add large folio support for shmem write path matching the same high order preference mechanism used for iomap buffered IO path as used in __filemap_get_folio(). Use the __folio_get_max_order to get a hint for the order of the folio based on file size which takes care of the mapping requirements. Swap does not support high order folios for now, so make it order 0 in case swap is enabled. Signed-off-by: Daniel Gomez --- mm/shmem.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index adff74751065..26ca555b1669 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1683,13 +1683,19 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, } static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, - pgoff_t index, bool huge, unsigned int *order) + pgoff_t index, bool huge, unsigned int *order, + struct shmem_sb_info *sbinfo) { struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; int nr; int err; + if (!sbinfo->noswap) + *order = 0; + else + *order = (*order == 1) ? 0 : *order; + if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) huge = false; nr = huge ? HPAGE_PMD_NR : 1U << *order; @@ -2032,6 +2038,8 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return 0; } + order = mapping_size_order(inode->i_mapping, index, len); + if (!shmem_is_huge(inode, index, false, vma ? vma->vm_mm : NULL, vma ? vma->vm_flags : 0)) goto alloc_nohuge; @@ -2039,11 +2047,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, huge_gfp = vma_thp_gfp_mask(vma); huge_gfp = limit_gfp_mask(huge_gfp, gfp); folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, true, - &order); + &order, sbinfo); if (IS_ERR(folio)) { alloc_nohuge: folio = shmem_alloc_and_acct_folio(gfp, inode, index, false, - &order); + &order, sbinfo); } if (IS_ERR(folio)) { int retry = 5; @@ -2147,6 +2155,8 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, if (folio_test_large(folio)) { folio_unlock(folio); folio_put(folio); + if (order > 0) + order--; goto alloc_nohuge; } unlock: