From patchwork Tue Sep 19 13:55:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391502 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8858BCD5BBD for ; Tue, 19 Sep 2023 13:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbjISN4B (ORCPT ); Tue, 19 Sep 2023 09:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232480AbjISNzz (ORCPT ); Tue, 19 Sep 2023 09:55:55 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20068F5 for ; Tue, 19 Sep 2023 06:55:49 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135547euoutp02b1ce1c6562dc928303eab79db71c70be~GUVf2eveH1710817108euoutp02- for ; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135547euoutp02b1ce1c6562dc928303eab79db71c70be~GUVf2eveH1710817108euoutp02- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131748; bh=FJQ8bvj/9Vs0utzuzFMcJ8GvK3wVEgVmfOOT/zQHcR0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=l9ajOekSgv9RJzUXI0V8msKFF5QnkT/CJnUhsjgVD4NdUPFXlfLckYb/3xjPj1PMZ qDkcM4L8ZFiYKUzR1tsXO5xr2fKk9prRBIhzl2ifkSItG4oZc34Lv7GRHghtd+6W+W 3C31ybcUB+q8s1eGeGnseu+HDZ7Gakffjb4/dqH4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135547eucas1p2511a5d8752168f2baa949be8ea4c10a6~GUVfeg3WY1636016360eucas1p2j; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3F.7E.11320.368A9056; Tue, 19 Sep 2023 14:55:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1~GUVfBq4u22317523175eucas1p27; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135547eusmtrp11e24cd154302622eacc81ec4f96cfcad~GUVe-9IqC2584925849eusmtrp1G; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-b6-6509a863472c Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A5.C9.10549.268A9056; Tue, 19 Sep 2023 14:55:46 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135546eusmtip1c60ef7b891afff594b8a2c51fcc57d87~GUVewBDRA1313713137eusmtip18; Tue, 19 Sep 2023 13:55:46 +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; Tue, 19 Sep 2023 14:55:46 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:46 +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 v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Topic: [PATCH v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Thread-Index: AQHZ6wD8QPBGKC1ahkW+sk1T2Ar7wQ== Date: Tue, 19 Sep 2023 13:55:45 +0000 Message-ID: <20230919135536.2165715-2-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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+NgFjrFKsWRmVeSWpSXmKPExsWy7djPc7rJKzhTDY73y1rMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MrZM2MBe8ZK2YvrmRpYHxOUsXIyeHhICJxJW+r2xdjFwcQgIrGCWOrDnMCuF8YZS4 tXQlI4TzmVFic+Nx5i5GDrCWiW+YIOLLGSV6jjcwgowCK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cgEcUXo2RfmlJakK GfnFJbZK0YYWRnqGlhZ6RiaWeobG5rFWRqZK+nY2Kak5mWWpRfp2CXoZWydtYC54yVoxfXMj SwPjc5YuRg4OCQETiYlvmLoYuTiEBJYySqzZ9outi5ETKC4jsfHLVVYIW1jiz7UuNoiij4wS O7Y8ZYFwzjBKzFvxgh3CWcko0fXjORNIC5uApsS+k5vAEiICs1klDi/uYARJMAvUSax5NosF xBYWsJT4vPktmC0iYCfx5s4aRghbT2LP/vtgNouAqsTxM5/AhvIKWEs83PIArF4IyH61cDXY fZwCNhI35jaB3c0oICvxaOUvdohd4hK3nsxngvhBQGLJnvPMELaoxMvH/6B+05E4e/0JI4Rt ILF16T4WCFtJ4k/HQqib9SRuTJ3CBmFrSyxb+JoZ4h5BiZMzn7BMYJSehWTdLCQts5C0zELS soCRZRWjSGppcW56brGhXnFibnFpXrpecn7uJkZggtp27OfmHYzzXn3UO8TIxMF4iFGCg1lJ hHemIVuqEG9KYmVValF+fFFpTmrxIUZTYBhNZJYSTc4Hpsi8knhDMwNTQxMzSwNTSzNjJXFe z4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamkNvNi/evPzFhr84ORrf1G8RahI1/PjyRul/T8cqi z+uuitZX8sQHtOwKr0q7lPyhQL2BPbcx/luZo8LJYiUpn42TubfySTXnFgn2fzh3Po/b787E mthXT3j2Cnc83vZo8VSv1hPl77jYJ/Hnv4prmbR26RyN+Ip67hC+8JfnSv9k+JRP6D5x2GGD p+jmn8/Tkj7N1VCeW2urzGo2oe1G54rlFXed2+a2CvnLKlpW31Xjv+Zs+t3dv+Wl/M6wNSur njnOzw1fPu8bi9TXZLv/SbLHPxe9fxPuL8mz7pNUlkZCqFR5krL2/6uuKwxSNdLmnojPNz+s n80imsDqYvtcTVWw6t7Owi2NJ++sUlBiKc5INNRiLipOBACISM272QMAAA== X-CMS-MailID: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 X-Msg-Generator: CA X-RootMTR: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135547eucas1p2777d9fde904adf4c2d0ac665d78880c1 References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 be050efe18cb..de0d0fa0349e 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 Tue Sep 19 13:55:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391503 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16A70CD5BC7 for ; Tue, 19 Sep 2023 13:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbjISN4H (ORCPT ); Tue, 19 Sep 2023 09:56:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjISN4A (ORCPT ); Tue, 19 Sep 2023 09:56:00 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1289AF2 for ; Tue, 19 Sep 2023 06:55:51 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135549euoutp0209060369360dd1ac4ed64923f8c1a845~GUVhq2s-b1585015850euoutp02W for ; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135549euoutp0209060369360dd1ac4ed64923f8c1a845~GUVhq2s-b1585015850euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131749; bh=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=S/I8tzNocRjVASDHLDVbZG1o0m5ySXDg7TpgNah3igHxxkIwUNZaIoedmh5F0HTBW dQo39hU3zNUXeSOhpV4FI2QiTwztjIioq1rd7Fsu8ItAWEjIVj4OLU9qcBike/4XPs KUXaM379aAsK8wBVtRcwGb7tZ3MbF+HOcWNmVaPI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eucas1p214bb8ae09e148c563a02f19655c58a3a~GUVhZ4Z1R1835818358eucas1p2Q; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C6.D1.42423.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf~GUVg-ov7A0405704057eucas1p1k; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eusmtrp2a092f04f72f32deca907d314cdbdbe2a~GUVg_3kxB2320823208eusmtrp2r; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-68-6509a8655322 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 00.55.14344.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135548eusmtip10e8f5eaa57c7ececc0fd70ba9f61c00f~GUVgvl2li1382813828eusmtip1a; Tue, 19 Sep 2023 13:55:48 +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; Tue, 19 Sep 2023 14:55:48 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:48 +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 v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Topic: [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Index: AQHZ6wD9pblMkq2/yUu1kd4yGg7G6w== Date: Tue, 19 Sep 2023 13:55:47 +0000 Message-ID: <20230919135536.2165715-3-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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: H4sIAAAAAAAAA02Sf0yMcRzH973nueeeO07PXakvkjk/NsXphD1NrE3y+JU2P4fFqa/OXCd3 Hfm5hriaYSrc0+knSYXdlTqnQkwlJ2lomSy7s2Q0ISoV3XNZ/70+e38+n/f7s31ITFrHn0ju 1iQgrUaplhEivPxJ7/M5qFCIAiseTKVNt0sIuvjdOYJudoyjnd1ncbqqNYCurKrH6WabiaDb Sob4tO2PVUC3nHcCuuBnl4C+Z84j6P7fJiJUzGQmNeFMjkXPlBb6M812PWMpSiEYS/cFAVN3 uR9nvlv8IsktopAYpN69H2nnLtkhUhWYF8Z3eSQabj3Bk8DjsalASEJqPmz4XANSgYiUUoUA /mIbsWFBSv0AsONUECd8B/DNp1fYyESuPYPgmq4D2Nc05X9Tzi0TxhXPALx420xwxQ0A29p7 XOMENQtW11sEw4IXlcmHj/INYFjAqGOw5COLD7MnFQYNvXaXhxe1AjqbTgOO5fD+O6uLcWoG NL/Kdy0VU4vgi4osFwupENhy5bhrFlCT4YcbfQJuvw9sdWTzuBskMC+z0n2PNxy0tRMcz4b2 Nw7AcSC8c60a51gG/xhy3TnlsCUjneA4ABbkfnZnkMB6o8Pd3yeEaUOLOA6DyaZzbi9P2Flb JuDYFw7dzeadBwHsqHjsKAt2lAU7yiIH4EXAB+l1cbFIp9CgA3KdMk6n18TKo/fGWcC/Z2sY rO22giud3+Q1gEeCGgBJTOYlNioIJBXHKA8eQtq927V6NdLVgEkkLvMRByyuj5ZSscoEtAeh eKQdUXmkcGIST3FyRfnhhKXq0Bco0cROUonqqjaaaxudL7MsANsqKmXa0aYWMt1DctU//URM RGuw3VtT/nZwjON1ePLKpOL37Ma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YmZpYGppZmxkjivZ0FHopBA emJJanZqakFqEUwfEwenVANTff6bezpsIlK1Bit5+ZkjHVpFf25Qnso4wWcXn+DcHfeeBWyf KXo1/M/Vq47HbfZqtVqGiVl9994+6VTqvj/hJh+Pzdh2zuaQrKlArATX0ld750upf3kTkpB2 WPX++bgJz8wK/vYVJ9WLak8/tsHjieDTHatTV2vnGP5fau71YHZK0OkVWR1Xr1+XsI++adX0 lXdHQPWBxR+/GK0OUpfRaz9r77hZ4VpGU1RgrdmjL6EcS9MPHH4mfuj9o5hmhZtPA7fu9W/w /vOtVff2/b0X3rh94TL9YGtbuXjfvX8NG+SNa/6F6v9/2dwiv8A5fXbVnpcHvv+fXcFeVH+o QHBRflZMl3bQ7HVaBfr+KyxMlFiKMxINtZiLihMBgbk09dkDAAA= X-CMS-MailID: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf X-Msg-Generator: CA X-RootMTR: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Both shmem_free_swap callers require to get the number of pages in the folio after calling shmem_free_swap. Make shmem_free_swap return the expected value directly and return 0 number of pages being freed to avoid error handling in the external accounting. Suggested-by: Matthew Wilcox Signed-off-by: Daniel Gomez --- mm/shmem.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index de0d0fa0349e..5c9e80207cbf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -846,16 +846,18 @@ static void shmem_delete_from_page_cache(struct folio *folio, void *radswap) /* * Remove swap entry from page cache, free the swap and its page cache. */ -static int shmem_free_swap(struct address_space *mapping, +static long shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap) { void *old; old = xa_cmpxchg_irq(&mapping->i_pages, index, radswap, NULL, 0); if (old != radswap) - return -ENOENT; + return 0; + free_swap_and_cache(radix_to_swp_entry(radswap)); - return 0; + + return folio_nr_pages((struct folio *)radswap); } /* @@ -1008,7 +1010,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - nr_swaps_freed += !shmem_free_swap(mapping, + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); continue; } @@ -1077,12 +1079,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - if (shmem_free_swap(mapping, indices[i], folio)) { + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); + if (!nr_swaps_freed) { /* Swap was replaced by page: retry */ index = indices[i]; break; } - nr_swaps_freed++; continue; } From patchwork Tue Sep 19 13:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391504 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A9CBCD5BC2 for ; Tue, 19 Sep 2023 13:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232598AbjISN4R (ORCPT ); Tue, 19 Sep 2023 09:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232442AbjISN4P (ORCPT ); Tue, 19 Sep 2023 09:56:15 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 293B4125 for ; Tue, 19 Sep 2023 06:55:52 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135551euoutp0229a864d7a46d206f6125efb8b9203870~GUVjcGlFZ1535515355euoutp02Z for ; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135551euoutp0229a864d7a46d206f6125efb8b9203870~GUVjcGlFZ1535515355euoutp02Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131751; bh=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tyM4uvQdUR1AS3aYkBsxN32j/P4q2FARUnPi8UjEsUaK/RInj4GTTsgiqt3Abi0EZ xPp6E2q79rArO2yh4Pg1Npb2OgCS+RY3naCuqZ/ExDsJ2hMNQOmyGDyPb3/9yCnggt 2eHzkHBjYlJcVe2tWGleBwTU4JIrtv0QzsVvrREg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230919135551eucas1p1c2f79426cc02c6873649747c6b5ebe77~GUVjFDdBx1658916589eucas1p1F; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 23.8E.11320.768A9056; Tue, 19 Sep 2023 14:55:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db~GUVilHeug1635116351eucas1p2u; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135550eusmtrp2e393e76eb8216b24e9888cc400ce0942~GUVikiwv92324623246eusmtrp2F; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-c7-6509a8674f70 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 32.55.14344.668A9056; Tue, 19 Sep 2023 14:55:50 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eusmtip17b6283cd8a9ef8f53119b7dcf49ffc0f~GUViY2AR61888818888eusmtip1z; Tue, 19 Sep 2023 13:55:50 +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; Tue, 19 Sep 2023 14:55:50 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:50 +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 v2 3/6] shmem: account for large order folios Thread-Topic: [PATCH v2 3/6] shmem: account for large order folios Thread-Index: AQHZ6wD+Wqd1jPdfPEKUQlAv9fdGJA== Date: Tue, 19 Sep 2023 13:55:49 +0000 Message-ID: <20230919135536.2165715-4-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7rpKzhTDb42SVrMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MaTNfsRS8kai4uvAaUwPjPpEuRk4OCQETibMrJzJ2MXJxCAmsYJTYP7mNGcL5wihx fdYtNgjnM6PEkY3/WboYOcBaur+mQMSXM0p0nfvGCjIKrOjUFKjuM4wSc7vXMkE4KxklmrvW MIJUsQloSuw7uYkdJCEiMJtV4vDiDrAEs0CdxJpns1hAbGEBW4n3C7+yg9giAk4Sj+dvYoGw 9SS2zb7DBHIGi4CqxOdTbiBhXgFriVc79zKD2JwCNhI35jaxgdiMArISj1b+YocYLy5x68l8 JoinBSUWzd7DDGGLSfzb9ZANwtaROHv9CSOEbSCxdek+FghbSeJPx0KoM/UkbkydwgZha0ss W/iaGeIGQYmTM5+wgPwlIdDEJfGqYynUUBeJXUtnskPYwhKvjm+BsmUk/u+czzSBUXsWkvtm IdkxC8mOWUh2LGBkWcUonlpanJueWmyUl1quV5yYW1yal66XnJ+7iRGY2k7/O/5lB+PyVx/1 DjEycTAeYpTgYFYS4Z1pyJYqxJuSWFmVWpQfX1Sak1p8iFGag0VJnFfb9mSykEB6Yklqdmpq QWoRTJaJg1OqgalxedqRkwZRry9ZTG7oi6xyXHZ9kmH4MjbO3+5H1zQvPvbUVM1F56/DiYag 8M8rhcoKTbTb1y6qU5JnP73b3vvtvoU+yZ/bbjfe7T3xa6/vuont1x9bCgmemrT96UfuBaY3 2m58OayV2BGRcurS33bNoJ+h2xgEWBZXWS+9Yr2o58S0tie373e/VeqsO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ybW+kpuybSYvX79bfZg51+ma YurLWUFnTh1ek3HpLQOLkHjzr7DurS/YQnNWmqye9EPiRvwBrqV6V9b/bj/y2sZ5Bc82zY2p z1lvLBR4u+BrxvMnrA1Xmh46vFSeyvtqrf2NwDrdj+qHzRbdLedcuyVTvJDlt3KleeHRw2r/ 7P5lGS774MfGtjo8XbQshue7561TZ1ZxZKUc9pqWxT7Td8Epg2d8pyZrROQHW6d//CQjeG71 V+Yzt88wpfxYGPusTSU1/KAst5ldK19A1Mygz7mf5XO9CpW4Zj4QPH/F49XJZqG4u/ZXj8he uXbrg+n9Z4xrLzXkuS7f68zpd6lVIn65EktxRqKhFnNRcSIAM2aVQtcDAAA= X-CMS-MailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-Msg-Generator: CA X-RootMTR: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5c9e80207cbf..d41ee5983fd4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -871,16 +871,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()) { @@ -1530,7 +1530,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)); @@ -1803,6 +1803,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, @@ -1812,13 +1813,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); } @@ -1905,7 +1907,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); @@ -2665,7 +2667,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 Tue Sep 19 13:55:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391507 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E05CD5BC5 for ; Tue, 19 Sep 2023 13:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232616AbjISN4j (ORCPT ); Tue, 19 Sep 2023 09:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbjISN4Q (ORCPT ); Tue, 19 Sep 2023 09:56:16 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3009EC for ; Tue, 19 Sep 2023 06:55:54 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135553euoutp022fd9e551c1928e3ae83ae9ba62e7e475~GUVk1ifgF1535515355euoutp02c for ; Tue, 19 Sep 2023 13:55:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135553euoutp022fd9e551c1928e3ae83ae9ba62e7e475~GUVk1ifgF1535515355euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131753; bh=j5/WuYRozdtOAgqCuDPHuq7YO9f8GU76Eza03ZT/hH0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Nuk+vBjmOh37sbt6+cadKZVS5pDdzpixYn6VfaHIUcxAPCiEoA5HyMHU16U4AXzlS uAY13cUs5iF3t9vzP0Wwptp6v7rcHcS1QS4p2z9CuSenJGbi8FP5xvy52tPDOa5C+A HquMNJPl6Mp5dXIMgriwdNYppSWors5aDVdkPq2A= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135552eucas1p24dc412b1eadbba23c9d14f70df03b1ac~GUVkXHo8C1636016360eucas1p2s; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C5.8E.11320.868A9056; Tue, 19 Sep 2023 14:55:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9~GUVj9gkvl1092210922eucas1p1Q; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135552eusmtrp1594d9a0d3fd5111d702d62a93bc6f02d~GUVj8zkSl2614026140eusmtrp1G; Tue, 19 Sep 2023 13:55:52 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-ca-6509a868e751 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9C.C9.10549.868A9056; Tue, 19 Sep 2023 14:55:52 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135552eusmtip105fc41d27402e30d4f75b71c970cf4f9~GUVjooqQg1607416074eusmtip1K; Tue, 19 Sep 2023 13:55:52 +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; Tue, 19 Sep 2023 14:55:51 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:51 +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 v2 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Topic: [PATCH v2 4/6] shmem: add order parameter support to shmem_alloc_folio Thread-Index: AQHZ6wD/X9RVQ39BEEGXAtoeSmDJSA== Date: Tue, 19 Sep 2023 13:55:50 +0000 Message-ID: <20230919135536.2165715-5-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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+NgFjrOKsWRmVeSWpSXmKPExsWy7djPc7oZKzhTDSZu1rWYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZW/ecYyrolamYv6GJqYHxgVgXIweHhICJxJ8LHl2MXBxCAisYJe6tuMMM4XxhlPh1 YDUThPOZUWLD3ZVADidYx/w5KxkhEssZJb6tWc8MkgCrevA0HCJxhlFi4qyl7BCJlYwSS1dy g9hsApoS+05uYgcpEhGYzSpxeHEHI0iCWaBOY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RX0ylTM39DE 1MD4QKyLkZNDQsBEYv6clYxdjFwcQgJLGSXerDzHBpGQkdj45SorhC0s8edaFxtE0UdGicOr 25ghnDOMEh9fPWSCcFYySjxfcQCshU1AU2LfyU3sIAkRgdmsEocXdzCCJJgF6iTWPJvFAmIL CwRKXGxaAbZPRCBM4svthUA2B5CtJ7GlNwIkzCKgKtG46SpYOa+AtcShwy/AbCEg+9XC1WC7 OAVsJG7MbQIbwyggK/Fo5S92iFXiEreezGeCeEFAYsme88wQtqjEy8f/oF7TkTh7/QkjhG0g sXXpPhYIW0niT8dCqJP1JG5MncIGYWtLLFv4mhniHkGJkzOfsExglJ6FZN0sJC2zkLTMQtKy gJFlFaNIamlxbnpusaFecWJucWleul5yfu4mRmCC2nbs5+YdjPNefdQ7xMjEwXiIUYKDWUmE d6YhW6oQb0piZVVqUX58UWlOavEhRlNgGE1klhJNzgemyLySeEMzA1NDEzNLA1NLM2MlcV7P go5EIYH0xJLU7NTUgtQimD4mDk6pBiYFLuOZt28WrO5KuKGw/6/E0/2FPu8/fnG65j+v43WC as2EAyEhqoLV4cdK7upo1S27tYWV71PQ/Uv/vL88n/df7udXwe+FH98ptN1Mqk67694b/utD v1NQxtPi/+ZiTzW7BN0n9e4S1srJ+J/fdHra3o5faqFXXPWuhBq8DjzkGjz/hTlP66ND7LNr 849s5VD1uvlI2UlaqtDLjW95guW039IqP08cUJniq6I2Q3qZ4ifF2ztfiRmeq2G8Wa9ncevQ io539UsecJz/cXGacN7nFwe+l5620vh6pMmw1pn19J2tS/OTP5dXTo9vv/Pj2zHL/jfztEKC pTOr/XjCIhRMHzHeWNQ2+cEUSY7oXY+UWIozEg21mIuKEwFsJZsF2QMAAA== X-CMS-MailID: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 X-Msg-Generator: CA X-RootMTR: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135552eucas1p11e19cd339078c2e0b788b52fae46e7c9 References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 d41ee5983fd4..66d94207b40c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1667,20 +1667,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; @@ -1689,7 +1690,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) @@ -1698,7 +1699,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); @@ -1748,7 +1749,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; @@ -1959,6 +1960,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; @@ -2034,10 +2036,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; @@ -2600,7 +2604,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 Tue Sep 19 13:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391505 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1692CD5BC6 for ; Tue, 19 Sep 2023 13:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232661AbjISN4e (ORCPT ); Tue, 19 Sep 2023 09:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbjISN4R (ORCPT ); Tue, 19 Sep 2023 09:56:17 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C85192 for ; Tue, 19 Sep 2023 06:55:56 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135554euoutp017c6d7fe8eff806890d47a866ce330c75~GUVmUOJd40199901999euoutp013 for ; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135554euoutp017c6d7fe8eff806890d47a866ce330c75~GUVmUOJd40199901999euoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131754; bh=qf0ZYfltBJHFQkocAMfpwOGkTFM18/mnXm/sqbTG1Hc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=RdyrgSlxDQnZ8OoTspAB8yPA4ahyu5un4f+0ntoCmwiJDcdh42jompH23sIq8BVqW ed8f1O+Q8HVOUfEHREfoorxQqo4i608JK7GT+n2oHWziyh0TcWPrXrc2pUNg0wsJie 1zSJwpiEYbsFnS+ZEdeLgKqZPJ2kcKgs6RKMQ9GQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135554eucas1p2c289f7b4360774a8577116bad4b22a34~GUVmEZqWP1832118321eucas1p2Q; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 44.72.37758.A68A9056; Tue, 19 Sep 2023 14:55:54 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c~GUVli9uA70405804058eucas1p13; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230919135554eusmtrp145105151189bdca9c761ae4116051b63~GUVliU81s2584925849eusmtrp1S; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-ca-6509a86ab4f5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id EE.C9.10549.968A9056; Tue, 19 Sep 2023 14:55:54 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135553eusmtip1da98dd855cbc6c425b4b7b0a0fa939af~GUVlXP9Nk1382813828eusmtip1f; Tue, 19 Sep 2023 13:55:53 +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; Tue, 19 Sep 2023 14:55:53 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:53 +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 v2 5/6] shmem: add file length in shmem_get_folio path Thread-Topic: [PATCH v2 5/6] shmem: add file length in shmem_get_folio path Thread-Index: AQHZ6wEANquhpkBXk0KILtjKWHTHrQ== Date: Tue, 19 Sep 2023 13:55:52 +0000 Message-ID: <20230919135536.2165715-6-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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+NgFjrBKsWRmVeSWpSXmKPExsWy7djP87pZKzhTDV4vVbaYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZ7TdnsRdc1a14tUGjgXGHShcjJ4eEgIlEz4Yr7F2MXBxCAisYJWbPPcUC4XxhlPjy 4BszhPOZUaK36QYbTMvG1QsYIRLLGSU+vF/FBlf16WU/O0iVkMAZRolT7dEQiZWMEjOO9DOD JNgENCX2ndwEtlFEYDarxOHFHYwgCWaBOok1z2YBbefgEBZwk5h2phwkLCLgLdH85yIzSFhE QE+i/aYJSJhFQFXi28xbLCA2r4C1xIp3E8GmcArYSNyY2wR2KaOArMSjlb/YIaaLS9x6Mp8J 4gNBiUWz9zBD2GIS/3Y9hPpMR+Ls9SeMELaBxNal+1ggbCWJPx0Loa7Uk7gxdQobhK0tsWzh a2aIGwQlTs58Ag47CYE2LolXtw9BNbtIrLr4kB3CFpZ4dXwLlC0jcXpyD8sERu1ZSO6bhWTH LCQ7ZiHZsYCRZRWjeGpp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92iE3iEreezIf6RkBiyZ7zzBC2qMTLx/+gPtOROHv9CSOE bSCxdek+FghbSeJPx0Koi/UkbkydwgZha0ssW/iaGeIeQYmTM5+wTGCUnoVk3SwkLbOQtMxC 0rKAkWUVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYHLaduzn5h2M81591DvEyMTBeIhRgoNZ SYR3piFbqhBvSmJlVWpRfnxRaU5q8SFGU2AYTWSWEk3OB6bHvJJ4QzMDU0MTM0sDU0szYyVx Xs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGpobjl9OXWAUyCq+pPcfb+bPlqcDuP+pPdd4c6hHq vj7txvJz795/tfncVTDtaKPU3Ne5Mxafme5pHeFT3/Bma/thc8fG8kP3by94GFlyYrnjj5cn xT7zRm64Jmfb/2H3FzujrheM604EdUs4H4+z+ffA9HgSb9z6qwv+/tv9TPvqkysTF/VfnaLQ rXnqn/rdmTVP2Z0j0g/t4+U0K13/udbY/fW8R/fWPdyyx0nbJlO+/TZblpr/jJSbQkmBKzdF MEcyx+au//hoX+tdrZk6vu8YHwh982NOleJ78qEyoz/LvSNFXspDZ3FCVO3PwqUxCcfXex5M T15oWOJy9JXOa18fmT2M5dJqW2TiHvd/+qHEUpyRaKjFXFScCAB3yF0I1wMAAA== X-CMS-MailID: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c X-Msg-Generator: CA X-RootMTR: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135554eucas1p1fefbe420a2381465f3b6b2b7f298433c References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 and PAGE_SIZE for pagecache read and vm fault. Signed-off-by: Daniel Gomez --- include/linux/shmem_fs.h | 2 +- mm/khugepaged.c | 2 +- mm/shmem.c | 32 ++++++++++++++++++-------------- 3 files changed, 20 insertions(+), 16 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 66d94207b40c..38aafa0b0845 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -971,7 +971,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; } @@ -1948,7 +1948,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); @@ -2162,10 +2162,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); } /* @@ -2248,8 +2249,8 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf) spin_unlock(&inode->i_lock); } - err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, - gfp, vma, vmf, &ret); + err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, gfp, + vma, vmf, &ret, PAGE_SIZE); if (err) return vmf_error(err); if (folio) @@ -2700,6 +2701,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))) { @@ -2709,7 +2713,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; @@ -2781,7 +2785,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; @@ -2958,7 +2962,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; @@ -3145,7 +3149,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 */ @@ -3500,7 +3504,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; @@ -3548,7 +3552,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) @@ -4916,8 +4920,8 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, int error; BUG_ON(!shmem_mapping(mapping)); - error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, - gfp, NULL, NULL, NULL); + error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, gfp, NULL, + NULL, NULL, PAGE_SIZE); if (error) return ERR_PTR(error); From patchwork Tue Sep 19 13:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13391506 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5D78CD5BC2 for ; Tue, 19 Sep 2023 13:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232676AbjISN4f (ORCPT ); Tue, 19 Sep 2023 09:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232619AbjISN4b (ORCPT ); Tue, 19 Sep 2023 09:56:31 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E02B1A4 for ; Tue, 19 Sep 2023 06:55:58 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135557euoutp0249d1a970e7b0a7044a99b5eb87dc535d~GUVoY4HJ91535515355euoutp02f for ; Tue, 19 Sep 2023 13:55:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135557euoutp0249d1a970e7b0a7044a99b5eb87dc535d~GUVoY4HJ91535515355euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131757; bh=JKaS2+/EEMvNdZiV+zve2PZ9hmK4b8LE7tpeT3AMyFo=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=nuctfpPHnSMC7WQhH3HQtlmt0BgRwRmZt8mRpYkEnpagsqTg5Xc3QzV+nXnDwFb6D lxURGbKYETqe7oCM8Mgw+BtSPsANdW2I0sC1Kk9USuK7719XgBh986WUD/UyXmzVnP 2kwtvOkEHXQIb3zoZiL0vNOSS/gXZ178cpLtEY6M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135556eucas1p25528f9f56de359f45b1e7b88035e664a~GUVn702Uc1835018350eucas1p2T; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FE.D1.42423.C68A9056; Tue, 19 Sep 2023 14:55:56 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117~GUVnbnZpF0405804058eucas1p16; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135556eusmtrp27b41cacf6044fd9f4708968fe6ddd715~GUVna-NnB2324623246eusmtrp2O; Tue, 19 Sep 2023 13:55:56 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-8a-6509a86cdb59 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 38.55.14344.B68A9056; Tue, 19 Sep 2023 14:55:55 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135555eusmtip1dc621754b1f2f7018cbadae30e65482e~GUVnMaPw61888818888eusmtip14; Tue, 19 Sep 2023 13:55:55 +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; Tue, 19 Sep 2023 14:55:55 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:55 +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 v2 6/6] shmem: add large folios support to the write path Thread-Topic: [PATCH v2 6/6] shmem: add large folios support to the write path Thread-Index: AQHZ6wEBFE+DTgi9xUu5khR159FX3A== Date: Tue, 19 Sep 2023 13:55:54 +0000 Message-ID: <20230919135536.2165715-7-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-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+NgFjrNKsWRmVeSWpSXmKPExsWy7djP87o5KzhTDfZtVLSYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZk1c8Yyx4pVxx5/YElgbG2zJdjJwcEgImEk8ebmACsYUEVjBKtNzJ6GLkArK/MEr8 vbWdHcL5zChx5t17dpiOgye+MUEkljNKzLv4nAWuauGkL8wQzhlGic4X06GclYwS1xf9Aetn E9CU2HdyE9hgEYHZrBKHF3cwgiSYBeok1jybxQJiCwt4Sqw/ehWsQUQgQKKt/woThK0n8XfZ STCbRUBV4t2/hWC9vALWEj8nHgKLcwrYSNyY28QGYjMKyEo8WvmLHWK+uMStJ/OZIJ4QlFg0 ew8zhC0m8W/XQzYIW0fi7PUnjBC2gcTWpftYIGwliT8dC6Hu1JO4MXUKG4StLbFs4WtmiBsE JU7OfAIOCwmBf5wS02auhxrkItE79yHUMmGJV8e3QENSRuL/zvlMExi1ZyG5bxaSHbOQ7JiF ZMcCRpZVjOKppcW56anFhnmp5XrFibnFpXnpesn5uZsYgent9L/jn3Ywzn31Ue8QIxMH4yFG CQ5mJRHemYZsqUK8KYmVValF+fFFpTmpxYcYpTlYlMR5tW1PJgsJpCeWpGanphakFsFkmTg4 pRqYRBJnbv1x2ka78IHfHt81nFbfLUzndT1+Z6woZfPpbRLDtLuPOrPuZLEaKd3a1xn7YNqd L9ErLp0Us3GYUbVT7tk1b9Wv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gk80riDc0MTA1NzCwNTC3NjJXEeT0L OhKFBNITS1KzU1MLUotg+pg4OKUamKY0sD3SbStZePl74E6P/u7P+56FFDDFCxd47pzP/ShM Z+nfY7pee44yWPTXM79S5dqiW/k/zsxoj45P6Nvlro1b6+R/bJghk/RNzEM29q31l5kc+X+U XZMn/mv72vVL6b2ziQKfqd9uXdHnexZ0GVcc36+56+l8lZ6D+ikM+5WDlPgWWL1alVV+mCPe 5YLJqw33uqyLNBS0vqxZ2aR0sJWz9f0XPU/H/fJCU/UXRPjWtVWF7Vi19c0nRg/9T6kZF38H G97/emt20tnNG+rNZt50C9rokSYts90pS0/c/k1mUL/OYbOVF7TnKPZt1fyVZj9vysTvWzIf XtxfUfbmaKl8c/Dygk2Gm/WyowyvKLEUZyQaajEXFScCAEql5LjaAwAA X-CMS-MailID: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 X-Msg-Generator: CA X-RootMTR: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135556eucas1p19920c52d4af0809499eac6bbf4466117 References: <20230919135536.2165715-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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() with a difference on the max order permitted (being PMD_ORDER-1) to respect the huge mount option when large folio is supported. 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 | 66 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 38aafa0b0845..96c74c96c0d9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -95,6 +95,9 @@ static struct vfsmount *shm_mnt; /* Symlink up to this size is kmalloc'ed instead of using a swappable page */ #define SHORT_SYMLINK_LEN 128 +/* Like MAX_PAGECACHE_ORDER but respecting huge option */ +#define MAX_SHMEM_ORDER HPAGE_PMD_ORDER - 1 + /* * shmem_fallocate communicates with shmem_fault or shmem_writepage via * inode->i_private (with i_rwsem making sure that it has only one user at @@ -1680,26 +1683,58 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, return folio; } +/** + * shmem_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. + * + * Like __filemap_get_folio order calculation. + * + * Return: The order. + */ +static inline unsigned int +shmem_mapping_size_order(struct address_space *mapping, pgoff_t index, + size_t size, struct shmem_sb_info *sbinfo) +{ + unsigned int order = ilog2(size); + + if ((order <= PAGE_SHIFT) || + (!mapping_large_folio_support(mapping) || !sbinfo->noswap)) + 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_SHMEM_ORDER); + + /* Order-1 not supported due to THP dependency */ + return (order == 1) ? 0 : order; +} + 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, unsigned int order) { struct shmem_inode_info *info = SHMEM_I(inode); struct folio *folio; - int nr; - int err; - - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) - huge = false; - nr = huge ? HPAGE_PMD_NR : 1U << *order; + int nr = 1U << order; + int err = shmem_inode_acct_block(inode, nr); - err = shmem_inode_acct_block(inode, nr); if (err) goto failed; - if (huge) + if (order == HPAGE_PMD_ORDER) folio = shmem_alloc_hugefolio(gfp, info, index); else - folio = shmem_alloc_folio(gfp, info, index, *order); + folio = shmem_alloc_folio(gfp, info, index, order); if (folio) { __folio_set_locked(folio); __folio_set_swapbacked(folio); @@ -2030,18 +2065,19 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return 0; } + order = shmem_mapping_size_order(inode->i_mapping, index, len, sbinfo); + if (!shmem_is_huge(inode, index, false, vma ? vma->vm_mm : NULL, vma ? vma->vm_flags : 0)) goto alloc_nohuge; 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); + folio = shmem_alloc_and_acct_folio(huge_gfp, inode, index, + HPAGE_PMD_ORDER); if (IS_ERR(folio)) { alloc_nohuge: - folio = shmem_alloc_and_acct_folio(gfp, inode, index, false, - &order); + folio = shmem_alloc_and_acct_folio(gfp, inode, index, order); } if (IS_ERR(folio)) { int retry = 5; @@ -2145,6 +2181,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 == 1) + order = 0; goto alloc_nohuge; } unlock: