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: 13391491 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 F1BFFCD5BC2 for ; Tue, 19 Sep 2023 13:55:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA68C6B052D; Tue, 19 Sep 2023 09:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D9C6B052E; Tue, 19 Sep 2023 09:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B06F96B052F; Tue, 19 Sep 2023 09:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9FF246B052D for ; Tue, 19 Sep 2023 09:55:55 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6DEB380D88 for ; Tue, 19 Sep 2023 13:55:55 +0000 (UTC) X-FDA: 81253495470.28.FBA1EB3 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf24.hostedemail.com (Postfix) with ESMTP id 7777E180006 for ; Tue, 19 Sep 2023 13:55:50 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=vKHZW4TP; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf24.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=1695131751; 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=FJQ8bvj/9Vs0utzuzFMcJ8GvK3wVEgVmfOOT/zQHcR0=; b=cGDB6dOhgID0JETEehXqZl8dk69kx4/ujKH/zZf07bizlzEUCi8eQSEsPRBgtaX4mbwP/f e2q4rOna70deUoBH9+xPCRzFLjWk07CMVKRXZrL5N8WL/2Gf4qf+NcdPbU1jhG2XxyblSn RBPGRrCb2JqlaKUUzNrUdqDX1ZDKKcQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=vKHZW4TP; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf24.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=1695131751; a=rsa-sha256; cv=none; b=A/nPalRNp6O+ExXjZY2LTfgXhVdzkPS1wSR57hBiHGNQVsGauNRAzK2kI5H00EBFup8gi6 9aMK5Zw09sDIb0MWMz1ny4YYpbtkANJBXxq4xXsBZr6VKm7tthY4rC1ON2P1I14ylKo2IP XNujYCUQ5z8vOGiQqht1HTu7O8UTjyc= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135547euoutp0169b4f6265a2b3b5ef604fed3d6875690~GUVfxGdLC0107701077euoutp01x for ; Tue, 19 Sep 2023 13:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135547euoutp0169b4f6265a2b3b5ef604fed3d6875690~GUVfxGdLC0107701077euoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131747; bh=FJQ8bvj/9Vs0utzuzFMcJ8GvK3wVEgVmfOOT/zQHcR0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=vKHZW4TPgFVoUEf/pL3g+3a9aJEqv7NQpkuXCtaguJwOqoLs3rzFGVmhxP/9/MVpf H4uRdQpVMKAQeED6OuJctfd746zmIPtwbvURj6wWKu05Dx4eaLFf9h3FIY/bbWZNQe yUmaL/tk4T7KT78vIS7YHzgOKOmspvcSI/TYm70U= 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/Q8rh8ttRj06p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FR5krL2/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> X-Rspam-User: X-Stat-Signature: 3j4jkt56mmzyhqeje75onxwqihwe6777 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7777E180006 X-HE-Tag: 1695131750-433582 X-HE-Meta: U2FsdGVkX1/1QL0VUFfgwpiBXdt1jC+e0cL2HhfF9KtMXYepDUt5BjOrGb4GUwl6A+luwR9abeM+f/YZ0sWsd6fc3wusKVaiDz5txvuBfX/ke/SpsBUCWWxzpGyoKPCcwn9JBixK/xMfBxrTMmpoiNFK3aM/7Vs2U0D9cIyuzqliewvkN7w1Ns2IXegt67jhy0EnrH+lNnJcZLCQrBT/I3glegupNKCqX7mukbhJpXMeE6MWq5ObFO8PHVKl10mlmGO/ptbl5KYcjFQ7JfdO2Vrq4PovNZBFiwefUsnoMNuCHxuEncqGcMbn0cwlKVhOhY68S7lVJLwRpb+GgSRxk00MmnAdonx/Jy+9+/yYsW3jIjqjC/hgVvQZZ3wa6UJj+9Jdc1TwS9Hbu/2lB9lq6uOL3HoaTcTpCv3lzElyDHSKQYFW5xcS2NcjAy4yM165RfFwN8EC5yTgRprP2Mfz1WTJ2J5CwjSYGq+2eFrXx0v5EGStlxssmerjMTV0sfHxgnwHZeeVDjLayCVFyEoP+eG1Fv/GvKtckCrTjw2xrqzoPYIqiuhgQinHBaqhiwQ5mKPXBn3akkWIJOVL6P/+lZgbX3ayCoiOXvfP5Cav3xGreiK15ISoVmejjTMJCdXjFbHohed6R/dLctq2r8/6ZBooDad7BHSoy/juGiJ+mV4IomSrQQgY9erQrpiTuoFzfGoxDO8AFDJfdDP1K0amPCBds0ZxlewtnT2rup6GmYn0IUnN5RDnh1Bc3j8b+ndYKxXe+riVRyKMPlFl2i2cS4nz7sE1nfcopTC+drEoG0FHenhW5Irn5BudkRXOgv1c4AYLMwAdmkwtNjEZgsiATWn2gG1//LT4ERhaeCrwA9oD8YYpo3ZexM/FsDEB+CehyaKkmVZIzzAT37ccD9ZmwE5ikV7TT+oM7IUbBQ9KI5o/MAhh7LJcZw2BDiSBFx2kz1ManNRXG0dc4NfYRwT 9A7eJEyg /e9G6t1Vx129VSuA7uBfGNz8ZJiViVQbHibOHrawk29Sboim+0zQ9KoY8mlOcO9TNLI8yaE37tZd04FuWRvfFzY6i+XL/U0mtxnMw0kBzaunzoKxfUCv4pb0vbNz4q0mgVlFGdHEgQH98nB5pYW8R588OwgDL8inFK5i8mqTB6aLUU7MJCyHUa5nIMvG0KpqMBdADVC/zVxOuzeU= 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 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: 13391490 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 F4224CD5BC2 for ; Tue, 19 Sep 2023 13:55:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E6EA6B052B; Tue, 19 Sep 2023 09:55:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 897206B052C; Tue, 19 Sep 2023 09:55:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7100C6B052D; Tue, 19 Sep 2023 09:55:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 59C546B052B for ; Tue, 19 Sep 2023 09:55:54 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 26B541A0DDE for ; Tue, 19 Sep 2023 13:55:54 +0000 (UTC) X-FDA: 81253495428.09.FABDF24 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf11.hostedemail.com (Postfix) with ESMTP id 2ADA840006 for ; Tue, 19 Sep 2023 13:55:50 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="S/I8tzNo"; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf11.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=1695131751; 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=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; b=eKbYEPIo1+d58YCjcTKNRrX3roJibqbtXlFDi7JmQ0YE2H3SOfhDPkGOVRJDX75aNv993T Z+ETxg3VoXsfJUiDE8S/WEGzaiaPpRBhbu+R2j9qNs3URTpfOGbDPOmZRW4wjn8cWMKlGo 78NOb1fatCsakzvpmgnu+5+uWKmXu08= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="S/I8tzNo"; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf11.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=1695131751; a=rsa-sha256; cv=none; b=uj+8JFuzl8/0uAJ47uRtH9AhlCKMmca06ggZKHNrwT8JeugviHHKyWxhUna8CIJKBgSmcf OGhTZzzB2RcJr4l2/yWOAnQpAPkYXy4E/FnHyBoqMmkSnwRKXuIlj3/oFbh8IQguo06uHg T/p6nNeRdwgbQTxUeSGygk2pwv4hTvc= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135549euoutp01fa6219da8f4564e400b1675ecfc7c0d1~GUVhp0ZfU0199901999euoutp01y for ; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135549euoutp01fa6219da8f4564e400b1675ecfc7c0d1~GUVhp0ZfU0199901999euoutp01y 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+Z84j6P7fJiJUzGQmNeFMjkXPlBb6M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7879a14a87724a9462fb8dd635bf 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> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2ADA840006 X-Stat-Signature: ffwtng134ok3fik5ydoyyd4f8qkxfjpp X-HE-Tag: 1695131750-786752 X-HE-Meta: U2FsdGVkX19IqL7R29u3KckimH7v4hbTPDH7QFB2U89n1zVR9i7Kf/OdHPMMlsWSNGLmvWq4TKrY2kHZsIXxotU8Jz9791cat4wsk6smp4cN3hmhIKf7xoH6z2EXoovLeMvhDiSmL9Gu3fkJauIq3eakNXb9TBo8CyprPEvFYXK9avvcSEZ9LVXfUHo/A9+mPFs/BYHAoEvnIC8uLS2h3BayR/auseJx9El2t6BiZMfeZyuL5wtv+RAGMMV/WB16lcqC+osm+6OdnEkhgqQVrZoGXidIIVljuICNeS0+v93gmx6Er3BZkoRWAreiykwOAQcNpo6nnyQvyKPUxA644MyujH82hyUlucxVqcUMOsA+tiTWg1J9phQrq7YEzAMxMrz4Sj2VNa8LLtE/deabF9VVzQF+4VktQPzCkBOMurEq4QrNYGXzX+QrEjuAb+yLE3cF0KZAPcxWwykQ5cDBqiIULqRWMA1u41tzjiw2JvnZmdpZLJrBoOACJAVRLhj12kTQgZuAMct5IqcVLiGXkA/5hbpjRs9pH6UG8wPS+9I2wzbk0+XWFs3duwZv/gxcv48/FKQ9WS9SPvMDwZ2MdIrZ4EaOyk5QlTwNxlSLaN/O4F0cOoK3trv/A+3ckzNH3LNNKChtWGGDDWD0BilkZ9gUqCu4y3pupXLZGYZF23POLhDeKnWW93C/Cjn9uzKHJLqkta7BgRCAA9BdZiXJSrj/mlVbSwksPg8OQsYDqwd2CC8QxFcG5284pOGOH6jScZgHdqOnYZzw1QogaSjouYg0lMxEAVEhvB+Yyzm2tH96kcO2leGZZekArbuhpr5+AphIw8JuAs724KplS4tKym3FuamJB2oBkbYR5EZtgLvwOHV1F4drncLiOZeOhjcHk6tQCYgYUFBTSsuldMATt7pAoHazfDwUneCRYpA1ybsLz0hmPF12LBMFAHDfvg5UZLksc4mcbwyHkpS0q0W 6zv5vv4k rcQNbGLWixZrxa3BseMdOXwt/om7Uk7YkFFLR540SrbEh6k6xzmIDYRnI3+23Cc6onFPWbKrrvNhSgFLYp9nWYLe4fB+DKIHuBnvDYXfKo+AR3KlzkAH4qWLfxx+D9pYNLWRNHvl+NA1oXpGoaiS1rsCCJgDYsCngoPFNU48aInjTJFNrVViXWOdKyjN10HsSbyRav50TFd7Fw2i4/BKzqkHQtQ== 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: 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: 13391492 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 9462BCD5BC5 for ; Tue, 19 Sep 2023 13:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 013D36B0530; Tue, 19 Sep 2023 09:55:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF13A6B0532; Tue, 19 Sep 2023 09:55:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2E086B0530; Tue, 19 Sep 2023 09:55:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BA8676B052E for ; Tue, 19 Sep 2023 09:55:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 91D3E160C22 for ; Tue, 19 Sep 2023 13:55:57 +0000 (UTC) X-FDA: 81253495554.05.60DDA95 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf12.hostedemail.com (Postfix) with ESMTP id 8253D4001F for ; Tue, 19 Sep 2023 13:55:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=tyM4uvQd; spf=pass (imf12.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=1695131754; a=rsa-sha256; cv=none; b=P5rbBlrujtml3fBdB2t3rHSNQ8YRrJ+LANOCKKxwaGpZnYfS+n4JGuF7GbRAFrJIooHbYi XCjUAsfLqVoWOTez7wFjPT5X/SuGpyZZORlgn5cNlec9Urb6r9Lq1c0E188Y+EueDOZcfx xGzPIZiNlUCFXlFspR1gtsEzpz60eJk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=tyM4uvQd; spf=pass (imf12.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=1695131754; 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=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; b=wNi2JGpislWKIPpAgGLP2Zl8bKF92K9O2vA+pc+cl4PmNXEaDxARVX+YMX1daRV0Y7tcz8 whzzGm0GSa1FA8GJdmeWxwfX9L8TUkhChr0p69sA2gA3pwsIljKKe9JHt2/fTFDUh4VRfY S77gX2WkjJ3aQkfG0HjR3DDIStH0JMU= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135551euoutp0286034f21a460b84b970ce812be8958c5~GUVjU3VBN1585015850euoutp02X for ; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135551euoutp0286034f21a460b84b970ce812be8958c5~GUVjU3VBN1585015850euoutp02X 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/VeqsOu+wNeKUTdyXKWfr WCN2su4TnXdxfu+dfTw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3HpLQOLkHjzr7DurS/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> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8253D4001F X-Stat-Signature: 7ab5579ekfoes7cx4gownioxjjizha7f X-Rspam-User: X-HE-Tag: 1695131754-4098 X-HE-Meta: U2FsdGVkX18TW+EB1DhaJlU2d9cz+nulRu13idmzRvX1BstiFSQEFvx1cq5cDtFjrGok228f/JHFPaiyVFl7i8YRq7B92jO4mlO8jbw4O4l6gHrop6CxwSomjCl9zVHAc0Mhog5sD7PatJbrE9UKhsaqAa1i3RDSE62wS64Y3+8sRXjyTsOVaE4QTgJWGRbMfUnQQeAfFWucIzUPhKjBONYc3zni9/k74Hm1uxRnDoitc0ZIt3Kpi36lT/zawjLwfeNBGt9zQlyTdPGEZycBsmvZGh8ppgxLSQqKKIbmqGde6WYMH1gg7CJHN/ND5lKKh7W+ohdl/D2jug5GH5ymOb9LoWQm6R9vMCJuVO/cBRuzNLFRarOVDWMYF6WmT+mEE2KS92pml4G2TrExog9F+1yIvUWbxnlKpXHt7PSvj/45yuskWkQFiAO9lmIva1xQ3RbFsyO4cpbkBktiO+SRXW40LM8a6PhUdRYlRMIXf5wc7OjuDhDppdYDGI+LUzYHRUpKn396etiBsCRnR2XCPdoB3mIv54x3M4PeI0aYHNITK6RH5O4EUDFCltHSFUQ7FF3uA2oTf5vCd/ZEH8SRp2iK1BzLWiI4e2Mi1jA5Rl7B8SSfWygy0jMuOa+P8B5r3QXW8pqO8NxDo1n0F+z5UVAkK+qXjcsg3e8twEzh72DWEmj2lSaQf8GyYeVQSNe17x/maMYjStTmcoaJ89zYG3IgNmzFrXNxgmXayGpJfasZBNMZQIbPgbnsyV49eNWc1Ag8VG4pXfbty/dKMiRxj8riEvhVzqx6zOevFVmjmMpnz/zwjanKGljLj8UO+61TRvyN57ZwpyjHiR19fDUd1Sd/O42A57Fg36tX/axI5uV/aFQ2Z86cMfLLohsoUU75WH5A5WNQifZwH7+URDqfXslHr715eke9+GJCtjVL3mEd94MaAgljpH0nNzGmPDOh8hg+s8sU1qhOu/LsoIL oA8AhEWY u3gthtZuHwOiH/uIgdUkYz4EnlhoYwCoMwOnfDOYqOptgBwjM5UStoriaCLxVybmBrdFaLmC85ufvDl5GwW3ykOGnJv9JBPQg39V+1a/sS2F2PEcDxnVWdi/IVGJxV0XMDQv0GZ2kaAGVQgEq8G6h3owSCyp57ZcYU7TT 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 | 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: 13391493 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 C4A72CD5BBD for ; Tue, 19 Sep 2023 13:56:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42CD06B052E; Tue, 19 Sep 2023 09:55:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DBE66B0531; Tue, 19 Sep 2023 09:55:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BEFF6B0533; Tue, 19 Sep 2023 09:55:58 -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 E36606B052E for ; Tue, 19 Sep 2023 09:55:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9A00B1404DD for ; Tue, 19 Sep 2023 13:55:57 +0000 (UTC) X-FDA: 81253495554.05.A7F7DA4 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf27.hostedemail.com (Postfix) with ESMTP id 86E774002B for ; Tue, 19 Sep 2023 13:55:54 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Nuk+vBjm; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf27.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=1695131754; 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=j5/WuYRozdtOAgqCuDPHuq7YO9f8GU76Eza03ZT/hH0=; b=wh+kpbSolxVut42NOW8B7QRwRc3DRa0dFV5UBmS6EJHs/rDAe7yCmIbGyFuq0jNqJH+yUp CpjayyoXIDPPnJooszlP+EcsiBuaJq7mdcbofE4mWyUMReJVC3Dcy+H7A2onsTRcZNzDsW dwstqRbgcObwE+r8LjMo0htHDGE5Ek4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Nuk+vBjm; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf27.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=1695131754; a=rsa-sha256; cv=none; b=CD7bfArCNpQ0UG/7rjfemcU7nTMfwKWp4Iw5Lg3I8TGDYSC5Am3+3IuzuhOyUA5gb5AHT+ ttGwRQ/dTOdrUbm4gvAxdMq3nqiTgTz4nybNBDgt+wKfqgm7V++h8CBKj2L23MA5u9Ej/C xiB2+ScMmS9bYVAVqEgXrjC9dMzcZj0= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135553euoutp02329f264fe0c275fad9eadd8a6c53c251~GUVkxhfYt1585515855euoutp02U for ; Tue, 19 Sep 2023 13:55:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135553euoutp02329f264fe0c275fad9eadd8a6c53c251~GUVkxhfYt1585515855euoutp02U 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+NgFjrOKsWRmVeSWpSXmKPExsWy7djPc7oZKzh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5VD1uvlI2UlaqtDLjW95guW039IqP08cUJniq6I2Q3qZ4ifF2ztfiRmeq2G8Wa9ncevQ 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> X-Rspamd-Queue-Id: 86E774002B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ps5596pzzz7kpuiyyajrk4z7bz7qa637 X-HE-Tag: 1695131754-554904 X-HE-Meta: U2FsdGVkX1+6lpma34XzTh22H2Mt74MHwxVEYWQoEcJHxOX4UgD7uDOQJW1QhA2HJ0idrVJDX9sYfdFsEOQTF83uhGdc/UwG9iVHgfJQ6j4c+L5hQ9O+x41k2zFoFY1DwxERQ8vklryw7tB1UadGN1/zFZdqGTKmbsVULvUBoIhiwTq5dcGGg91e92GrBcXVypRkc8eMIKNX9g/tjTJLzjj34YJ1HYqFm9s2WjWZ5ZzdANRrCAaar+9xUNx+bBUccz/GqwNF3TJtOyBiLqk6Er0ubMsuW2p/0nsWr5cOmNdbWaL4S8gCAXaUVJF6lKw+4S4YMJ0mnORUis0EaWmkW91cR79El3CBqDsS5txif2o6MC/I0I3ktemC4wSk79XBluXrPACfuy3fzSnJMXwSK89lvm8oZKwPwehxcvojmsgfKkshEfi0c+hZF9zjNDD6/92l8YPn+aLoSS/sJUJ3gRravepzEf3weUw/GNL8Dy26D9zFjMn2RYzhAQrDK8WlXXPHb4fYrFDDIjCt5fNNPL3hgTFftSwC+QUgAYhVveg5CjwfZP+UAgGkSDTruUAZu/U8PoEFPi4zp09mfEoBYpztlV9XyofTdEE1Cb15PXhyuuQoTWJ8i0u4TabPPWV/XwkLfzHD0MvSwMRNPyGRYGosFplmi8xKSPBMMbayHudh1SRr5Ht5UvtuyfHxU78dFXaKlv3kmjFldFk7NG298XaexyHBtZ6KcGlY+fKcz6PmkQk1UcmsCJQTrKvcvbeXOCkBpZlIKALcoyiyHhSWQlpo6iwBNjPoGCoLWJrtOH2H8kIAY/reiM4pbn5fwqPuUgLIx1ILY73Q2BVdNBoWYt6zDfpeQE1TB9ouxt1G78LHcevZwErYuUyDEPTS1RKVwb1eVqyCaSI8oJMr7DgUBXLU9vfCunMto7Vzi8Z0ImKI3nhIOfBPHUt3liIoiudxQUszrVOAdBkLnfGRxLm 4Hf44vJN m+sBVyCG/fcdtQsWucjUyxlM9cTOtJM6RlWcYpjhYaVN3GcoSWWLzGl5ilNFqRh/SLk4VyTqQfQmjpAn0drMJ3hzeMZPl5WkkYZ81eyAlpiVsVf+hV/4eY4bVcqf7QOSLNgQWenB+CWYev/FRfp/WpIpEYIPGKRERkUd9ekO1qQhRRmTwOyFCDbej46QKGqcSMiJap/RZb9PsN125XfOzR6Jdfg== 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 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: 13391494 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 BA26ACD5BC2 for ; Tue, 19 Sep 2023 13:56:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95D6B6B0531; Tue, 19 Sep 2023 09:55:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C16B6B0532; Tue, 19 Sep 2023 09:55:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C32B6B0533; Tue, 19 Sep 2023 09:55:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4914E6B0531 for ; Tue, 19 Sep 2023 09:55:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1A9321605D1 for ; Tue, 19 Sep 2023 13:55:59 +0000 (UTC) X-FDA: 81253495638.17.FDE517B Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf30.hostedemail.com (Postfix) with ESMTP id 0E63780030 for ; Tue, 19 Sep 2023 13:55:55 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RdyrgSlx; 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=1695131756; 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=qf0ZYfltBJHFQkocAMfpwOGkTFM18/mnXm/sqbTG1Hc=; b=nDs9oQERkG9cJ5SWrI/U9Z4PSTx8gzgK+jFSeaNnb6XIn1s2ifBN0f+a2t9D8cfINyUl6Q W64ZCHeHKbtI0JRrgFxUtRUBmKVGCpTjuAD261cf+KRWEc+ZSW5nnbyWgnxhdAxIG25qH+ x5JKK1tk8wUxbY105qisfAfNxWiN55M= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RdyrgSlx; 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=1695131756; a=rsa-sha256; cv=none; b=v0NlnJJMTIv6C+fNDQbfjJK7hpCfSVYYpa2/eojIt2CnJ5aizyQkh/TF2bAOXCWmh3+wdI QS3A7xDajqQ/c/NUASeyyPYrHrDnebREFqIXaj6M6X9FvECxPeQxiNMqpuendymQ0u94ws oNUfBzhsipTtNHUz4EFpV/chYHf+y8A= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135554euoutp022b4dcfb1edbec041e874ddba1dbae29f~GUVmPQLEn1619216192euoutp02A for ; Tue, 19 Sep 2023 13:55:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135554euoutp022b4dcfb1edbec041e874ddba1dbae29f~GUVmPQLEn1619216192euoutp02A 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 LCQ7ZiHZsYCRZRWjeGppcW56arFxXmq5XnFibnFpXrpecn7uJkZgYjv97/jXHYwrXn3UO8TI xMF4iFGCg1lJhHemIVuqEG9KYmVValF+fFFpTmrxIUZpDhYlcV5t25PJQgLpiSWp2ampBalF MFkmDk6pBqaSuBwH+ds1VpbLp097b7xwtsSnC5bmi3zsHsg9E4vOFpM0De7P8d2z68Az75Kg 7kAftV81opEXXi6TszC8p/psgp1eUc4uo5wDMc9kLWWkpyz4tOm2amb/6t1XNxexmSren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DU0szYyVx 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> X-Rspamd-Queue-Id: 0E63780030 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4idto8e8cxsunqj69a77etm1tsg3i5rf X-HE-Tag: 1695131755-714465 X-HE-Meta: U2FsdGVkX1+QefOKPCRrO7dAigZ/+O7zOQoSNUQFD54Q9B0YUp/g6Zhml9A/tZz72/E+31p3DaA9nNr5YOI14MWNA/aKhf30RWu6H99T6qPWkcZyS4V10hWacKrUW9RQy9u0hNLaCNDNsBQCWAZPcRnyHj/XIkV8xuMNuDFyNcoEw6ZttEUTSjKEL/62oh3GvuxkDm2B7FCon2DskpusLcI/VHd8uPPdFtn8/HFjKmdm/xk6GaIk/19Q296ovJmlaYH3kM4+MgGD/tDytCwuxrhJgjxRCjMkRL0n1xOvJxSHtbTyHjO50RzG0/scyhCbSMOadJQFSAIGmrvYJPJMMD9t4U5Fyyp0VfZiag8aQEdhoBIWYkmrTF2U7N8QMSxLBvBy7DeDh4/72lo9zSZDQTURsar+crQjAATf8pYJKBrDwbkYsRIDMhoJGTdyxH7kBCGCARra1EFwn3BN9ODsr8P5zRbZZsnlpD4NKXsNheVQ/Gs2cVK7a7PTc5L76Bqp0Pxy2nRteWbyJ5Fi+vgHDiW/OgDM8lSVkYRxBukU80PMx93X4mg2MbX/HM2hdLWNZIWJoSQg17jliMjvbUM5BT6vI+PoE+dYO4y1DGgRvfnj5wFQdpWG3TW0g5l4QeY7khkza2H40Lk6YpFjMpNV+2rNd+KTBGtFpPLgVzNvnjqPSe2hbHuk6woaPEtmBYPILbtzjFN+TwlpWiDARLAmgMY5shnoIj5FDk8TppIakXRp72lQl7ue3baxoZyt+kD0zUDT4EOgALaJcZUaseeTKJgorraL1f5Ya8HDCoMQL2j0gN1y12GL0+yc0sIBfWQhDQ2+dN1/UwcJ6pkMY0ZhecB9z/ut5XiFZhC3887Z1+5K58HDM9yDKrzHEN5jao0zGkDGw3FqqrffAXAqCWo6pNMfdMh4e6aKe6QZD1cUQgcDarvvKkZNVe5Sj8jdsRJ/P/z5+mNj+qm/oK58o+m q/2xOZB6 9IDCAYDXWStOg+2+zbNh0Gn7gX7YwU1Ae0EaWFE0amMZOOOJe97CJ1oOtYlEzoL4WrZMJh9bXGDfAKVsDP+wIR0CWXotamAT084TzlkOKHH+c8gmxxKcs8DYMCpemQp3nLC1aXPtsIzbXOAcm7hlC72Cvc5MTzQWFEfUzylJcs35/SeyQHum5pJ4Sm72FZTmLGeKDHD1H+i19PRvwh1lCyYJUSQ== 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 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: 13391495 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 E7CAACD5BC2 for ; Tue, 19 Sep 2023 13:56:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A84E6B0533; Tue, 19 Sep 2023 09:56:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 230576B0534; Tue, 19 Sep 2023 09:56:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05AAB6B0535; Tue, 19 Sep 2023 09:56:01 -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 E3BC36B0533 for ; Tue, 19 Sep 2023 09:56:01 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ADA43B3AB4 for ; Tue, 19 Sep 2023 13:56:01 +0000 (UTC) X-FDA: 81253495722.23.224B11F Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf09.hostedemail.com (Postfix) with ESMTP id B66EE14000A for ; Tue, 19 Sep 2023 13:55:58 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=nuctfpPH; spf=pass (imf09.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695131759; a=rsa-sha256; cv=none; b=BPk8SictT8+xpcyNyh90qdV7LZGH5XhVjZnYegGwXY9RmYkAFQSKR8fPYsknedA1x7yMAZ /jAKkNzGau4stFxzFjPhOEilHZHlVZrnCeUWhw/hFHWV9VKU5m58AZLpp38llBn/UPvvF9 ahuCcecZypgdlFpO4bDT9ipQyHZ9hbI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=nuctfpPH; spf=pass (imf09.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=1695131759; 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=JKaS2+/EEMvNdZiV+zve2PZ9hmK4b8LE7tpeT3AMyFo=; b=aa9QjBzNRPi5sToxd2z3kESw0IIJCoMMROwHjuP/FRq6QqXoSX+xrmumbiXO0OAp58Jkrz bfkFef1LFLU0bduaD4k1FaxC6eRwZUhGhIszlxHWrW9DqzDC1+iYOq6VnWuh5e+ViZZWOM Bc+BYvPLyXzqnph0o7xZh8FhygLHeN8= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135557euoutp01ae26dc16ee624b8a46ba35fa13cfcaf8~GUVoYXb-c0199901999euoutp015 for ; Tue, 19 Sep 2023 13:55:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135557euoutp01ae26dc16ee624b8a46ba35fa13cfcaf8~GUVoYXb-c0199901999euoutp015 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 ZMcCRpZVjOKppcW56anFhnmp5XrFibnFpXnpesn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/qN90JM5ef8IIYRtI bF26D+p/JYk/HQuhbtaTuDF1ChuErS2xbOFrZoh7BCVOznzCMoFRehaSdbOQtMxC0jILScsC RpZVjCKppcW56bnFRnrFibnFpXnpesn5uZsYgSlq27GfW3Ywrnz1Ue8QIxMH4yFGCQ5mJRHe mYZsqUK8KYmVValF+fFFpTmpxYcYTYFhNJFZSjQ5H5gk80riDc0MTA1NzCwNTC3NjJXEeT0L 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> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B66EE14000A X-Stat-Signature: j57eqghd5a753nyzqe66tzcif7e5srhr X-Rspam-User: X-HE-Tag: 1695131758-778579 X-HE-Meta: U2FsdGVkX18NjqfxKMb/F1nekzZlcXbSH8qLfYkbRxGvcUrt6Fjr092W4AmV2E8KGJkBNv2PBKaAF1x77Uu1ecgWqOCis9yheeY4PzUoA7cP9GU1mal5pfggMBMe1akkBg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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() 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: