From patchwork Sat Oct 28 21:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439573 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 36A1FC41535 for ; Sat, 28 Oct 2023 21:15:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB6626B0294; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9F026B0311; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92BBD6B0297; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 842ED6B0291 for ; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5E9AC80412 for ; Sat, 28 Oct 2023 21:15:45 +0000 (UTC) X-FDA: 81396127050.07.EC9BC29 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf12.hostedemail.com (Postfix) with ESMTP id 55DF640004 for ; Sat, 28 Oct 2023 21:15:42 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=jjaWoMKm; 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=1698527742; 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=eR4ECi1C+RsYauRNG0Oa6wKRBmELNPkutLhe+B7jobc=; b=jvEsKqJTo7XzzNz1a5ar80ygl/Mdu0u7S+uJcY0jZUrHFmkXcqqMbbWmqgALqIJGAvypJp x0xS04g6303Opwi7Y+PeMPNi9Ij7vsUDj9tgPXY/uO52t2m2iILvmtZ+o+hEuCcVkdqZJp WvfNuXZcBnsS/zRFz8aIx+vRUYO/wlM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698527742; a=rsa-sha256; cv=none; b=Yl+w4YQH7BW43uGDL/2iMfAWV8OeUVmKa5cDLSbjMHEVYOakniYPlQXvoDm3+e8NniCTwi nxoJef2muDiSiqmp/rpD473P0ElCbpJ6yVQ156hL4bwKSB676GKR3UG02xJ3islB50oYTG gqCDlF3JQi8mRE/JcVPWnEV5uLLs2Cw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=jjaWoMKm; 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 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211539euoutp02b64c473a44f319b2787a0887ff33d633~SYfrrrweM0331103311euoutp02W for ; Sat, 28 Oct 2023 21:15:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211539euoutp02b64c473a44f319b2787a0887ff33d633~SYfrrrweM0331103311euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527739; bh=eR4ECi1C+RsYauRNG0Oa6wKRBmELNPkutLhe+B7jobc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=jjaWoMKmpeL2sLoVtVIJ4rBEKLLd2KsJYQnpEHdBiXJriXoTywXG7JA0og2/7E9L4 nh3HhyRmF4s0KfRNL2fV8cM/ugVIvmzKE6VHyE/hZDSmpARN7AkVO0+/3hrdTuAeGS B39ZTQ5pTxSF7SBjTBKGSvpsliXmO/RVLKc4DdkQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211538eucas1p2c2a45a33072dae2e110eb46cac041cea~SYfq672AJ1087910879eucas1p2A; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DA.57.37758.AF97D356; Sat, 28 Oct 2023 22:15:38 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eucas1p186e33f92dbea7030f14f7f79aa1b8d54~SYfqiRzRj2326023260eucas1p1N; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211538eusmtrp26da1062912af33695c737ab5cb5b69ed~SYfqhpNZo1141411414eusmtrp2Y; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-f7-653d79fa5a08 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2B.F0.25043.AF97D356; Sat, 28 Oct 2023 22:15:38 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eusmtip1dbcf26df78fa637ec241be47c974aeb8~SYfqUnhnc0467404674eusmtip1G; Sat, 28 Oct 2023 21:15:38 +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; Sat, 28 Oct 2023 22:15:37 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:36 +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: [RFC PATCH 01/11] XArray: add cmpxchg order test Thread-Topic: [RFC PATCH 01/11] XArray: add cmpxchg order test Thread-Index: AQHaCePk2/Onfe3eA0ia1dQGCoKrAw== Date: Sat, 28 Oct 2023 21:15:35 +0000 Message-ID: <20231028211518.3424020-2-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrNKsWRmVeSWpSXmKPExsWy7djP87q/Km1TDS60mFvMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOK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qFCz+W BJhWPH6WrvJD2nztj0ARLbfcNVZfC3pllViKMxINtZiLihMBJkEZzNkDAAA= X-CMS-MailID: 20231028211538eucas1p186e33f92dbea7030f14f7f79aa1b8d54 X-Msg-Generator: CA X-RootMTR: 20231028211538eucas1p186e33f92dbea7030f14f7f79aa1b8d54 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211538eucas1p186e33f92dbea7030f14f7f79aa1b8d54 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 55DF640004 X-Rspam-User: X-Stat-Signature: opn9bxg9wo4ips5bbp6pj88x5fn7xnit X-Rspamd-Server: rspam03 X-HE-Tag: 1698527742-382579 X-HE-Meta: U2FsdGVkX19dMSMz6+zEYnHjGr+j2t504qEPT123IR96L3je2FCEWpsJy5baHpgOLyIwGzKqsVWGqBWT/ZabZnFJfrBVvpOFOmh80AwcyxVnyF4NVJcOsWgvoFgINRQB0pk8VTA4XoZ6u5nHLAPRKedQosC+48xIXmA7KgBxctP9EtQ6WeRsPy6a9emqT0omOFxHOy31wVHIH0vzvT9Jg/Mp0vjSdX+OV1cU6isyM22jQgFHZweFq9Dx/yjBxgvKFkqnukvT1S6Vvcf8KK+71MFwyIOsvTCLSv+LD2xQeCt/IJKf/gvPeHK6e65UdmCbgfdTj6258T+8DwrdBCwgbTsjqa3/HGlXbgrWfCyoz8HT0GnTXX22dmPxTdedHM8GywHNjqCkWYDuvuwXDBcMg6jIS4QBPswWc6cW9dZc4aoFXVORwelPmj3hszGofedxxj5XJyeVH+yZhTg+T1ZdOhSfqsTz2NkGvO06vu793XRts1oWjNBq/kz3Vhr5465dul6Ua5yRjnD/OXJB2kJZgdEJ5nAvvh+Hg+NsQ2Nj6i53q6A70wOHhxJBsfPqwO3k0atzu2qLvHI3XYug0BLac1vyZDCFB4Qaf3NbxMmlpHRnLjBJDzE4tOSTRxn2oSL2J+2Bw4hB3MISqEi5nWFZZVIdSDOIv7B7wYySZ6F9UjlrGjZp8f0U+VqOL07+GWmftm52u01BimiMXIQQ8TZ995lEBX1qQEyeaSLO6TW7D5BsoCPVOrqj+qCFy5li82s8ojrw03KxSwipEWs9nsAEqA7pB1ueCxb2zh5Bk1OoZkZ0JNRlwZepwUUlzoG1GyD13nXztiZ07RObCllsIJVAJnTvpT0Ksu+3Km+3lzDJHcgJl8Bez/QG9zb+/omCTOIPPJXePNPRyh6Mi68j38LceBtrttZvOpJJswGb2f9+ZQ3A68I7PWEb+wAtDc164Dn0k0Ouffa2VSoIB8oHSaS 1XUhWV3I iOg0f700IldiNilCAMhVVmWJojWjD81u0CVGTo076JrJg7e1D/zLHwNqoFQbVkFu89vXqjO22+96D5TJZQueVuZC20/bZAAhRSGQDi8pOzrkGucv86EDv4vNWJL3xHAJNbEYzqjmsdCH/d8LTfHqrcUFpQVfTodHVN8aI 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: List-Subscribe: List-Unsubscribe: XArray multi-index entries do not keep track of the order stored once the entry is being marked as used (replaced with NULL). Add a test to check the order is actually lost. Signed-off-by: Daniel Gomez Reviewed-by: Luis Chamberlain --- lib/test_xarray.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index e77d4856442c..6c22588963bc 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -423,6 +423,26 @@ static noinline void check_cmpxchg(struct xarray *xa) XA_BUG_ON(xa, !xa_empty(xa)); } +static noinline void check_cmpxchg_order(struct xarray *xa) +{ + void *FIVE = xa_mk_value(5); + unsigned int order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 15 : 1; + void *old; + + XA_BUG_ON(xa, !xa_empty(xa)); + XA_BUG_ON(xa, xa_store_index(xa, 5, GFP_KERNEL) != NULL); + XA_BUG_ON(xa, xa_insert(xa, 5, FIVE, GFP_KERNEL) != -EBUSY); + XA_BUG_ON(xa, xa_store_order(xa, 5, order, FIVE, GFP_KERNEL)); + XA_BUG_ON(xa, xa_get_order(xa, 5) != order); + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(FIVE)) != order); + old = xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL); + XA_BUG_ON(xa, old != FIVE); + XA_BUG_ON(xa, xa_get_order(xa, 5) != 0); + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(FIVE)) != 0); + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(old)) != 0); + XA_BUG_ON(xa, !xa_empty(xa)); +} + static noinline void check_reserve(struct xarray *xa) { void *entry; @@ -1801,6 +1821,7 @@ static int xarray_checks(void) check_xas_erase(&array); check_insert(&array); check_cmpxchg(&array); + check_cmpxchg_order(&array); check_reserve(&array); check_reserve(&xa0); check_multi_store(&array); From patchwork Sat Oct 28 21:15:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439574 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 21875C001B0 for ; Sat, 28 Oct 2023 21:15:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F02C6B0291; Sat, 28 Oct 2023 17:15:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 079F06B0297; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D71176B0313; Sat, 28 Oct 2023 17:15:45 -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 A97416B0291 for ; Sat, 28 Oct 2023 17:15:45 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7B75B80466 for ; Sat, 28 Oct 2023 21:15:45 +0000 (UTC) X-FDA: 81396127050.04.E130385 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf29.hostedemail.com (Postfix) with ESMTP id 83D98120002 for ; Sat, 28 Oct 2023 21:15:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="Mm7/kBdi"; spf=pass (imf29.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=1698527742; a=rsa-sha256; cv=none; b=II8SzABzs0VTnKYURrDvEH9kJIToEICEBfag2R11qj0GjKeAlWhwxPur8ITVBvkkkohU9/ ViXvunpCH83LaaUj6HRnfecnJk0mty6PQ4Wr5FDWpW0XH6LgHCkk69zsMDNt/RsLsv7Vcd 8uRC3VErGwLm1cPgNgDeOR90jOmISGs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="Mm7/kBdi"; spf=pass (imf29.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=1698527742; 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=JNoJR/Xq7klfzP9hsOQ2xMnfdiLvLMoR5LEBEoVDOGw=; b=4YDSJp4K6fIbEFeWxV6TKtzSAyDsn8RBmiA9sol5KSSWn9m+ea7u0q7JBPJ2gRE4s+MPv4 2nivUJI+k6dbQ0tpxJ1rwuqirLKbB2tj6Ll68SNPiv/AXoNkZ219oQG8HLyr/WF+kP8sOO Xunn0XWXi4ditJm9DWEHpImiUk+ZDfs= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211540euoutp0278b5253efca1de60fcafd06ae00ca1b2~SYfsDZvzj0878908789euoutp02H for ; Sat, 28 Oct 2023 21:15:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211540euoutp0278b5253efca1de60fcafd06ae00ca1b2~SYfsDZvzj0878908789euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527740; bh=JNoJR/Xq7klfzP9hsOQ2xMnfdiLvLMoR5LEBEoVDOGw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Mm7/kBdisYvKed+Ygjkzhy9JoYAi4fful3cwN1vo9Q93LupZh5jo6Qx+rmZQKHVPd DyzqzIDTQ4ta+ecdzC7gF4ZhT3ywHxbN9VgChrJTvJA8ynYNXCPcGdwAnG6/90wRR5 OB4t5WBqrOK4IkC+G7LWapdYxKCBFI2bfx6akZgc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211539eucas1p244eaee8bc62c90f79ee02e581ed59c80~SYfrfIuDH1224812248eucas1p22; Sat, 28 Oct 2023 21:15:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C0.20.11320.BF97D356; Sat, 28 Oct 2023 22:15:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011~SYfqobMTB1181011810eucas1p1C; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211538eusmtrp241d650d122083e72da8aaaa16e6632fb~SYfqnuS2Q1141411414eusmtrp2Z; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-82-653d79fb8a21 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0C.F0.25043.AF97D356; Sat, 28 Oct 2023 22:15:38 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eusmtip1460431297fe820fa6ae8f8fd8d552ed5~SYfqdcDZX0467404674eusmtip1I; Sat, 28 Oct 2023 21:15:38 +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; Sat, 28 Oct 2023 22:15:38 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:37 +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: [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Thread-Topic: [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Thread-Index: AQHaCePl1pHcrPV2xkWSZMmpwVjy+w== Date: Sat, 28 Oct 2023 21:15:37 +0000 Message-ID: <20231028211518.3424020-3-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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: H4sIAAAAAAAAA02SbUxSYRTHe+By75Wi3cTyKTUbWS0sspZ1IzPbWvGl5Zq9zLUZixs5ERlI 7y9mNdMPVlamQKFmmkU5yJQUXMNZovbinNNMJZLMwZqZZC+aFlxrfvudc57z///P9uDMQDtr AZ4sT6eUcrGMh7KR6uc/X60cO76JiqrvDyd1lQaUfNB7GSXbXbPJj19zEdLaHUlarHaEbK/V oWSfYZJF1o6bMbLrykdAln0bwsg6YwlKjv3QoXEckTajDREVmdSix/f4ovaXapHpfjYqMn3N w0RNBWOIaMS0MB5PZMdIKFnyEUq5KvYA+7DW0sBQfF52bDxfmAH0i3JAAA6JtbCpeBDkADYe SNwDsHnEgdKFF8Brv51MuhgBsKJ0AMsBuH/ljWcv3S8HsM5pAf8f9Q89m9poBfDN0OiUVgWA DfZR4HNEieWw3m7CfIMgQsuCDXcu+QdM4gw0DGgQH3OJeNiiuYv6OIjYDRtvtTJoFsCOARfm Y4RYAr3N3f5MHGIjPNdzxtcOIGKgY7TGvwqIMPih4hdGywfDbpeeQV89B5ZoLUya58GJWidK 8wr4stMFaI6CT+7WIzTz4Pil4qmYAth14zpKcyQsK/b4dTh/Ne2FLsR3FyQy2dBaVTplthW2 jbpZNHOh+0UVRnMonHyqZ1wBkZpp+TTTPDTTPDTTPIoAch8EU2pVqpRSrZFTRwUqcapKLZcK DqalmsDf39Yy8cJrBuXuYYENMHBgAxBn8oI4zC0xVCBHIj5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pWchWTcLScssJC2zkLQs YGRZxSiSWlqcm55bbKRXnJhbXJqXrpecn7uJEZiath37uWUH48pXH/UOMTJxMB5ilOBgVhLh ZXa0SRXiTUmsrEotyo8vKs1JLT7EaAoMoYnMUqLJ+cDkmFcSb2hmYGpoYmZpYGppZqwkzutZ 0JEoJJCeWJKanZpakFoE08fEwSnVwOR56tOqI322ddo/H6305LugNa/mya2Hyxc0Oi3gEFdW UZ7jt1j8W86BIpYct9pKs70zLRRfv1ZmvbvC2O5pkmjS07f/Hjw3vyMR4yz34L5E/rfHL0OV V63h/r9YtbzMbaXg0gkvN3g8e/xo04I7nQHsnJ+UH/Hd8uZMeN5pEevvt2/hm2o1o1nqc+sU pzidqp2xRsrWPVXnxBxD3ztRS4+euZXkEnrUPurpY07DJyIdfT6Sr76yX5q3IuP2g/Vci8sP Oq1JO6l0IMn21pXIqJZInytlrme27NPXfuiz9tDZ99MW/zsYY17ZM+NHotDxuOUxeZvPPWA5 +77ONrfFXWXjqZ/He39Oq3t8SXDefKNJSizFGYmGWsxFxYkAFE7R3dYDAAA= X-CMS-MailID: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 X-Msg-Generator: CA X-RootMTR: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 83D98120002 X-Stat-Signature: 9g84mghzycn5gfz7qeugms66y8qnzfcm X-Rspam-User: X-HE-Tag: 1698527742-572657 X-HE-Meta: U2FsdGVkX18kAmPIkz9dfpC1HvAHU6Gk0pMwy1NcLNj35u3MJM6Sc4vPHAZWa1sMpBufcPBYhLHl6joSoT52sFxyoyKG61kFV0XdDpcN4ppTsw5Fhy93BiujzTJwI0uYYyRtb7xcgd/q1uK+G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ofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Luis Chamberlain The multi index selftests are great but they don't replicate how we deal with the page cache exactly, which makes it a bit hard to follow as the page cache uses the advanced API. Add tests which use the advanced API, mimicking what we do in the page cache, while at it, extend the example to do what is needed for min order support. Signed-off-by: Luis Chamberlain Tested-by: Daniel Gomez --- lib/test_xarray.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 6c22588963bc..22a687e33dc5 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -694,6 +694,139 @@ static noinline void check_multi_store(struct xarray *xa) #endif } +#ifdef CONFIG_XARRAY_MULTI +static noinline void check_xa_multi_store_adv_add(struct xarray *xa, + unsigned long index, + unsigned int order, + void *p) +{ + XA_STATE(xas, xa, index); + + xas_set_order(&xas, index, order); + + do { + xas_lock_irq(&xas); + + xas_store(&xas, p); + XA_BUG_ON(xa, xas_error(&xas)); + XA_BUG_ON(xa, xa_load(xa, index) != p); + + xas_unlock_irq(&xas); + } while (xas_nomem(&xas, GFP_KERNEL)); + + XA_BUG_ON(xa, xas_error(&xas)); +} + +static noinline void check_xa_multi_store_adv_delete(struct xarray *xa, + unsigned long index, + unsigned int order) +{ + unsigned int nrpages = 1UL << order; + unsigned long base = round_down(index, nrpages); + XA_STATE(xas, xa, base); + + xas_set_order(&xas, base, order); + xas_store(&xas, NULL); + xas_init_marks(&xas); +} + +static unsigned long some_val = 0xdeadbeef; +static unsigned long some_val_2 = 0xdeaddead; + +/* mimics the page cache */ +static noinline void check_xa_multi_store_adv(struct xarray *xa, + unsigned long pos, + unsigned int order) +{ + unsigned int nrpages = 1UL << order; + unsigned long index, base, next_index, next_next_index; + unsigned int i; + + index = pos >> PAGE_SHIFT; + base = round_down(index, nrpages); + next_index = round_down(base + nrpages, nrpages); + next_next_index = round_down(next_index + nrpages, nrpages); + + check_xa_multi_store_adv_add(xa, base, order, &some_val); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != &some_val); + + XA_BUG_ON(xa, xa_load(xa, next_index) != NULL); + + /* Use order 0 for the next item */ + check_xa_multi_store_adv_add(xa, next_index, 0, &some_val_2); + XA_BUG_ON(xa, xa_load(xa, next_index) != &some_val_2); + + /* Remove the next item */ + check_xa_multi_store_adv_delete(xa, next_index, 0); + + /* Now use order for a new pointer */ + check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != &some_val_2); + + check_xa_multi_store_adv_delete(xa, next_index, order); + check_xa_multi_store_adv_delete(xa, base, order); + XA_BUG_ON(xa, !xa_empty(xa)); + + /* starting fresh again */ + + /* let's test some holes now */ + + /* hole at base and next_next */ + check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != &some_val_2); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) != NULL); + + check_xa_multi_store_adv_delete(xa, next_index, order); + XA_BUG_ON(xa, !xa_empty(xa)); + + /* hole at base and next */ + + check_xa_multi_store_adv_add(xa, next_next_index, order, &some_val_2); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) != &some_val_2); + + check_xa_multi_store_adv_delete(xa, next_next_index, order); + XA_BUG_ON(xa, !xa_empty(xa)); +} +#endif + +static noinline void check_multi_store_advanced(struct xarray *xa) +{ +#ifdef CONFIG_XARRAY_MULTI + unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1; + unsigned long end = ULONG_MAX/2; + unsigned long pos, i; + + /* + * About 117 million tests below. + */ + for (pos = 7; pos < end; pos = (pos * pos) + 564) { + for (i = 0; i < max_order; i++) { + check_xa_multi_store_adv(xa, pos, i); + check_xa_multi_store_adv(xa, pos + 157, i); + } + } +#endif +} + static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base) { int i; @@ -1825,6 +1958,7 @@ static int xarray_checks(void) check_reserve(&array); check_reserve(&xa0); check_multi_store(&array); + check_multi_store_advanced(&array); check_get_order(&array); check_xa_alloc(); check_find(&array); From patchwork Sat Oct 28 21:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439575 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 900ABC4332F for ; Sat, 28 Oct 2023 21:15:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 670256B0311; Sat, 28 Oct 2023 17:15:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9486B0317; Sat, 28 Oct 2023 17:15:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44AED6B0313; Sat, 28 Oct 2023 17:15:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2E7B06B0311 for ; Sat, 28 Oct 2023 17:15:46 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 05C0240285 for ; Sat, 28 Oct 2023 21:15:46 +0000 (UTC) X-FDA: 81396127092.28.8BF89A2 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf11.hostedemail.com (Postfix) with ESMTP id 1478440002 for ; Sat, 28 Oct 2023 21:15:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=p25vRFik; 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; 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=1698527743; 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=KNdASYDMYBghyPawUeQa4sXu1VB/4Vbh5nAWx6WaBVc=; b=vQ6zMcmpImJubPBbS7R+x/Z9o2oyM+g6uqexB40G7EKI9jf++0VW55Dd/xHWVU+kd8yzad Edrn0Dztmf+LU+oabgkEbMvQNw+fYM4k7qloN3u+wZpu4IRUuIwtRq2OEq6WmAeeDo+kV7 SnYZJyrfqfDcMbSudH7GMYPwqB0khLI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=p25vRFik; 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; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698527743; a=rsa-sha256; cv=none; b=3P8JH9tyxMlRV50DFeQ8Rrkg+fPkZsHToH1fZVX4q1Krm+P3Jn6Vpzp1E4pfk2eaHXSOz+ GvCxgLdUB+MOxxVEVXtK12J8ccxu6xHj2KVyBQMLUgpIBzD0VmgQb3FqcDaDcGR5lFfV3N scSOtg1l7MOKU5fQ6WT8EQVfij62gpE= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211541euoutp01261a2dfa3dbc804e15f033bd645f2a08~SYftopvc32292822928euoutp01S for ; Sat, 28 Oct 2023 21:15:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211541euoutp01261a2dfa3dbc804e15f033bd645f2a08~SYftopvc32292822928euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527741; bh=KNdASYDMYBghyPawUeQa4sXu1VB/4Vbh5nAWx6WaBVc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=p25vRFikG8/u08B+ePf6VvgHwV8NxkrJZH/Gsn8m+A4lT/HMsDTVuZiosdX3Q/nYP 4pTukVv2uwz4EsY7oichDyeSqZ7xpFNFT2zF1JcaGs7iKcTK7FxWMMW++fF5boQcA6 LYREJzDKHJlJFelI5RdkTvhHCEVS+bsyGNhQaI6M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211541eucas1p2956f217a1965e3854c430386af01e412~SYfs9xZLz1224812248eucas1p24; Sat, 28 Oct 2023 21:15:41 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2B.81.42423.DF97D356; Sat, 28 Oct 2023 22:15:41 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211540eucas1p1fe328f4dadd3645c2c086055efc872ad~SYfslkcX60616106161eucas1p1P; Sat, 28 Oct 2023 21:15:40 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211540eusmtrp2885c51cf5903a19a29a6bef124f4dabc~SYfslCIHP1141411414eusmtrp2a; Sat, 28 Oct 2023 21:15:40 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-be-653d79fdc682 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EC.F0.25043.CF97D356; Sat, 28 Oct 2023 22:15:40 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231028211540eusmtip266e8e32a92786e265d14e5903bc6464c~SYfsYR64B1182011820eusmtip2o; Sat, 28 Oct 2023 21:15:40 +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; Sat, 28 Oct 2023 22:15:40 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:39 +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: [RFC PATCH 03/11] shmem: drop BLOCKS_PER_PAGE macro Thread-Topic: [RFC PATCH 03/11] shmem: drop BLOCKS_PER_PAGE macro Thread-Index: AQHaCePme5B6ldUfmUi6e3JGjkM9rA== Date: Sat, 28 Oct 2023 21:15:39 +0000 Message-ID: <20231028211518.3424020-4-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrOKsWRmVeSWpSXmKPExsWy7djP87p/K21TDU7tYLeYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/gEpvTHjKaLHs63t2i90bF7FZ/P4x h82B12N2w0UWjwWbSj02r9DyuHy21GPTqk42j02fJrF7nJjxm8Xj8ya5AI4oLpuU1JzMstQi fbsErowT+zkLfrJWnJw+kamB8RtLFyMnh4SAicSLF4/YQWwhgRWMEvuOpXYxcgHZXxglrh6Z xwbhfGaUWPPoGzNMR8uvfVCJ5YwSNxa1s8JVNRyYwQ7hnGGUuPLxKNTglYwS8x5EgNhsApoS +05uAisSEZjNKnF4cQcjSIJZoE5izbNZQFdxcAgL2Egc3GYGEhYRcJR4en4RO4StJ/H15A8m EJtFQFXi99yVTCDlvALWEpPXSoCEOYE673/bzgZiMwrISjxa+YsdYrq4xK0n85kgPhCUWDR7 D9Q3YhL/dj1kg7B1JM5ef8IIYRtIbF26DxpGShJ/OhZCXakncWPqFDYIW1ti2cLXYHN4gWae nPmEBeQtCYF/nBINa+9CNbtIXFn1BMoWlnh1fAs7hC0j8X/nfKYJjNqzkNw3C8mOWUh2zEKy YwEjyypG8dTS4tz01GLDvNRyveLE3OLSvHS95PzcTYzAtHb63/FPOxjnvvqod4iRiYPxEKME B7OSCC+zo02qEG9KYmVValF+fFFpTmrxIUZpDhYlcV7VFPlUIYH0xJLU7NTUgtQimCwTB6dU A5P9jDmlq4+837ha/eB1m4PF6iKbuHkWFNexrXP3Z8wtsTeSKZ+/zU5SSqfFdu7qRvdwR7M0 M6OYuxlPlOVe+T19+2QhR07OKw5urZUKNktXp/y96zb1sljVDH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DEwNTcwsDUwtzYyVxHk9 CzoShQTSE0tSs1NTC1KLYPqYODilGpjanh3aXWR/1vyIa8aCFQWvODaEeT03c1qTtiH4vPMW rjtHjl1Q/ldeGmXc+3enwCFH38jZUfM1BFJvejecLP7woI+FWZqjMCH1S2PZNlZpL7c+jud+ JpW+vdveB4S7Np4tauIp40kpZJocnR/Gd8laT2itR6Ob/UEtgcveSV2LTmd9MM4NMOJ2DwnN CZ6dPVFXbMEp9RmvhGKCPBu6/0x0Dc80TdZPbXiqGbJ7vc5bG5/nMfr6+7vfZzYs9xIwFAxQ nbFtc85Mw6+Hbl4W5G8oXPxrfvDhreF1/oFnfod13DmZuW+l5Ld57JW6OnOOvPvWppnGlhvA HRHjuCWzvHsOR/6/1p1RUSnmO3cosRRnJBpqMRcVJwIAW8mX/9YDAAA= X-CMS-MailID: 20231028211540eucas1p1fe328f4dadd3645c2c086055efc872ad X-Msg-Generator: CA X-RootMTR: 20231028211540eucas1p1fe328f4dadd3645c2c086055efc872ad X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211540eucas1p1fe328f4dadd3645c2c086055efc872ad References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 1478440002 X-Rspam-User: X-Stat-Signature: ic3erutxgk5mokphpmd4c7ytq8fobubr X-Rspamd-Server: rspam01 X-HE-Tag: 1698527742-875147 X-HE-Meta: U2FsdGVkX1/maJ8GOuCuU4/woN/35i1mrOb8VOuXPOYVFpyGycQ6dXcU68toOcb5GIliiPqWZZ/3Q46vpktKTTdwDGfOl4Cjk90S/e9roCTJl7bDBSe/bhI7frnWIHobKlf6qUFenZ1I/G2DkZ8kUyMpli81a/T+cEIqyClBouSglNLZftWmrLOee2kWUK0MD+qOy6wNFpdEN/J1tkDnvrg/WIH1B5DFpJ/Z05rDbY6Yc03Pg+A+Nt5rUjJ0MryPodtBxlpYKHt24tIpL8GDwUq5e68bHSqNXkBi4YbKv8mplH78GXPiF05+WMOLL591it7REztcQo8gAsN2SqPCrh7ZBeplFDw7kU5LAttPlIow42ER8BIR9orfm/fR8A5vCRtIAdZVH+UrsLqBxF1LAZA5A8FPdEQAdD5pW5lW4HrWTCnZL4ng7sjFzRHYY6+r0DkqTC0HEAQlVnWVBf86xBRE2VEU9NFkVAaheuBFgimRIyobF8p9QMbjFoeSfhCGOmbRYdmZbhI+SS6iR93RJ5XCLIh5kAWnwBYatLChiqhtexBI5QP9Dq3GKCwIzUGPhP5PnuUvUu57rr+T6iEPMkEpLHD2EG2+VgIdd+6XD6kxJgcSBZ8rH/uJBP3aj+j92b9XqOKVgJEca9qpjLTW0GMGpcTwjoKArR8E3EFhUgn7EmOyAy3f9oQ5ht8iqlgp64AwJp0z2ftbFfF+2Y6/aHGIY4I1Ckdl4vyKAUuQ5MpEhFa5jceH4CIUbS9z/eeLYdnI+CbbBb6AyqWVFkzD6Kx/x35qjhRNK2env7uCbMlQfUSypbJR8hkqbyV0BHIiyUBF830KGNYIswc6bcPkgkYYIGGN5lOaardpCTGYR0RZJ2dy7/oo4tR1EbKPZiLoNP5gxJD5+uPG6JQoegeeqKDoPmkrnnnf8Z1AXtJVkoP2pHDIjlAKp0ZJlakZzU8tCpkW8IqMXNLKcTGHYbM GvbWpyTB 9AcgGBPxmseU+vUx3vhqT/XMLQXulcvjg/rhi3YOZplGmbGeVRTExIZ1rMpVK0R3slbrhUh6xKDq8giWezb4QCN6sHnr5CsBZLhTxjj8Y6UWVs7754N+eI1dyeQ73zGGkHs9Jr5cea7IMeV/v6tvIFeCBHnvaFZtOhTA7e6qIa72AKvKWUNg6KQL8XFbxzn3Wb/u5ZOUwMPNxvXw= 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: List-Subscribe: List-Unsubscribe: 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 0d1ce70bce38..a2ac425b97ea 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -84,7 +84,6 @@ static struct vfsmount *shm_mnt __ro_after_init; #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 Sat Oct 28 21:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439577 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 2A2FAC04A95 for ; Sat, 28 Oct 2023 21:15:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 252B76B0313; Sat, 28 Oct 2023 17:15:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D9256B0317; Sat, 28 Oct 2023 17:15:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 004416B031B; Sat, 28 Oct 2023 17:15:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DA8136B0313 for ; Sat, 28 Oct 2023 17:15:47 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BDA21A038E for ; Sat, 28 Oct 2023 21:15:47 +0000 (UTC) X-FDA: 81396127134.18.1F4797D Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf10.hostedemail.com (Postfix) with ESMTP id CF885C0003 for ; Sat, 28 Oct 2023 21:15:44 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=VYigV6I+; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf10.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=1698527745; 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=8ofABjUQrTp1kzdTCcGf7BUaZhuxx/1pi/TdtpYF5D0=; b=bp0ClbJtrNGOqIhv8FS8oYjgxVmz/3HOoidPzNgYIeg00th2hj/a/XAEVjkqGrkEeL05ob Tiq8o7mkXCsI3+0OiJaXxQOA8uR9O7TqAyd40Xiw1+PjnNFp7gsB+152TW3PMTuINi0gPO 3DRwohrhRI4iYqeIBHseX+vW97U2hnc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=VYigV6I+; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf10.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=1698527745; a=rsa-sha256; cv=none; b=nK5OPMLlqz2NK+8yMksDoVLfQKuURkwwzqZWVvqRe9rlm5832Hx+bySCXADiuHh3bZ2bjh p2uDwsj7WdKYHFqDpAZqeYpqeJpTmYe0r+rqQfW301/Iuyr+nSxTm9kHjwqSpRsV+LtLPk 9plcniyhtzGcF4P4ICJIC9fh506jrew= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211543euoutp02d8a62e552e322107cf5216f0d52ee92c~SYfu7t1aY0890208902euoutp02C for ; Sat, 28 Oct 2023 21:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211543euoutp02d8a62e552e322107cf5216f0d52ee92c~SYfu7t1aY0890208902euoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527743; bh=8ofABjUQrTp1kzdTCcGf7BUaZhuxx/1pi/TdtpYF5D0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=VYigV6I+Xlg2f6kz+xnces7qO2f0nE5tR01Ol4rTD112qHEJhBXjL2IHc3c+wZLc0 4J5CPLxTCXq6Ef4vaHJ1aZ336J5ZiBJuzTVHj3DUHIMh8LafS+j7OlzIeMZQm0qVAT WE449o7Hrm2ASSKGptRHfU9DYe+D1wjPkqA1i5Rs= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211542eucas1p241e7ab5f2da4fdfc2cba9e250271dcbc~SYfuALImE1087910879eucas1p2E; Sat, 28 Oct 2023 21:15:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A1.20.11320.EF97D356; Sat, 28 Oct 2023 22:15:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231028211541eucas1p26663bd957cb449c7346b9dd00e33a20f~SYftgbGJH1224812248eucas1p26; Sat, 28 Oct 2023 21:15:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231028211541eusmtrp14898d07da8c7cf9ca684d016181d49c0~SYftf57WW0755507555eusmtrp1Z; Sat, 28 Oct 2023 21:15:41 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-85-653d79fec53a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D1.52.10549.DF97D356; Sat, 28 Oct 2023 22:15:41 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211541eusmtip17d9fe4ecde792d45fb6ab59803d2f652~SYftVSUg60467404674eusmtip1K; Sat, 28 Oct 2023 21:15:41 +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; Sat, 28 Oct 2023 22:15:41 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:40 +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: [RFC PATCH 04/11] shmem: return number of pages beeing freed in shmem_free_swap Thread-Topic: [RFC PATCH 04/11] shmem: return number of pages beeing freed in shmem_free_swap Thread-Index: AQHaCePnyXBbRf49wEefJYEMRSVIWA== Date: Sat, 28 Oct 2023 21:15:40 +0000 Message-ID: <20231028211518.3424020-5-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrFKsWRmVeSWpSXmKPExsWy7djPc7r/Km1TDU6/4LCYs34Nm8Xqu/1s Fpef8Fk8/dTHYrH3lrbFnr0nWSwu75rDZnFvzX9Wi11/drBb3JjwlNFi2df37Ba7Ny5is/j9 Yw6bA6/H7IaLLB4LNpV6bF6h5XH5bKnHplWdbB6bPk1i9zgx4zeLx+dNcgEcUVw2Kak5mWWp Rfp2CVwZmze/Zir4K1xxbvFp1gbGh/xdjJwcEgImEjNnnmTtYuTiEBJYwShxbN8yJgjnC6PE h1mfoTKfGSUmXdjKBNNyZvNrqMRyRoknKy4iVC39coAZpEpI4AyjxNmz6hCJlYwSDybfAWtn E9CU2HdyEztIQkRgNqvE4cUdjCAJZoE6iTXPZrGA2MICURJLv58DmyQiEC8x48x+oGYOIFtP 4tRCHZAwi4CqxPdTm8BKeAWsJe5sW8AKYnMK2Ejc/7adDcRmFJCVeLTyFzvEeHGJW0/mQ70g KLFo9h5mCFtM4t+uh2wQto7E2etPGCFsA4mtS/exQNhKEn86FkKdqSdxY+oUNghbW2LZwtdQ NwhKnJz5hAXkLwmBJi6J/ml/WCGaXSRWXTrNDmELS7w6vgXKlpE4PbmHZQKj9iwk981CsmMW kh2zkOxYwMiyilE8tbQ4Nz212CgvtVyvODG3uDQvXS85P3cTIzC5nf53/MsOxuWvPuodYmTi YDzEKMHBrCTCy+xokyrEm5JYWZValB9fVJqTWnyIUZqDRUmcVzVFPlVIID2xJDU7NbUgtQgm y8TBKdXA5LH5/BK/2XEvS0rDH+p7a7B1C6yv5pZ8Hrog9fpHIc7Xjh3THu8JEH6/46rF+0/P 5mefTb6oK9z4ecvG5UkRh+4rPDjgsbi8KLD//7rop+uf/D6qcVXAY33SL0aBpEXfze4yz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zNjJXFe z4KORCGB9MSS1OzU1ILUIpg+Jg5OqQYmmfIPt4terD4tu9SmM9LA3Cl3+rl9SbIbAh19csok tTdrHQteNC8mwjyl+P6tJ4k7qlqZDJr1NVZr9BpOTLjBZH7d5fsBuftTpyqfOb2shdHht5SG epxciZ3IgeYjy/arTw9P/KnP6X7P4siBiOmnTGbZJ+1Lf5qZsXyyQ0v7uf/rxW7yGvjcPJLJ fKPhVLJB6AkOF4udC38f+i2vXs8R63PiQUOSqO/G5hNfeC55v05f5/yIxelO0gQ7ncoivYe2 QdOKOA6c5nj7m9FW57D0h8/XmfNub3GU5r+sVqZ49rt4lbXhhhMdbSvOqj3N330w1vbT/trU /+EGZfWKps5m5+wP2Kdt0K769dNqyx8lluKMREMt5qLiRAAYunQX1gMAAA== X-CMS-MailID: 20231028211541eucas1p26663bd957cb449c7346b9dd00e33a20f X-Msg-Generator: CA X-RootMTR: 20231028211541eucas1p26663bd957cb449c7346b9dd00e33a20f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211541eucas1p26663bd957cb449c7346b9dd00e33a20f References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: CF885C0003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: u9h4w94dw6sgz1f9yhrddkcyj4mzd15q X-HE-Tag: 1698527744-156409 X-HE-Meta: U2FsdGVkX1+sG+SvmbYvlemLkofR5BUMnJ6b9HnDDcGMOz21RElH+MY/p6fhXV9Zn/WbHJLheq8AW8Kz3zZl1KFl0rWduLouKRMdHqB7YPJBRpucfaJx+xkQvls0KN5xCJYV5Qak4kRbRViKC7CXGnVq8c7K67wS+TXdlOcqQ+Ca42d/Y/CTLOHdXRihqiosJb8uRkf5kyhyBYn9WNEqdV6N3x+8SU/Ehs6wQAOgsCu1pbrQiLDCoWHlWd/18X1W/DKcQg+feF7d9fysg2UuyisJPww2nkLDCxUxL0q0Bk3bF8C9V/UVukp3fYvska6apluxp11JNCz+lF7DQzwSF6xBal1CImzKq+FVQuD/bAwD2GvPbGlmB5MOm+MzPkuULIYeHJBiqHleUUGOf58FOMViCZ/Zg5y1KTYD2EIbIazmFIHdvXyQj24yc8wLD/Hn+xSD5OdthkXvrMXDYybukQrjY6LXpQ1BwY3vlHwaBUVarZFe9DwiaTuSXtjSnvxS8LEZsO9AjQqPcss9KivuPAo0M+LchWaRhvIJ1+zKQ7queyoXNGEqgUbIDVt2Q5x1sMtjvC5/dtRvpXPqTbawvG2uD3NPs/ToN5wx2hghhmS7A2mfk4SleyBokSdKmzC1jb8fVm3MkqRpFyUmYrDpHzIZoQZkCCWYlS18XL5p3wCdyGOLzxangRj0+YTJzkVDj8IDmHe7tdddV778AuWGWP5sQjKfHpI+KCB/OBCZlI3P0EKrpgKxGK7iI9ma4Hoa/fWWg7Cyqv4fFTY6BBmWVcILGvGhwx1OAhsMAMAng8KnZ1DivQGw6IMD25Qf6jl0QhgxUUxb/8XMhYkQ21bEaX1yK7OfLMdJh8+LU3QhfAnRIqGQ9hiJWeD9zelHoSu0Bqi6Eot9r6OQNaIXAQKfS1R9Qm3ciyCJPZXDzPCdycz8jZ7I5h/e4sDMU1OaG7PjiGecoJxSUTGWMayzxJw P8JPo0L0 NSPWjUxVdvSL99DImQpGINQbag00WO3Njtj//9k+6XK1Ca70dRl77uPsWi0xXCWenv/INTrx9hTUnceZJwjY8Vo3nx5SitYlRPK3llwt4fULKdQrRojpKJZOwjyZ5hkodCZTn6w6hdPAeF8isBvPyKj3tFHF9ZNM7WBppi+8AVN1U8e0lTYWQN+urZaA/wCv/gZ1eYSZDUhgL3rASr4m8zrmtaQ== 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: List-Subscribe: List-Unsubscribe: Both shmem_free_swap callers expect the number of pages being freed. In the large folios context, this needs to support larger values other than 0 (used as 1 page being freed) and -ENOENT (used as 0 pages being freed). In preparation for large folios adoption, make shmem_free_swap routine return the number of pages being freed. So, returning 0 in this context, means 0 pages being freed. Suggested-by: Matthew Wilcox Signed-off-by: Daniel Gomez Reviewed-by: Luis Chamberlain --- mm/shmem.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index a2ac425b97ea..9f4c9b9286e5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -827,18 +827,22 @@ 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. + * Remove swap entry from page cache, free the swap and its page cache. Returns + * the number of pages being freed. 0 means entry not found in XArray (0 pages + * being freed). */ -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; + long swaps_freed = 1UL << xa_get_order(&mapping->i_pages, index); 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 swaps_freed; } /* @@ -990,7 +994,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; } @@ -1057,14 +1061,17 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, folio = fbatch.folios[i]; if (xa_is_value(folio)) { + long swaps_freed; + if (unfalloc) continue; - if (shmem_free_swap(mapping, indices[i], folio)) { + swaps_freed = shmem_free_swap(mapping, indices[i], folio); + if (!swaps_freed) { /* Swap was replaced by page: retry */ index = indices[i]; break; } - nr_swaps_freed++; + nr_swaps_freed += swaps_freed; continue; } From patchwork Sat Oct 28 21:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439576 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 17125C0018A for ; Sat, 28 Oct 2023 21:15:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13ECC6B0317; Sat, 28 Oct 2023 17:15:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C8166B031B; Sat, 28 Oct 2023 17:15:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D97916B031E; Sat, 28 Oct 2023 17:15:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BE9BC6B0317 for ; Sat, 28 Oct 2023 17:15:49 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99BAC1603E2 for ; Sat, 28 Oct 2023 21:15:49 +0000 (UTC) X-FDA: 81396127218.04.D54575D Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf05.hostedemail.com (Postfix) with ESMTP id A80AE10000A for ; Sat, 28 Oct 2023 21:15:46 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=d0BEWt0N; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.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=1698527746; 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=/CvASZfCabc/Ew9WG/OE+/8Wt2GCjn+VDx2yMe2ZiFk=; b=qFiJ+c+VDeOkE5kSUyoH+1UInDEqEczJNivKTWHgRaFM9uHas1mv2dbbZzAJwP+n2fLEMj buL7HHg9FqDRrE6BfwImaXrX/y0/ekDl0GwrvCjAWBnYYvEcdbrfogfnoVKZeTzFyKvW0Q EkOvm6/F0ud4Y32sXswqWbmXuIo3rVc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=d0BEWt0N; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.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=1698527746; a=rsa-sha256; cv=none; b=pWzfyfTG59bpxmx19ZIIozIXIhJip1+FIEnOvrHOaAN8+jG3eE1ZTq6lVdn0U8itABof6S D5Zu9fNgrhMhE3eAz92ti5+v0O0BOzVihgKpPnl9dTCIFkhKOocsphws/+xFpfsCbFNf4f c+Ne1C7iPJWzxfY3e95aT1FdhDRV+Og= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211545euoutp012ad5eba8cbeb8f04ded11836d7ae4761~SYfwvhHRd2663226632euoutp01C for ; Sat, 28 Oct 2023 21:15:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211545euoutp012ad5eba8cbeb8f04ded11836d7ae4761~SYfwvhHRd2663226632euoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527745; bh=/CvASZfCabc/Ew9WG/OE+/8Wt2GCjn+VDx2yMe2ZiFk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=d0BEWt0NRJ+q9fKwIT9WCJmLwnptxbJk8cHMt4E1+uBYIQAsZ8HmB0fV81C9HGMNh eplHCmHGAfK9UKuEM3ZkMU9SC9sskXWwIUvxl9OaeWtjnzZO7Uztce5QNGgW6Ll1S3 V0XCcJJ7oPcp//iGDSuKTptzJTpA26oYwVacTJPc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211544eucas1p2dd80d12755f4916b3ddb921b0f269b68~SYfwUtLgi1224812248eucas1p27; Sat, 28 Oct 2023 21:15:44 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FB.57.37758.00A7D356; Sat, 28 Oct 2023 22:15:44 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231028211543eucas1p2c980dda91fdccaa0b5af3734c357b2f7~SYfvYfPTw1090610906eucas1p2I; Sat, 28 Oct 2023 21:15:43 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211543eusmtrp23d56e547237e332334313cc821183188~SYfvX96w-1141411414eusmtrp2c; Sat, 28 Oct 2023 21:15:43 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-ff-653d7a00f0a9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DD.F0.25043.FF97D356; Sat, 28 Oct 2023 22:15:43 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211543eusmtip1c2729878b21b7ae72b87f193ecb7dc7d~SYfvKXDWf0467404674eusmtip1M; Sat, 28 Oct 2023 21:15:43 +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; Sat, 28 Oct 2023 22:15:42 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:42 +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: [RFC PATCH 05/11] shmem: account for large order folios Thread-Topic: [RFC PATCH 05/11] shmem: account for large order folios Thread-Index: AQHaCePog3tlS7SbBUi1hq/vgcoYwQ== Date: Sat, 28 Oct 2023 21:15:42 +0000 Message-ID: <20231028211518.3424020-6-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrOKsWRmVeSWpSXmKPExsWy7djPc7oMVbapBvtfaVrMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6Mm39bmAveSFRMmHSIvYFxn0gXIyeHhICJRNfqZWxdjFwcQgIrGCUeXZjFCuF8Y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EWc1FxIgDmdKNI1gMAAA== X-CMS-MailID: 20231028211543eucas1p2c980dda91fdccaa0b5af3734c357b2f7 X-Msg-Generator: CA X-RootMTR: 20231028211543eucas1p2c980dda91fdccaa0b5af3734c357b2f7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211543eucas1p2c980dda91fdccaa0b5af3734c357b2f7 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A80AE10000A X-Stat-Signature: x8nk944wu7dn4bcz716ci8q7jyw4ankz X-Rspam-User: X-HE-Tag: 1698527746-530764 X-HE-Meta: U2FsdGVkX18YHXHyqKIRuYDdOMyMPKKNZp9IN5Lb/3H/oUxbxlStAj54mOaOXgt0c3j84GxsUZx10fQvv2HrJAFKVMCrIsTBFbXcXE+E0w6LwO271zvl+30CNmtBiOhbuHTXpVTd9Zo609QRkcAoIueo/owm89ig0GG3XXu6yLGoKt/9ijHkJgSoViQFSrRAWqn9PyyO/ETA5zyd8U+32rnT3m74Of/iahQEnJLJcig7vw0ZgNAbra2wWrCSraCxSS1VZCFcdWV350PxmO1Vexeq55q2exSoTNDnG8rroCbQWQZ+J9F0356s9eLY2vyfUZl4+SNcH3IuExbiakUf5pOVrbu/hNQuGzmJ2dUcpPt3mMLOg8HtE2b5tGsO0dX4c60Lgv223E+n1npzgptHgAzZKvhGBH3yABk9fdtPjcJX52EPKAS1NDTbNPLjwIT39jwAFhxC3JBgiBEmH098qJ/tHqa2lmnNSRQ8ch+4bofwi7za+HqbcJqRmEZcWniF3LnuutSgr30dCNIPinFZrc2wXcS3cYVryecBF9IwR3TOU2LN6Y2EKEI6UkDdKx1fEvyFKc36+9DXbgtRkeokxXled5gGQ7PzUVgyQc+Tbjm1bqS1bpMkk5UpmgY8pA6tpoUu2AFD1rwswk2VEmN75Ssve966Ydbq3yqLUoGSUcsKeiowbm3o/K5rI5+1zzBm0XOj8GjX6J8CVnxzxNSqwevB9Y7Xcp1smJAq917696gYrJ9Z5IdhOo96kbIil9mGybXCCIPeMeSP6xnvFVK9dTEDLIsF8ZriAc9jHA/9nCu9DuHsEczpiCwVASypxgK75cnNiF4RceFiItZ5NiJmWGTUqa+N51WfoHPSWjX2JP65sZK17r5pw1mSlyNRrbQ0y+1uAYaTjYQgyIPFjyUeCYGVY/WPQcYNUto0kr+vxRw4L4rVmo8sgr6YYSsTUlJMIw2OmISv/Vqh9FT90rY +d4GZUpn IyWdr+kAGwmf8JXvdUaMrFFDoyTKVwbwXEN0knPWgPi0IIipLA9njgcfbXvyGRoU9kAN1aHqx4uJvKzneSnVd/MkQZY3LQOo5DGL3qc51fxLNxXsRK4W1UPFMC/tDZUfh5HQSlbnoPJRBN/4DUahnimpfMkwad6JWtZKz 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: List-Subscribe: List-Unsubscribe: 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 9f4c9b9286e5..ab31d2880e5d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -856,16 +856,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()) { @@ -1514,7 +1514,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)); @@ -1828,6 +1828,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, @@ -1837,13 +1838,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); } @@ -1928,7 +1930,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); @@ -2684,7 +2686,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 Sat Oct 28 21:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439578 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 A6E7BC4332F for ; Sat, 28 Oct 2023 21:15:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B3CB6B031E; Sat, 28 Oct 2023 17:15:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13DF56B0322; Sat, 28 Oct 2023 17:15:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E850A6B0326; Sat, 28 Oct 2023 17:15:51 -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 CE1466B031E for ; Sat, 28 Oct 2023 17:15:51 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8A6271203CB for ; Sat, 28 Oct 2023 21:15:51 +0000 (UTC) X-FDA: 81396127302.16.D51338B Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf08.hostedemail.com (Postfix) with ESMTP id 9EB4C160018 for ; Sat, 28 Oct 2023 21:15:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=bjGf4PuO; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf08.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=1698527748; 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=cqTk9J1wmzoKfcE/fbVQ1ZhNe/efGCweXy90QEX86kQ=; b=OeuGZF+nteXrw74lTmLmwiH0nRaeJ/MaL0L0ruy8bHN+0Vp+hBtsFr0J9C2r46/uB/hrmv wKxuyImEKiUzgTvzvM03LcFEE6fz5gKz2nneCKat3DEDdiWdMjXDc8wN+pAiGfxd0n0OCk pWLnOKBLSvDAJk1bgfgu1382w7lUSrg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=bjGf4PuO; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf08.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=1698527748; a=rsa-sha256; cv=none; b=7rwlAtY82EHd+MC9foJ6XeDLNNU8wPfnc0w5NaqCnFcgOLqahJ7S6+v87DmhgW88bk1Aiq DkIWoW+Ioc98m3TxSRCjDgEpIy7MuELOc/SxvznDDtoqzfdo9rRSwtUZeu30QTQZGfLrV4 ztC3gxlV3zAs6mt0skPQMeyiQSvWizk= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211546euoutp0208b5f27eb5df0fcbc43b8efcbc5b2535~SYfyWHVBv0879208792euoutp02O for ; Sat, 28 Oct 2023 21:15:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211546euoutp0208b5f27eb5df0fcbc43b8efcbc5b2535~SYfyWHVBv0879208792euoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527746; bh=cqTk9J1wmzoKfcE/fbVQ1ZhNe/efGCweXy90QEX86kQ=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=bjGf4PuODXvBE+WtcNSzL/CGuJ1b5AEEdHtQz7pHlVmrkuMHVuyweXzVQWgG/atL9 wzuPX6jt6lRIWbVhOuxYDQbOfoD02yu1xpSqLVgyQWBUoXM5O3wVGJbtK4WAyHIQxa Hv407t/IChRH42DXr+FKGurxlj6OzW9hDC5hL9E0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211546eucas1p2d9c87ac5195deeb424c6db2ee6b4bba0~SYfyAl9sB1224812248eucas1p2_; Sat, 28 Oct 2023 21:15:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A2.20.11320.20A7D356; Sat, 28 Oct 2023 22:15:46 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231028211545eucas1p2da564864423007a5ab006cdd1ab4d4a1~SYfxbyUZ41087910879eucas1p2I; Sat, 28 Oct 2023 21:15:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211545eusmtrp27f616722d703e49e984feaa6bd1f86ae~SYfxbQh_i1141411414eusmtrp2d; Sat, 28 Oct 2023 21:15:45 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-8b-653d7a029922 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CE.F0.25043.10A7D356; Sat, 28 Oct 2023 22:15:45 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211545eusmtip1ecd5e3b6d81770cd6ea6596dd01bf8b4~SYfxRlEbt0467404674eusmtip1O; Sat, 28 Oct 2023 21:15:45 +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; Sat, 28 Oct 2023 22:15:45 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:44 +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: [RFC PATCH 06/11] shmem: trace shmem_add_to_page_cache folio order Thread-Topic: [RFC PATCH 06/11] shmem: trace shmem_add_to_page_cache folio order Thread-Index: AQHaCePpKnL5pBbYgEe8tpnCRhW3OA== Date: Sat, 28 Oct 2023 21:15:44 +0000 Message-ID: <20231028211518.3424020-7-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7pMVbapBrMfSFnMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MK9tmsxSsFq9Y+vE0ewPjJuEuRk4OCQETifavp1i6GLk4hARWMEpMaP3OBJIQEvjC KPF9ggtE4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d4a1 X-Msg-Generator: CA X-RootMTR: 20231028211545eucas1p2da564864423007a5ab006cdd1ab4d4a1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211545eucas1p2da564864423007a5ab006cdd1ab4d4a1 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 9EB4C160018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 6xtsbizrabsnaxsq7btpw31akfzwuywf X-HE-Tag: 1698527748-807127 X-HE-Meta: U2FsdGVkX19fz+RsohztDuOBlbLeAzZESs2242W8DCPBNL+WSdFebnzWPifwbPXQrt0Z+KcbmjAyUm4Q7l0FhpAaeSDQnqxT7bHGtQz3/EzVg9aRlYvw5/6eMdUmmcNi9K+4eOv4juIBjxzj9APm/uvvlbghwQZUhdsdG3iosW8E9Jcb5UJjXLqTfcutPSNt5P9glfEi5CClJKp3QdnrSpUDFR6eVF8zYHvPIZV/0toFZSuKRrxkAscNxwiOth7XR7ECFURdzm5rF6lUqjTobqxD+na7Yk8LW9puJWoPcNxrKqp542kwafvDUuzGTRjeIqRO3a0nt2dFDHXIdLKWU9DP51zxIHPwxuwJWO/1agiwhaYpgbl5V6jdwT9ENCRFgAXMNKYsHnd+Ea2JVQAnKxgBNWyh2oaSxG/dKCOujJfshOxOpvJYMq7UtzzVf11E9NAgMjHwz9HgDtpUGcEElbDvE9HxsdRdrRCj9C0o4qHTLeCFwS7ipnF6if49l+Q9tCfqy42JRREARnN+lu1sIvj0ipKUPYZ0cF+WlM0zcZ+dxIYuKTdys2Szb5m3dxHIDxc1A0hVEuotraFMmRQtjlXO3CzGczAwLKyQiRLt9CQuK/jg0w2m0Y8MS6To3w1GVZ/e+NCXFSaxpHy6fj6g59n25ynWmJ8pr0T5R62xJlNlcD9oQtT3R9F/P8ys+F7S0J9xtX4uSDMMD08GD3m5c4BBztgI3anPreWiSjnlhyuilMXXLzIGDYzw+2RVol/xecM/6wIOW7gQwRC/vs0ucazIvzDJtzyW7rnVxV/DLjlEE+eg0TgA1bvFl5llAxxoie0Z0nkm+gXWkER9kHywiJkq5dAQzYtaFIb/LwuhHi9TcM09ED9Jwr517V0OT8DqItw8TtlOJrfO4DQJOAuQIu5X/Sc8O50Kwps6aN8vcZ0NZHYz2quwgnwmsdfMA300OX8SXhjNeGksjYO1fdK L0AG+5mH nCFaPAqPB/8c4czyAO5aF+MQKx7s2uXeGtGJbKJps7I8+N2CRDTGT2FW5wMP0qzzrJi6rldmz3AZpEohKB8BgZToinSsXBeLmZYDecm6+kP40l9qQbecgJTQ4Upc8/Vgw1886Gmufe4uaJpY/qjFrwpud/SDbeMzZK1exhD2sjXeco70tqUeqXNoISg243Y0T5XHtZENYN5krEDNyPWQYaCrAsw== 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: List-Subscribe: List-Unsubscribe: To be able to trace and account for order of the folio. Based on include/trace/filemap.h. Update MAINTAINERS file list for SHMEM. Signed-off-by: Daniel Gomez --- MAINTAINERS | 1 + include/trace/events/shmem.h | 52 ++++++++++++++++++++++++++++++++++++ mm/shmem.c | 4 +++ 3 files changed, 57 insertions(+) create mode 100644 include/trace/events/shmem.h diff --git a/MAINTAINERS b/MAINTAINERS index bdc4638b2df5..befa63e7cb28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21923,6 +21923,7 @@ M: Hugh Dickins L: linux-mm@kvack.org S: Maintained F: include/linux/shmem_fs.h +F: include/trace/events/shmem.h F: mm/shmem.c TOMOYO SECURITY MODULE diff --git a/include/trace/events/shmem.h b/include/trace/events/shmem.h new file mode 100644 index 000000000000..223f78f11457 --- /dev/null +++ b/include/trace/events/shmem.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM shmem + +#if !defined(_TRACE_SHMEM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_SHMEM_H + +#include +#include + +DECLARE_EVENT_CLASS(mm_shmem_op_page_cache, + + TP_PROTO(struct folio *folio), + + TP_ARGS(folio), + + TP_STRUCT__entry( + __field(unsigned long, pfn) + __field(unsigned long, i_ino) + __field(unsigned long, index) + __field(dev_t, s_dev) + __field(unsigned char, order) + ), + + TP_fast_assign( + __entry->pfn = folio_pfn(folio); + __entry->i_ino = folio->mapping->host->i_ino; + __entry->index = folio->index; + if (folio->mapping->host->i_sb) + __entry->s_dev = folio->mapping->host->i_sb->s_dev; + else + __entry->s_dev = folio->mapping->host->i_rdev; + __entry->order = folio_order(folio); + ), + + TP_printk("dev %d:%d ino %lx pfn=0x%lx ofs=%lu order=%u", + MAJOR(__entry->s_dev), MINOR(__entry->s_dev), + __entry->i_ino, + __entry->pfn, + __entry->index << PAGE_SHIFT, + __entry->order) +); + +DEFINE_EVENT(mm_shmem_op_page_cache, mm_shmem_add_to_page_cache, + TP_PROTO(struct folio *folio), + TP_ARGS(folio) + ); + +#endif /* _TRACE_SHMEM_H */ + +/* This part must be outside protection */ +#include diff --git a/mm/shmem.c b/mm/shmem.c index ab31d2880e5d..e2893cf2287f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -84,6 +84,9 @@ static struct vfsmount *shm_mnt __ro_after_init; #include "internal.h" +#define CREATE_TRACE_POINTS +#include + #define VM_ACCT(size) (PAGE_ALIGN(size) >> PAGE_SHIFT) /* Pretend that each entry is of this size in directory's i_size */ @@ -1726,6 +1729,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, } } + trace_mm_shmem_add_to_page_cache(folio); shmem_recalc_inode(inode, pages, 0); folio_add_lru(folio); return folio; From patchwork Sat Oct 28 21:15: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: 13439579 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 6D058C0018C for ; Sat, 28 Oct 2023 21:16:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA2576B0322; Sat, 28 Oct 2023 17:15:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B01566B0329; Sat, 28 Oct 2023 17:15:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DF546B032B; Sat, 28 Oct 2023 17:15:54 -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 756EC6B0322 for ; Sat, 28 Oct 2023 17:15:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 56764B5662 for ; Sat, 28 Oct 2023 21:15:54 +0000 (UTC) X-FDA: 81396127428.19.E483331 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf23.hostedemail.com (Postfix) with ESMTP id 64047140006 for ; Sat, 28 Oct 2023 21:15:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="NpS6/cZU"; spf=pass (imf23.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=1698527751; 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=KMahjoHxxEGT5gaBZBeFILgQTlTnM1MpN5QmTOlrbgg=; b=d53VqVzhynyr3OkkTWkho24bHTN7GbKOIfr/kb7haxMhXS2n9G+DEobaiBFP6QSJResTLD caA648vXyGCo/JYavBTpoxUj+R721wB/vge9iHjZ8cJ+/77K+y1jjBb1ZWQPKG7hLfRaTi MZ4auLWLgvDwzh24+CQr0aRlM2cg3zY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="NpS6/cZU"; spf=pass (imf23.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=1698527751; a=rsa-sha256; cv=none; b=hMrD471RhVTEVB0LKttzuFQn3mVRY4Z0IR1r8yNut84bzVLNgT3iW0TOtjy31/zd3ytoTr qhqaUEKHC0qXvdQyLBKKqxE7IyO2/oEF2U03Ta1qEsazhkzyuSlHwK+5QzAzWSHvKScUYh Yav8PexCQ0wnD17OzHX+9U7IkhzAlpY= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211549euoutp01b0b72d8ef2e55402d6eb259fd2fa7220~SYf0toLE03100431004euoutp01U for ; Sat, 28 Oct 2023 21:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211549euoutp01b0b72d8ef2e55402d6eb259fd2fa7220~SYf0toLE03100431004euoutp01U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527749; bh=KMahjoHxxEGT5gaBZBeFILgQTlTnM1MpN5QmTOlrbgg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=NpS6/cZUu5469ui0A5b4Affrh1LC9nZowLTonIS7cPKyDXrNdXVKaiyGJ1TnafE5y 4LZwZlvKcCw+9knXLxqd9tEsMBJwbMd4urVuLB7SzQre8J+EYyRm/gtGPXy8T2oiHE yjjkGvf2Jw+yP7iqeks84/0G685vWSuoHbxoybrU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211549eucas1p2fc824cd9bc602e094c2b9bc40e72187b~SYf0VLXIT1087910879eucas1p2M; Sat, 28 Oct 2023 21:15:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FC.57.37758.40A7D356; Sat, 28 Oct 2023 22:15:48 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231028211546eucas1p2147a423b26a6fa92be7e6c20df429da5~SYfyRbpOf1224812248eucas1p2A; Sat, 28 Oct 2023 21:15:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211546eusmtrp2c9f70e6608c90b52dc9e964b9cdca2d6~SYfyQ6t5Z1141411414eusmtrp2e; Sat, 28 Oct 2023 21:15:46 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-05-653d7a045348 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AF.F0.25043.20A7D356; Sat, 28 Oct 2023 22:15:46 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211546eusmtip1b8f4d77fa5acb0d4af2695620577282c~SYfyEc2tN0467404674eusmtip1Q; Sat, 28 Oct 2023 21:15: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; Sat, 28 Oct 2023 22:15: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; Sat, 28 Oct 2023 22:15:45 +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: [RFC PATCH 07/11] shmem: remove huge arg from shmem_alloc_and_add_folio() Thread-Topic: [RFC PATCH 07/11] shmem: remove huge arg from shmem_alloc_and_add_folio() Thread-Index: AQHaCePqWfxF+qVFe0qg34umJ1pkKA== Date: Sat, 28 Oct 2023 21:15:45 +0000 Message-ID: <20231028211518.3424020-8-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrKKsWRmVeSWpSXmKPExsWy7djPc7osVbapBoenWlrMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6Mh5N2sxcsEqo4/ES4gfENXxcjJ4eEgInE2n3fWEBsIYEVjBKPJ8Z1MXIB2V8YJVbt Oc4I4XxmlHi9qgvI4QDruPuFEyK+nFHi1tclb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F4/MmuQCOKD2bovzSklSF jPziElulaEMLIz1DSws9IxNLPUNj81grI1MlfTublNSczLLUIn27BL2Mh5N2sxcsEqo4/ES4 gfENXxcjB4eEgInE3S+cXYxcHEICSxklpk16y9rFyAkUl5HY+OUqlC0s8edaFxtE0UdGib9/ HzOCJIQEzjBKnH9aDpFYySixb8kksASbgKbEvpOb2EESIgKzWSUOL+4ASzAL1EmseTaLBWS1 sECIxJumIJCwiECkxIS2bkYIW0/ixt95zCAlLAKqEpu6CkHCvALWEv96zrGChIUEciX62zJB wpwCNhL3v21nA7EZBWQlHq38xQ6xSFzi1pP5TBD3C0gs2XOeGcIWlXj5+B/UXzoSZ68/YYSw DSS2Lt3HAmErSfzpWAh1MNA1U6ewQdjaEssWvmaGOEdQ4uTMJywTGKVnIVk3C0nLLCQts5C0 LGBkWcUoklpanJueW2ykV5yYW1yal66XnJ+7iRGYlrYd+7llB+PKVx/1DjEycTAeYpTgYFYS 4WV2tEkV4k1JrKxKLcqPLyrNSS0+xGgKDKGJzFKiyfnAxJhXEm9oZmBqaGJmaWBqaWasJM7r WdCRKCSQnliSmp2aWpBaBNPHxMEp1cBks26VznGhj91Xr5m8ZpLoz6jMnXtSun7dzUbri1qW 397emvzNawZjSlfOxk1PpRNvmU88dWVWedtuOyEdi7rogBLmfxbM196sM01a8GzajgsT3yv6 FC7w2KWf+uDmF2OWsP/lfQ+fJgXn2XS05d/aVZtWf/K8URvX5vuSoa+3ngtZd+oQ66+Enfu0 /B5VqRjJrDnWedNwyRG9CCvWh+EHn39XfmolML3Inff9tR8xW7R0nIOVhc3v7Rf4WVJfrLx1 MeN0dv4Lsda2kc9qzxwN/bTdusf+hZea09sjL2WYNp9vX6PEG6cvt9P5QV//a66Yuc/O/Utm d03/XTU72TEo9pztvSbThUm9S+Yqf01TYinOSDTUYi4qTgQA2WR+ZdQDAAA= X-CMS-MailID: 20231028211546eucas1p2147a423b26a6fa92be7e6c20df429da5 X-Msg-Generator: CA X-RootMTR: 20231028211546eucas1p2147a423b26a6fa92be7e6c20df429da5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211546eucas1p2147a423b26a6fa92be7e6c20df429da5 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 64047140006 X-Rspam-User: X-Stat-Signature: fkyhacbbc4bqij8rdxh1ygdnouk1yhua X-Rspamd-Server: rspam01 X-HE-Tag: 1698527751-12588 X-HE-Meta: U2FsdGVkX1/zC+Z5Wn3K3NMbuJl1zFS2CxE9uyl0kKgrW0kUor1iKXjkMhmiUk7nXq7fD5b7W2E5jpTqBsYpul/dUAW26k1wm90QnDO7cpi2JW7BTSRBqfLmr/c7V4tE/gn5ydl0pumuv0WrVoCUs52SQ9Zy6l+g/s9DW5DlcNfpbh7DLV0SjvNNECLo/SpqvOiaKbiP/Ly+kfz3DMfoSrohdjHswFeedRhOo230OmVpWjvZ3Tog2AxOLiT3HkWAcrtZimKMMLTAkuZetzZWwEfxNijpYMMCmFeog4oCokc5a3EyQ78j6N1UnkaY4FLZ7E1XzuB2oeIcr3tULQoLGZtAJ4E9zpp7ojZuEDl8i4G6NKk/1cOMM/WyWRLtR7zYSm21kARD2h6zcX0d87f5nre4nsevO0OUK8xFGEr6FituSpNa2/gg5HBA6mgS610hHyzlSkJZge/EWYjwvqC62UUsf2gv/gNNuxqlLE2S96qIWzVYRhUXPcBQtTGMC+MQpX9BYGnxB4tMABfSMZfPBG8ydv7MyAElU2MVZmVbhDhUzO7YDOQCub7Jsv5AjbnUysE1P5areIp31C98TiCXV5Ql4HglFYMK2PhCaFMR9ndYFsNMORF3Va8q7hgVJ3ilAfeOm6IX+RFoV8ffUDPokQzUffbOjo2lZ6nrwUZFpn69lulAay7Pf6i8oR85EB6Peiwn1/yzd/6l95qAxQFtcr0vsEyLkaEZOnVZRpvFkrlQV3rkb/T0dIz1BhGVyVcKgqFQJJ8N4RFzrCcVQGRXZewTCz8B3Iyv9PiXgC5HWk6GOSaq41YY+fVw8p1ZQAG0rBw/pelmp9hNEJaTua1SwnglVw1Ef+SVqb+wErLz3hFe0WwkCUz6lIsS33WgnY4GBtyQX4EeTAnnvu5dobNnpuNFnH4zr+zvmGEnVxkLLLx/TKm+J6sI+51+j4R3x+V4+AQYNvEmH+xPno7sXQR x05r13xv 6Df5xpnxQafN633xl178+XhJClGBxNErPUN/NasuWnydDk+Aci1ig+MzPqBVpB7N49U15HK1GJjxigIB7NTNb1KhPvUKUMnltybbTw2fGEAU9w8GSq7W+bJgPfeLb3ml73QdZOrtwPcIeJzBM7YTymzQmEuoIFwNyviEIOJopE1WdnKFeoouQ/lilA2FMclhuCrJDoeYpydyRwkkbrX56xmWaww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The huge flag is already part of of the memory allocation flag (gfp_t). Make use of the VM_HUGEPAGE bit set by vma_thp_gfp_mask() to know if the allocation must be a huge page. Drop CONFIG_TRANSPARENT_HUGEPAGE check in shmem_alloc_and_add_folio() as VM_HUGEPAGE won't be set unless THP config is enabled. Signed-off-by: Daniel Gomez --- mm/shmem.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index e2893cf2287f..9d68211373c4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1644,7 +1644,7 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct inode *inode, pgoff_t index, - struct mm_struct *fault_mm, bool huge) + struct mm_struct *fault_mm) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -1652,10 +1652,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, long pages; int error; - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) - huge = false; - - if (huge) { + if (gfp & VM_HUGEPAGE) { pages = HPAGE_PMD_NR; index = round_down(index, HPAGE_PMD_NR); @@ -1690,7 +1687,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, if (xa_find(&mapping->i_pages, &index, index + pages - 1, XA_PRESENT)) { error = -EEXIST; - } else if (huge) { + } else if (gfp & VM_HUGEPAGE) { count_vm_event(THP_FILE_FALLBACK); count_vm_event(THP_FILE_FALLBACK_CHARGE); } @@ -2054,7 +2051,7 @@ 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_add_folio(huge_gfp, - inode, index, fault_mm, true); + inode, index, fault_mm); if (!IS_ERR(folio)) { count_vm_event(THP_FILE_ALLOC); goto alloced; @@ -2063,7 +2060,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, goto repeat; } - folio = shmem_alloc_and_add_folio(gfp, inode, index, fault_mm, false); + folio = shmem_alloc_and_add_folio(gfp, inode, index, fault_mm); if (IS_ERR(folio)) { error = PTR_ERR(folio); if (error == -EEXIST) From patchwork Sat Oct 28 21:15: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: 13439580 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 EBB0EC4167D for ; Sat, 28 Oct 2023 21:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49CD76B0329; Sat, 28 Oct 2023 17:15:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 426C96B032B; Sat, 28 Oct 2023 17:15:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18B226B032E; Sat, 28 Oct 2023 17:15:55 -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 031536B0329 for ; Sat, 28 Oct 2023 17:15:55 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CEEF8140294 for ; Sat, 28 Oct 2023 21:15:54 +0000 (UTC) X-FDA: 81396127428.12.72E3C71 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf16.hostedemail.com (Postfix) with ESMTP id AF17D180003 for ; Sat, 28 Oct 2023 21:15:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=HvgVsjl6; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf16.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=1698527751; 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=gxd/EGAczS5Sd2rHF+B8nzW13spueLXcZPpoB3AlPYI=; b=LueT6EjC2qKK7M2AYQ7lBBjHkmSnLBqlQkRE5UBRT8N6ySwD0xkk4xk7zEfHWc96pPlA3e VWCwrCuMXraboUVhDEdpK6RG37Wc7arlo7qdUU0nozgWrI5mZoT+bIf9ezZezaI06M8fjj M9o1KRdpd+c/w0Ncdbu4KcNmPOkO7rE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=HvgVsjl6; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf16.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=1698527751; a=rsa-sha256; cv=none; b=sYf9jyKw4aElo0fZkWGqmO+//rZ3xE20aCTdD7TSPOYHw1IYoH9tHldDqBKKMqiczJGw6H kKvf263vmK75V6hgkbDHQeisGMAkycghUTORSmL/ooUQ+Gv5isJvL12hKkUCUxYyq7gPIk ygrNhUR3VAXIr6oB5rq9oxD2/5EePlM= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211550euoutp01a5c73930b873be5bdf7a1775112c7f95~SYf1lhOnh2659126591euoutp01L for ; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211550euoutp01a5c73930b873be5bdf7a1775112c7f95~SYf1lhOnh2659126591euoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527750; bh=gxd/EGAczS5Sd2rHF+B8nzW13spueLXcZPpoB3AlPYI=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=HvgVsjl64HvJ64ot77kmzDje+uQuxtA7zifALFjBJvDoDR4pE12gHKnQopPb9Q1Ki JcsOmoG3yxeNnMF8nPokyO29MmGgAeRqQa/qZXip9wn/92O8bamlvsBdGOhyhREkOW bBBKJ419K6MQ52U10yhCjUxALGKOW1hVkwIgykE8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211549eucas1p239234b06d304c44bb785b810de7b1834~SYf0zFEUx1087910879eucas1p2O; Sat, 28 Oct 2023 21:15:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DD.57.37758.50A7D356; Sat, 28 Oct 2023 22:15:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211548eucas1p18d34af3d578966ba6778d4e60751789d~SYf0Hvnnc0616106161eucas1p1U; Sat, 28 Oct 2023 21:15:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231028211548eusmtrp167fbd68caf98448438c2e2eab8a99c2b~SYf0HNAVQ0755507555eusmtrp1c; Sat, 28 Oct 2023 21:15:48 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-07-653d7a050245 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 03.52.10549.40A7D356; Sat, 28 Oct 2023 22:15:48 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211548eusmtip138c1e7e6b533f290bc0b98246a985425~SYfz7zIWw0467404674eusmtip1S; Sat, 28 Oct 2023 21:15: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; Sat, 28 Oct 2023 22:15: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; Sat, 28 Oct 2023 22:15: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: [RFC PATCH 08/11] shmem: add file length arg in shmem_get_folio() path Thread-Topic: [RFC PATCH 08/11] shmem: add file length arg in shmem_get_folio() path Thread-Index: AQHaCePr7bvMjV6bP0CdFgNDCwhrFA== Date: Sat, 28 Oct 2023 21:15:47 +0000 Message-ID: <20231028211518.3424020-9-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7qsVbapBqdbpSzmrF/DZrH6bj+b xeUnfBZPP/WxWOy9pW2xZ+9JFovLu+awWdxb85/VYtefHewWNyY8ZbRY9vU9u8XujYvYLH7/ mMPmwOsxu+Eii8eCTaUem1doeVw+W+qxaVUnm8emT5PYPU7M+M3i8XmTXABHFJdNSmpOZllq kb5dAldG69KJbAWfrSomTH3I1sDYpd/FyMkhIWAicbf9I1MXIxeHkMAKRom1J34wQjhfGCUu fNsK5XxmlLh99QkjTMupR1tYIRLLGSUeX57IBJIAq9r0LQ8icYZRYtK2L6wQiZWMEvNnBYDY bAKaEvtObmIHKRIRmM0qcXhxB9hYZoE6iTXPZrF0MXJwCAsESvy/nQYSFhEIk/h0fCMThK0n 0X7+CFg5i4CqxIVfU8Hm8wpYSyw7vpYdxOYUsJG4/207G4jNKCAr8WjlL3aI8eISt57MZ4L4 QFBi0ew9zBC2mMS/XQ/ZIGwdibPXYb40kNi6dB8LhK0k8adjIdSZehI3pk5hg7C1JZYtfM0M cYOgxMmZT1hA/pIQaOKSOHT/C9RQF4nrVxqghgpLvDq+hR3ClpE4PbmHZQKj9iwk981CsmMW kh2zkOxYwMiyilE8tbQ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gIDEkj3noR4TlXj5+B/UYzoSZ68/YYSw DSS2Lt3HAmErSfzpWAh1sZ7EjalT2CBsbYllC18zQ5wjKHFy5hOWCYzSs5Csm4WkZRaSlllI WhYwsqxiFEktLc5Nzy021CtOzC0uzUvXS87P3cQITE7bjv3cvINx3quPeocYmTgYDzFKcDAr ifAyO9qkCvGmJFZWpRblxxeV5qQWH2I0BQbRRGYp0eR8YHrMK4k3NDMwNTQxszQwtTQzVhLn 9SzoSBQSSE8sSc1OTS1ILYLpY+LglGpgYlcX/fQuqjyj5O0+T1Ff6ztTeKQ4ZwnMrTtQeyF+ 44ESE+nld02Wec2Nu6F7TCt7h1Q2Y0qXppNDvFL8Rl8F/ZlhitwCvyPY18g7HvJsK19we693 1cXVLuLvebqnxVt1nKjbLvlD+OFHlpVCKmZ9a5ovLJryhjE3j0tkxvI/B6+bi76z5eSX7Wo8 UZtmIVIkej99j4nQsSmW9zcUXHFe2LzHavHXeyczNgt9+7m5KPRS49K5h+Zs1fz1Qri98lDi /KnyFzyUz6nxP6i68O9DXJXIt0/+NTsZTNaI7Eu9s9pe5FNafWHz8WWlXae65Wbzq3YYfQ31 PX1AWLXE+ZfzwTs2ecWmtzKfJOfsKp+pxFKckWioxVxUnAgAN/NqXtcDAAA= X-CMS-MailID: 20231028211548eucas1p18d34af3d578966ba6778d4e60751789d X-Msg-Generator: CA X-RootMTR: 20231028211548eucas1p18d34af3d578966ba6778d4e60751789d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211548eucas1p18d34af3d578966ba6778d4e60751789d References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AF17D180003 X-Stat-Signature: y74et7sxjeooxcwm7s61169j1hfhi9fh X-Rspam-User: X-HE-Tag: 1698527751-213186 X-HE-Meta: U2FsdGVkX18DaSGsEUgBcgisbJbQ1bS6YYuWOwDVk99fuuAGIiHbnsrjNQUIm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1H3RE8ehWtO6xRy9lkP0brYmd4TJaxHM0UpT6XkZqvCGG0Ry3gsARIhu8c+bfYz2oBEmg== 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: List-Subscribe: List-Unsubscribe: In preparation for large folio in the write path, add file length argument in shmem_get_folio() path to be able to calculate the folio order based on the file size. Use of order-0 (PAGE_SIZE) for non write paths such as read, page cache read, and vm fault. This enables high order folios in the write and fallocate paths once the folio order is calculated based on the length. Signed-off-by: Daniel Gomez --- include/linux/shmem_fs.h | 2 +- mm/khugepaged.c | 3 ++- mm/shmem.c | 33 ++++++++++++++++++--------------- mm/userfaultfd.c | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) -- 2.39.2 diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 2caa6b86106a..7138ea980884 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -137,7 +137,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 064654717843..fcde8223b507 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1855,7 +1855,8 @@ 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, + PAGE_SIZE)) { result = SCAN_FAIL; goto xa_unlocked; } diff --git a/mm/shmem.c b/mm/shmem.c index 9d68211373c4..d8dc2ceaba18 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -958,7 +958,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, PAGE_SIZE); return folio; } @@ -1644,7 +1644,7 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct inode *inode, pgoff_t index, - struct mm_struct *fault_mm) + struct mm_struct *fault_mm, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -1969,7 +1969,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_fault *vmf, vm_fault_t *fault_type) + struct vm_fault *vmf, vm_fault_t *fault_type, size_t len) { struct vm_area_struct *vma = vmf ? vmf->vma : NULL; struct mm_struct *fault_mm; @@ -2051,7 +2051,7 @@ 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_add_folio(huge_gfp, - inode, index, fault_mm); + inode, index, fault_mm, len); if (!IS_ERR(folio)) { count_vm_event(THP_FILE_ALLOC); goto alloced; @@ -2060,7 +2060,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, goto repeat; } - folio = shmem_alloc_and_add_folio(gfp, inode, index, fault_mm); + folio = shmem_alloc_and_add_folio(gfp, inode, index, fault_mm, len); if (IS_ERR(folio)) { error = PTR_ERR(folio); if (error == -EEXIST) @@ -2140,10 +2140,10 @@ 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); + mapping_gfp_mask(inode->i_mapping), NULL, NULL, len); } /* @@ -2237,7 +2237,7 @@ static vm_fault_t shmem_fault(struct vm_fault *vmf) WARN_ON_ONCE(vmf->page != NULL); err = shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, - gfp, vmf, &ret); + gfp, vmf, &ret, PAGE_SIZE); if (err) return vmf_error(err); if (folio) { @@ -2716,6 +2716,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))) { @@ -2725,7 +2728,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; @@ -2796,7 +2799,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, PAGE_SIZE); if (error) { if (error == -EINVAL) error = 0; @@ -2973,7 +2976,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, PAGE_SIZE); if (error) { if (error == -EINVAL) error = 0; @@ -3160,7 +3163,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, (end - index) << PAGE_SHIFT); if (error) { info->fallocend = undo_fallocend; /* Remove the !uptodate folios we added */ @@ -3511,7 +3514,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, PAGE_SIZE); if (error) goto out_remove_offset; inode->i_mapping->a_ops = &shmem_aops; @@ -3558,7 +3561,7 @@ static const char *shmem_get_link(struct dentry *dentry, struct inode *inode, return ERR_PTR(-ECHILD); } } else { - error = shmem_get_folio(inode, 0, &folio, SGP_READ); + error = shmem_get_folio(inode, 0, &folio, SGP_READ, PAGE_SIZE); if (error) return ERR_PTR(error); if (!folio) @@ -4923,7 +4926,7 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, BUG_ON(!shmem_mapping(mapping)); error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, - gfp, NULL, NULL); + gfp, NULL, NULL, PAGE_SIZE); if (error) return ERR_PTR(error); diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 96d9eae5c7cc..aab8679b322a 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -256,7 +256,7 @@ static int mfill_atomic_pte_continue(pmd_t *dst_pmd, struct page *page; int ret; - ret = shmem_get_folio(inode, pgoff, &folio, SGP_NOALLOC); + ret = shmem_get_folio(inode, pgoff, &folio, SGP_NOALLOC, PAGE_SIZE); /* Our caller expects us to return -EFAULT if we failed to find folio */ if (ret == -ENOENT) ret = -EFAULT; From patchwork Sat Oct 28 21:15: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: 13439581 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 91ACEC4167B for ; Sat, 28 Oct 2023 21:16:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 539676B032E; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BFBE6B032F; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 228556B0330; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0A5546B032E for ; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DBD51803F7 for ; Sat, 28 Oct 2023 21:15:56 +0000 (UTC) X-FDA: 81396127512.27.75DF583 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf14.hostedemail.com (Postfix) with ESMTP id F038F10000B for ; Sat, 28 Oct 2023 21:15:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=ePBvv+Wz; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698527754; a=rsa-sha256; cv=none; b=cyIGSVubN8TE2M5uCOrGUMMZZh0xGixVqgHYqhp5rJ9KcOL/nkG+6PERu+ixpIdSo5g3F3 iro+UBRGsMILnfqfgBc6LYsZE+4VLptCWYWv4qiXvzMZ0sWQ+9bM7NkKx2isv9GL47uRuV volKLrQkxd8Jto1UWA5gcRjbK/SUj5I= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=ePBvv+Wz; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698527754; 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=MryWcICdLJnJIpSQ//VC4hAIbMIw5xNwvvS8lnrY/z4=; b=k426ZlUtcQ3PMleOspTSF5xb25lWvInsstj4xKi1vkWOoTXXx5PE1OTjLYAfmH7vmGu5o7 69zzWLU+4pWjccmGp191jCWAd9HG5RoTB11zz5930UCoy7iTed3xPQckgIckuPFCH+oRKO vP/OmfOpqBCX/g9dLocQHCBBUmAZglk= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211552euoutp029c53b6710e6f81f0c18e8b79e085b1e9~SYf3uDx7M0331103311euoutp02l for ; Sat, 28 Oct 2023 21:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211552euoutp029c53b6710e6f81f0c18e8b79e085b1e9~SYf3uDx7M0331103311euoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527752; bh=MryWcICdLJnJIpSQ//VC4hAIbMIw5xNwvvS8lnrY/z4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ePBvv+WznISzR3zoq3qsBn2CBSEJB2wrKIglDYakrXINkRy/NEALAyS/D37Ds0sMW CBZwq1VbMuGTaOih6ybrOyNMlVtrlV0vm2iC1UWGc9UPbkUW/xZJlH7xcOZokOfpAz CCUnB7AMfrF+6pejFOr/f+mUZSEJSVinapl2Zh0g= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211551eucas1p2e50b635ba8eae30317009299b0be2ea3~SYf2kdVsc1224812248eucas1p2E; Sat, 28 Oct 2023 21:15:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BE.57.37758.70A7D356; Sat, 28 Oct 2023 22:15:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef~SYf2GDan11181011810eucas1p1I; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211550eusmtrp2373a802e94a6ccdb4bd44f64388a442f~SYf2FekMo1141411414eusmtrp2g; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-0b-653d7a071720 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.01.25043.60A7D356; Sat, 28 Oct 2023 22:15:50 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231028211550eusmtip29b55570e519e6390a3d01dce2b0ec14a~SYf120roh1182011820eusmtip2p; Sat, 28 Oct 2023 21:15: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; Sat, 28 Oct 2023 22:15: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; Sat, 28 Oct 2023 22:15: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: [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Thread-Topic: [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Thread-Index: AQHaCePsz4j06UKTKkuVsaJRZMX8Ng== Date: Sat, 28 Oct 2023 21:15:49 +0000 Message-ID: <20231028211518.3424020-10-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrFKsWRmVeSWpSXmKPExsWy7djPc7rsVbapBj/nSVjMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MJdcqC05IVLxtusnYwNgh0sXIySEhYCIx8/ADli5GLg4hgRWMEq9PP4VyvjBKLN61 iQ3C+cwo0fL1PGsXIwdYy+o9DhDx5YwSPXdOsMAVbZ96mB3COcMoMWldGyuEs5JR4uKfLawg G9kENCX2ndwEViUiMJtV4vDiDkaQBLNAncSaZ7NYQGxhATeJL0segsVFBLwlXvftg7L1JJoW 9TOB2CwCqhKzu+awgdi8AjYSM89sB4tzAtn3v20HizMKyEo8WvmLHWK+uMStJ/OZIN4WlFg0 ew8zhC0m8W/XQzYIW0fi7PUnjBC2gcTWpftYIGwliT8dC6Hu1JO4MXUKG4StLbFs4WtmiBsE JU7OfAIOCwmBf5wSd/5OY4VodpHY924Z1CB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cTmFbCRmHlmOxPI3UICuRL9bZkg YU6g8P1v28FKGAVkJR6t/MUOsUpc4taT+UwQLwhILNlznhnCFpV4+fgf1Gs6EmevP4F62UBi 69J9LBC2ksSfjoVQJ+tJ3Jg6hQ3C1pZYtvA1M8Q5ghInZz5hmcAoPQvJullIWmYhaZmFpGUB I8sqRpHU0uLc9NxiI73ixNzi0rx0veT83E2MwOS07djPLTsYV776qHeIkYmD8RCjBAezkggv s6NNqhBvSmJlVWpRfnxRaU5q8SFGU2AQTWSWEk3OB6bHvJJ4QzMDU0MTM0sDU0szYyVxXs+C jkQhgfTEktTs1NSC1CKYPiYOTqkGJsW1tlf4mY0/XmfZqfDJbrVO5TLJIKtu0z9rHdurnV4k fbq48pFsd4ioXs9PQdnuHAVpTk+v66+NFF6Ev6p6pCbl5C6cFjDhzNpQ4UNiCnZR7Vte7W99 u+ksN3PQiUvL+1mtO+Sbf6+NdPM01rIpuJnhwjJ/1/dd5wUzttRZGebt2naJRf9h0yP2q7/z zqoaFWq9v2pgsJpjd6Ym83e//rS6uwHm6+SPB855Upmfnum7PGERq/6yRxeaY09N9Lr+c0dU cL8WA8/crQfv3/u1jMnRapOW6PtIncf6O2u5GLZLOXpeO14crbpwV1rUrMlqjBXbGJpXxjmX 8xhfWDfzoWvY5CNaKUeDnaT8lR2VWIozEg21mIuKEwHPwMUl1wMAAA== X-CMS-MailID: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef X-Msg-Generator: CA X-RootMTR: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F038F10000B X-Stat-Signature: oah3qhonmzbd8sokpei9mkb1c56kfbzy X-Rspam-User: X-HE-Tag: 1698527753-278590 X-HE-Meta: U2F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JF14dXWAZXQhdqK2ECP8uie4LfgdwhXGPlkARjWcDuDbp0mlKlynKiMO0yb6kbaQnzx5MA0PQ2UnJri6Q9xfz/KdkPTzLT1t4nPiwjU86QuUUJXoT4I+w== 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: List-Subscribe: List-Unsubscribe: Add folio order argument to the shmem_alloc_folio() and merge it with the shmem_alloc_folio_huge(). Return will make use of the new page_rmappable_folio() where order-0 and high order folios are both supported. Signed-off-by: Daniel Gomez --- mm/shmem.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index d8dc2ceaba18..fc7605da4316 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1614,40 +1614,27 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) return result; } -static struct folio *shmem_alloc_hugefolio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) +static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info, + pgoff_t index, unsigned int order) { struct mempolicy *mpol; pgoff_t ilx; struct page *page; - mpol = shmem_get_pgoff_policy(info, index, HPAGE_PMD_ORDER, &ilx); - page = alloc_pages_mpol(gfp, HPAGE_PMD_ORDER, mpol, ilx, numa_node_id()); + mpol = shmem_get_pgoff_policy(info, index, order, &ilx); + page = alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); return page_rmappable_folio(page); } -static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) -{ - struct mempolicy *mpol; - pgoff_t ilx; - struct page *page; - - mpol = shmem_get_pgoff_policy(info, index, 0, &ilx); - page = alloc_pages_mpol(gfp, 0, mpol, ilx, numa_node_id()); - mpol_cond_put(mpol); - - return (struct folio *)page; -} - static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct inode *inode, pgoff_t index, struct mm_struct *fault_mm, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); + unsigned int order = 0; struct folio *folio; long pages; int error; @@ -1668,12 +1655,12 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, index + HPAGE_PMD_NR - 1, XA_PRESENT)) return ERR_PTR(-E2BIG); - folio = shmem_alloc_hugefolio(gfp, info, index); + folio = shmem_alloc_folio(gfp, info, index, HPAGE_PMD_ORDER); if (!folio) count_vm_event(THP_FILE_FALLBACK); } else { - pages = 1; - folio = shmem_alloc_folio(gfp, info, index); + pages = 1UL << order; + folio = shmem_alloc_folio(gfp, info, index, order); } if (!folio) return ERR_PTR(-ENOMEM); @@ -1774,7 +1761,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; @@ -2618,7 +2605,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 Sat Oct 28 21:15: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: 13439582 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 2FFE5C4332F for ; Sat, 28 Oct 2023 21:16:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC8166B032F; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B52D96B0330; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 953D76B0331; Sat, 28 Oct 2023 17:15:57 -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 7D5356B032F for ; Sat, 28 Oct 2023 17:15:57 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5F540A027D for ; Sat, 28 Oct 2023 21:15:57 +0000 (UTC) X-FDA: 81396127554.27.D8D9A0D Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf28.hostedemail.com (Postfix) with ESMTP id 67954C001E for ; Sat, 28 Oct 2023 21:15:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Ug90+BkE; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf28.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=1698527754; 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=V58CpUMglUVRv2d2n4PjwOPxGbR6MAVB1lgi43BKbik=; b=1mdUPpR4PD3acmQreFg0zYK9oLAxQIL4K/CSU5uq+WiuEA8ZEPjvG7FCj++pJkCMin3h4Y rDGHy1DmnfK/uiVAa6eT7Z4M6Qntiab16Bo0LfWnRvHXCnAFQGam/OIs5avE1LUAASdwT4 jv4O+M6d4eBJM6+Egf90ucGF6setm1Y= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Ug90+BkE; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf28.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=1698527754; a=rsa-sha256; cv=none; b=ZG/t7YtUtuMtA/vMLgIXJM2qMvCnaFfoZ9B2hhPQ+PCjBGzfl+Jg4kbHp7qIwb0Isozk3v iRXHWLmlMwDhoLzncp21iz+0Fq5bThy0xHplDtZo/wGFu0zJ5+WyB5kjkni6c+Q6kjB8Z+ eaM7ZGriLG76t2otBusbxGBzOYTs+xU= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211553euoutp028e7c373ac1988a326746bcfd8f030540~SYf4KxjYJ0879208792euoutp02S for ; Sat, 28 Oct 2023 21:15:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211553euoutp028e7c373ac1988a326746bcfd8f030540~SYf4KxjYJ0879208792euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527753; bh=V58CpUMglUVRv2d2n4PjwOPxGbR6MAVB1lgi43BKbik=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Ug90+BkEzSkTyQzxO6IX69s40XfH1kin4j5qyV0qRip82QwCoST7VXdZhGtirfp/C eCUwW7HRdmW9RoJGBubVMRkje6dh2LhFr2aY5RD5wPKF7i+0tilH+Z95hxaUGhQlqG PwLLloFWfV3YsuaTmdl68/3RahrJys8XbK1q3o3E= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211552eucas1p2368f287afd825b44877b59399542f661~SYf3yR5P21087910879eucas1p2Q; Sat, 28 Oct 2023 21:15:52 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A3.20.11320.80A7D356; Sat, 28 Oct 2023 22:15:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211551eucas1p1552b7695f12c27f4ea1b92ecb6259b31~SYf3Amogw0616106161eucas1p1Y; Sat, 28 Oct 2023 21:15:51 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231028211551eusmtrp166725da83a27a1657bdc91947630f5f0~SYf3AFyW50755507555eusmtrp1e; Sat, 28 Oct 2023 21:15:51 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-94-653d7a08c743 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 04.52.10549.70A7D356; Sat, 28 Oct 2023 22:15:51 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211551eusmtip146fad08e90fd824bcd219c14210d9955~SYf206cR30467404674eusmtip1U; Sat, 28 Oct 2023 21:15:51 +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; Sat, 28 Oct 2023 22:15: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; Sat, 28 Oct 2023 22:15: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: [RFC PATCH 10/11] shmem: add large folio support to the write path Thread-Topic: [RFC PATCH 10/11] shmem: add large folio support to the write path Thread-Index: AQHaCePt75l+dUBUfkS9wehNfGwv9w== Date: Sat, 28 Oct 2023 21:15:50 +0000 Message-ID: <20231028211518.3424020-11-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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: H4sIAAAAAAAAA01Sa0hTYRjmOzs7O65WpyntU7uuJHK6mRWcwCIp8FAQXcio6LLypJWaba2L Rs0wbEMsNaFdKi95aS2mq0zMGc1srSlltrSFhjYtjFLTynRYm2eF/573ed7nfd7348NZfDs7 BD+ceoKWpUqThRgXrXn2+2Uknr6ajrrTE07qTUaMvNN5GSPb3DPI3u+5KGlxich6ix0l2+r0 GNll/MMm6zy1HLLjSi8gy38McMhH1SUYOT6qx9byKJ2yFaWKzArqXmU41daioMwGFUaZv+dz qOfXxlFq2DxvM76LG5NAJx8+Scska/Zzk765+pC0/tDTqjdsJbg7Ww0CcEisgJ5uD1sNuDif qARwqETvL0YAbHmRgzLFMIBV7V3oP0tldpu/qwJAzS8j539XzjeVX2n2KtlWFlPcBnBU7eT4 /BixFDbYzZOWIELHho2ll4BPYBHnoLFPOxkSSGyEat1LxIeDiK1QVTXsnYR7sRjmmfg+GiXC oNPowXw0j4iBFucOHx3ghR9+PsR8GBBzYc/tMQ4zXQBd7psIc8IsWKKrZzF4Npyo68YYHAFb 2t2AwVHwQVmD/2Qh9F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4NBzGFBHIl+tsyQSo4 gaL3v21nA7EZBWQlHq38xQ6xSFzi1pP5TBAPCEgs2XOeGcIWlXj5+B/UYzoSZ68/YYSwDSS2 Lt0H9bySxJ+OhVAH60ncmDqFDcLWlli28DXYHF4BQYmTM5+wTGCUnoVk3SwkLbOQtMxC0rKA kWUVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYGraduzn5h2M81591DvEyMTBeIhRgoNZSYSX 2dEmVYg3JbGyKrUoP76oNCe1+BCjKTCEJjJLiSbnA5NjXkm8oZmBqaGJmaWBqaWZsZI4r2dB R6KQQHpiSWp2ampBahFMHxMHp1QDU0CAsoTS1hAGmS/nH3i36u929eEWimr/tZDT+c+W9zdk +j7s2BBvKC2z605S8rkvx6zP7W76dXdpiD1nSUCCzzKz5+//acvJXYzLU9dRFOwRv7rpzSVr prif27hWlFeseN8dwbHrtGKr7et7BevnuVody/ztGbJti0zUyv+27/oS65/7LOU+3VBofMyU ba9bTIDa0tPsS0+auyyOkO79Fc3ie2qNyC/p6H9n7FOfzFvkdt3+P+uf9zcMHmnJeP6yecp3 L4fX6NlNa4Z0JrPtjH7Mn3uDbx282qlQsc/b0zl292vXxYLP/rz7eylyVlNTK091Z+fPjF6e pqvmcyRzN6l/04ttmFnDl7CJ8zeDEktxRqKhFnNRcSIABtzmANYDAAA= X-CMS-MailID: 20231028211551eucas1p1552b7695f12c27f4ea1b92ecb6259b31 X-Msg-Generator: CA X-RootMTR: 20231028211551eucas1p1552b7695f12c27f4ea1b92ecb6259b31 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211551eucas1p1552b7695f12c27f4ea1b92ecb6259b31 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 67954C001E X-Stat-Signature: o975ows961conjhh9zk1w5msphoed98s X-HE-Tag: 1698527754-24598 X-HE-Meta: U2FsdGVkX18ybKXP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CdWIBa+lrbUvJWBFvcIIWoKA2UJMEhs9L/gbagNsDhL/DZRkItLWhaV050KNFN081j+X 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: List-Subscribe: List-Unsubscribe: Current work in progress. Large folios in the fallocate path makes regress fstests generic/285 and generic/436. 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(). Add shmem_mapping_size_order to get a hint for the order of the folio based on the 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. Add the __GFP_COMP flag for high order folios except when huge is enabled. This fixes a memory leak when allocating high order folios. Signed-off-by: Daniel Gomez --- mm/shmem.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index fc7605da4316..eb314927be78 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1621,6 +1621,9 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info, pgoff_t ilx; struct page *page; + if ((order != 0) && !(gfp & VM_HUGEPAGE)) + gfp |= __GFP_COMP; + mpol = shmem_get_pgoff_policy(info, index, order, &ilx); page = alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); @@ -1628,17 +1631,56 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info, return page_rmappable_folio(page); } +/** + * 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; + + order -= PAGE_SHIFT; + + /* If we're not aligned, allocate a smaller folio */ + if (index & ((1UL << order) - 1)) + order = __ffs(index); + + order = min_t(size_t, order, MAX_PAGECACHE_ORDER); + + /* Order-1 not supported due to THP dependency */ + return (order == 1) ? 0 : order; +} + static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct inode *inode, pgoff_t index, struct mm_struct *fault_mm, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); - unsigned int order = 0; + unsigned int order = shmem_mapping_size_order(mapping, index, len, + SHMEM_SB(inode->i_sb)); struct folio *folio; long pages; int error; +neworder: if (gfp & VM_HUGEPAGE) { pages = HPAGE_PMD_NR; index = round_down(index, HPAGE_PMD_NR); @@ -1721,6 +1763,11 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, unlock: folio_unlock(folio); folio_put(folio); + if (order != 0) { + if (--order == 1) + order = 0; + goto neworder; + } return ERR_PTR(error); } From patchwork Sat Oct 28 21:15: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: 13439583 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 BF454C4167D for ; Sat, 28 Oct 2023 21:16:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 403E66B0330; Sat, 28 Oct 2023 17:16:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38CAA6B0332; Sat, 28 Oct 2023 17:16:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 141BD6B0333; Sat, 28 Oct 2023 17:16:00 -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 E6EB96B0330 for ; Sat, 28 Oct 2023 17:15:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BE7BE1A02C9 for ; Sat, 28 Oct 2023 21:15:59 +0000 (UTC) X-FDA: 81396127638.07.E1D74FF Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf22.hostedemail.com (Postfix) with ESMTP id C6D38C0006 for ; Sat, 28 Oct 2023 21:15:56 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Hmi+lFYm; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf22.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=1698527757; 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=vhkx9nEW1P7cUV8Zzx9SlNlxAL82sC2JgyqBVsGy9MY=; b=8XFlKOhtoobQoC72qo1/ChTuXrCjbiEMhYCeBqliDnrSQFVSX/g3BRDUO5hC2Iv4LbAsWN WmFBMHwN/AszqALzBLOSk17gjitDCzgvM0X1+aIG3vNuLx9jYbC6DjVdl6B9mx6JPgSve0 WWrSH7dXsZMOlLv6USbgf8QN74Nkg5c= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Hmi+lFYm; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf22.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=1698527757; a=rsa-sha256; cv=none; b=Cr9ccf8mOlXgyhc6Y28udNvmKFHBCvVTLpxuP3Ai4LcomSFHmCWIsNuRS2aVkUJdiGelSG 8etGUUvXNAR9qpxXatpq2lJGqFdqhmuLxdXKDspyBWPq0P8ogKME4p2aquyjW8RzifyfOm LR1T7y9tdiR3NU6FhjNfLr4hEnsyDis= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211555euoutp02e20cf9d32c1e9e8ca05d94085202332a~SYf6bCty70878908789euoutp02U for ; Sat, 28 Oct 2023 21:15:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211555euoutp02e20cf9d32c1e9e8ca05d94085202332a~SYf6bCty70878908789euoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527755; bh=vhkx9nEW1P7cUV8Zzx9SlNlxAL82sC2JgyqBVsGy9MY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Hmi+lFYmkHisLsZG4VbgvaPvoiedms0z5nZdt23VzeCaQ4zTch+cDcnZoKOkjZexm /vTxBQ0PS0S7S/vCmV+ontWsu8i0kpVGRzZBNKgTjMHBvhGggt2MHcoh0c1JqnGkqq ARbkmZY90/TNfseuHtaw6TXdEUBbIaXDncT5gR60= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211555eucas1p2394b404cd93491ee5bf44a270047b733~SYf6NFJBV1224812248eucas1p2I; Sat, 28 Oct 2023 21:15:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 9F.57.37758.B0A7D356; Sat, 28 Oct 2023 22:15:55 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211553eucas1p1a93637df6c46692531894e26023920d5~SYf441zj70616106161eucas1p1Z; Sat, 28 Oct 2023 21:15:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211553eusmtrp28117a3ed7ca27591a873d3f9be3ed510~SYf44SkDt1141411414eusmtrp2i; Sat, 28 Oct 2023 21:15:53 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-10-653d7a0b230b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A1.01.25043.90A7D356; Sat, 28 Oct 2023 22:15:53 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231028211553eusmtip2ab1bab33fda116438d8bc7115d2b0f8e~SYf4oIwLJ1182011820eusmtip2q; Sat, 28 Oct 2023 21:15: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; Sat, 28 Oct 2023 22:15: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; Sat, 28 Oct 2023 22:15: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: [RFC PATCH 11/11] shmem: add per-block uptodate tracking Thread-Topic: [RFC PATCH 11/11] shmem: add per-block uptodate tracking Thread-Index: AQHaCePuWb31sxRneEm07VKavHLDZg== Date: Sat, 28 Oct 2023 21:15:52 +0000 Message-ID: <20231028211518.3424020-12-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-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+NgFjrNKsWRmVeSWpSXmKPExsWy7djP87rcVbapBmfWC1nMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6Mw3f6mAtOelQ86drA0sB4zLqLkZNDQsBE4ury1exdjFwcQgIrGCUerZrOBOF8YZTY sH8NG4TzmVGibfUpZpiWZ7vfMEMkljNKbG9qYYKrOnXzEdSwM4wST/ddZgdpERJYySjRsVoR xGYT0JTYd3ITWJGIwGxWicOLOxhBEswCdRJrns1iAbGFBRwljj95BRYXEXCTmN3Sxgph60lc XrkdbCiLgKrEyw872UBsXgEbiW1/D4PFOYHs+9+2g8UZBWQlHq38xQ4xX1zi1pP5TBA/CEos mr0H6h8xiX+7HrJB2DoSZ68/YYSwDSS2Lt3HAmErSfzpWAh1p57EjalT2CBsbYllC18zQ9wg KHFy5hMWkMckBP5xSrz4cBNqgYvEqs87oAYJS7w6voUdwpaR+L9zPtMERu1ZSO6bhWTHLCQ7 ZiHZsYCRZRWjeGppcW56arFxXmq5XnFibnFpX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Jnrz9hhLANJLYu 3ccCYStJ/OlYCHWynsSNqVPYIGxtiWULXzNDnCMocXLmE5YJjNKzkKybhaRlFpKWWUhaFjCy rGIUSS0tzk3PLTbSK07MLS7NS9dLzs/dxAhMTtuO/dyyg3Hlq496hxiZOBgPMUpwMCuJ8DI7 2qQK8aYkVlalFuXHF5XmpBYfYjQFBtFEZinR5HxgeswriTc0MzA1NDGzNDC1NDNWEuf1LOhI FBJITyxJzU5NLUgtgulj4uCUamAK8Su9t4A1dfL8zhPeLTrCNgEbXsyONbGd+tjGQCXox5HS 3rLggsakCS0Lb5R/8/w6v9qoWV59ZpHhI5PKzex/s4N2LgzfKCTwtXmeu++O+NKS+rTs/xNe fCx2vZt1/MbtC/dVzD/KHvzYxihx+XiuvkDISXWGvHjGd8fP++3pealQ5nbry3GpXIHmBQVb +e28FPN3Trm8YXJg2PpLr+aKvHbbLndBrS7/WkzNr0O3q1d1XrFQPPBX4vJEEYlrSQ8XyXk6 S7/ftyamem7b6TStFa02djtyb7rxKfxm8HzxRVFVPkG7be/Odbq3ZjPveaGa/uKs8j3FkxP3 mN+alyPDVFdftLSha/eDRJOLy8uUWIozEg21mIuKEwGITef91wMAAA== X-CMS-MailID: 20231028211553eucas1p1a93637df6c46692531894e26023920d5 X-Msg-Generator: CA X-RootMTR: 20231028211553eucas1p1a93637df6c46692531894e26023920d5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211553eucas1p1a93637df6c46692531894e26023920d5 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: C6D38C0006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: qq5nkf3bpgtue64wjksffsqjrngaw8px X-HE-Tag: 1698527756-705721 X-HE-Meta: U2FsdGVkX19MbLM0s/HvN6rkyD2k6/SprQH/9KaQdYfi873W1fR3WAjlHPyVabHHrga150w5X6b55G6Gxhp5/L8Y6sNYAgCiylZmx704XHiO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4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Current work in progress due to fsx regression (check below). Based on iomap per-block dirty and uptodate state track, add support for shmem_folio_state struct to track uptodate per-block when a folio is larger than a block. In shmem, this is when large folios is used, as one block is equal to one page in this context. Add support for invalidate_folio, release_folio and is_partially_uptodate address space operations. The first two are needed to be able to free the new shmem_folio_state struct. The last callback is required for large folios when enabling per-block tracking. This was spotted when running fstests for tmpfs and regress on generic/285 and generic/436 tests [1] with large folios support in the fallocate path without having per-block uptodate tracking. [1] tests: generic/285: src/seek_sanity_test/test09() generic/436: src/seek_sanity_test/test13() How to reproduce: ```sh mkdir -p /mnt/test-tmpfs ./src/seek_sanity_test -s 9 -e 9 /mnt/test-tmpfs/file ./src/seek_sanity_test -s 13 -e 13 /mnt/test-tmpfs/file umount /mnt/test-tmpfs ``` After per-block uptodate support is added, fsx regresion is found when running the following: ```sh mkdir -p /mnt/test-tmpfs mount -t tmpfs -o size=1G -o noswap tmpfs /mnt/test-tmpfs /root/xfstests-dev/ltp/fsx /mnt/test-tmpfs/file -d -N 1200 -X umount /mnt/test-tmpfs ``` Signed-off-by: Daniel Gomez --- mm/shmem.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 159 insertions(+), 10 deletions(-) -- 2.39.2 diff --git a/mm/shmem.c b/mm/shmem.c index eb314927be78..fa67594495d5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -132,6 +132,94 @@ struct shmem_options { #define SHMEM_SEEN_QUOTA 32 }; +/* + * Structure allocated for each folio to track per-block uptodate state. + * + * Like buffered-io shmem_folio_state struct but only for uptodate. + */ +struct shmem_folio_state { + spinlock_t state_lock; + unsigned long state[]; +}; + +static inline bool sfs_is_fully_uptodate(struct folio *folio, + struct shmem_folio_state *sfs) +{ + struct inode *inode = folio->mapping->host; + + return bitmap_full(sfs->state, i_blocks_per_folio(inode, folio)); +} + +static inline bool sfs_block_is_uptodate(struct shmem_folio_state *sfs, + unsigned int block) +{ + return test_bit(block, sfs->state); +} + +static void sfs_set_range_uptodate(struct folio *folio, + struct shmem_folio_state *sfs, size_t off, + size_t len) +{ + struct inode *inode = folio->mapping->host; + unsigned int first_blk = off >> inode->i_blkbits; + unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; + unsigned int nr_blks = last_blk - first_blk + 1; + unsigned long flags; + + spin_lock_irqsave(&sfs->state_lock, flags); + bitmap_set(sfs->state, first_blk, nr_blks); + if (sfs_is_fully_uptodate(folio, sfs)) + folio_mark_uptodate(folio); + spin_unlock_irqrestore(&sfs->state_lock, flags); +} + +static void shmem_set_range_uptodate(struct folio *folio, size_t off, + size_t len) +{ + struct shmem_folio_state *sfs = folio->private; + + if (sfs) + sfs_set_range_uptodate(folio, sfs, off, len); + else + folio_mark_uptodate(folio); +} + +static struct shmem_folio_state *sfs_alloc(struct inode *inode, + struct folio *folio, gfp_t gfp) +{ + struct shmem_folio_state *sfs = folio->private; + unsigned int nr_blocks = i_blocks_per_folio(inode, folio); + + if (sfs || nr_blocks <= 1) + return sfs; + + /* + * sfs->state tracks uptodate flag when the block size is smaller + * than the folio size. + */ + sfs = kzalloc(struct_size(sfs, state, BITS_TO_LONGS(nr_blocks)), gfp); + if (!sfs) + return sfs; + + spin_lock_init(&sfs->state_lock); + if (folio_test_uptodate(folio)) + bitmap_set(sfs->state, 0, nr_blocks); + folio_attach_private(folio, sfs); + + return sfs; +} + +static void sfs_free(struct folio *folio) +{ + struct shmem_folio_state *sfs = folio_detach_private(folio); + + if (!sfs) + return; + WARN_ON_ONCE(sfs_is_fully_uptodate(folio, sfs) != + folio_test_uptodate(folio)); + kfree(sfs); +} + #ifdef CONFIG_TMPFS static unsigned long shmem_default_max_blocks(void) { @@ -1495,7 +1583,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) } folio_zero_range(folio, 0, folio_size(folio)); flush_dcache_folio(folio); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); } swap = folio_alloc_swap(folio); @@ -1676,6 +1764,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct shmem_inode_info *info = SHMEM_I(inode); unsigned int order = shmem_mapping_size_order(mapping, index, len, SHMEM_SB(inode->i_sb)); + struct shmem_folio_state *sfs; struct folio *folio; long pages; int error; @@ -1755,6 +1844,10 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, } } + sfs = sfs_alloc(inode, folio, gfp); + if (!sfs && i_blocks_per_folio(inode, folio) > 1) + goto unlock; + trace_mm_shmem_add_to_page_cache(folio); shmem_recalc_inode(inode, pages, 0); folio_add_lru(folio); @@ -1818,7 +1911,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, __folio_set_locked(new); __folio_set_swapbacked(new); - folio_mark_uptodate(new); + shmem_set_range_uptodate(new, 0, folio_size(new)); new->swap = entry; folio_set_swapcache(new); @@ -2146,7 +2239,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, for (i = 0; i < n; i++) clear_highpage(folio_page(folio, i)); flush_dcache_folio(folio); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); } /* Perhaps the file has been truncated since we checked */ @@ -2788,13 +2881,18 @@ shmem_write_end(struct file *file, struct address_space *mapping, if (pos + copied > inode->i_size) i_size_write(inode, pos + copied); + if (unlikely(copied < len && !folio_test_uptodate(folio))) + return 0; + if (!folio_test_uptodate(folio)) { - if (copied < folio_size(folio)) { - size_t from = offset_in_folio(folio, pos); - folio_zero_segments(folio, 0, from, - from + copied, folio_size(folio)); - } - folio_mark_uptodate(folio); + size_t from = offset_in_folio(folio, pos); + if (!folio_test_large(folio) && copied < folio_size(folio)) + folio_zero_segments(folio, 0, from, from + copied, + folio_size(folio)); + if (folio_test_large(folio) && copied < PAGE_SIZE) + folio_zero_segments(folio, from, from, from + copied, + folio_size(folio)); + shmem_set_range_uptodate(folio, from, len); } folio_mark_dirty(folio); folio_unlock(folio); @@ -2803,6 +2901,54 @@ shmem_write_end(struct file *file, struct address_space *mapping, return copied; } +void shmem_invalidate_folio(struct folio *folio, size_t offset, size_t len) +{ + /* + * If we're invalidating the entire folio, clear the dirty state + * from it and release it to avoid unnecessary buildup of the LRU. + */ + if (offset == 0 && len == folio_size(folio)) { + WARN_ON_ONCE(folio_test_writeback(folio)); + folio_cancel_dirty(folio); + sfs_free(folio); + } +} + +bool shmem_release_folio(struct folio *folio, gfp_t gfp_flags) +{ + sfs_free(folio); + return true; +} + +/* + * shmem_is_partially_uptodate checks whether blocks within a folio are + * uptodate or not. + * + * Returns true if all blocks which correspond to the specified part + * of the folio are uptodate. + */ +bool shmem_is_partially_uptodate(struct folio *folio, size_t from, size_t count) +{ + struct shmem_folio_state *sfs = folio->private; + struct inode *inode = folio->mapping->host; + unsigned first, last, i; + + if (!sfs) + return false; + + /* Caller's range may extend past the end of this folio */ + count = min(folio_size(folio) - from, count); + + /* First and last blocks in range within folio */ + first = from >> inode->i_blkbits; + last = (from + count - 1) >> inode->i_blkbits; + + for (i = first; i <= last; i++) + if (!sfs_block_is_uptodate(sfs, i)) + return false; + return true; +} + static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *file = iocb->ki_filp; @@ -3554,7 +3700,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_mapping->a_ops = &shmem_aops; inode->i_op = &shmem_symlink_inode_operations; memcpy(folio_address(folio), symname, len); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); folio_mark_dirty(folio); folio_unlock(folio); folio_put(folio); @@ -4524,6 +4670,9 @@ const struct address_space_operations shmem_aops = { #ifdef CONFIG_MIGRATION .migrate_folio = migrate_folio, #endif + .invalidate_folio = shmem_invalidate_folio, + .release_folio = shmem_release_folio, + .is_partially_uptodate = shmem_is_partially_uptodate, .error_remove_page = shmem_error_remove_page, }; EXPORT_SYMBOL(shmem_aops);