Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1949437rdh; Sat, 28 Oct 2023 14:17:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyNENnNBLxYnCliaS6ByajHKbN/cKfjcT8U027mn1BHTaHzRw9RXTbnYjgaFHcO/yz2qCk X-Received: by 2002:a17:90b:e89:b0:27d:7f1b:1bf1 with SMTP id fv9-20020a17090b0e8900b0027d7f1b1bf1mr5287579pjb.32.1698527878705; Sat, 28 Oct 2023 14:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698527878; cv=none; d=google.com; s=arc-20160816; b=k4m0K2bMkir1b88F0y2z4osnwzuDEAC74T7m9uHGbcI1RpZk2UJxUtOIF8wSVDHDCD IydnVzhdJZPnYaiErbXd204lmnKZ7D4YGg+bnF/IJblM9G84A0wGOw1e58Vm7YWmDQ2q CGBGkaTq8bsemhh2VdFdktynZ9LBYQQqbus7LSrh40G8FG6o6OXdkwVaaBimjAILXihY fRliuqifmGNyo5YMDqBtWQ5Q1/LEV+iViMBiMUYZKjbRdpKwY9OlPFiG0XHyKQN+ZWeX 6A/9x3nnjz1mHLydvmCwHg6YFwvLDq+xqut8QD7Rn2DPT85CRMhoSF4/KVWZ3VH1+Rz6 z52Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=8ofABjUQrTp1kzdTCcGf7BUaZhuxx/1pi/TdtpYF5D0=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=JNUqnO4yX+x0L4I1st6wxqoqOlJYqyYOaRYNlqro0m4SFbbNCGXiB+2hR+QrbxtN6o dYki8DZx+qGGlCmGt4A6GAr3eOFMTyDLHkKek1R3oNwEKLwpg+566oYo+B+VPxDHLtzK iE9m4SmcyAa7Ed84ReBsl0rfZKFDXE4+p1yFyrXTFKn5IbkqHlq2W+IxhPaUhi7QVwNF +JjIPHlPlgTkr5s7He2f71mHIENjayzE/JL5JomUB+MxPyiBTWURoq6GDKFqyDWKw/Df rj0J6PZhh0WChj4r6WTegij1BHjmHNFkhiuvxMxJezh7vgG6QPybGdUTeoHmuTzWhbV8 unwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=VYigV6I+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n8-20020a17090aab8800b002801dcb4770si1810412pjq.137.2023.10.28.14.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=VYigV6I+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 725388055ADE; Sat, 28 Oct 2023 14:17:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbjJ1VQA (ORCPT + 99 others); Sat, 28 Oct 2023 17:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjJ1VPs (ORCPT ); Sat, 28 Oct 2023 17:15:48 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E60BE4 for ; Sat, 28 Oct 2023 14:15:45 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211543euoutp027c737c753d222493fedad4427fc523b5~SYfu8zF0A0331103311euoutp02d for ; Sat, 28 Oct 2023 21:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211543euoutp027c737c753d222493fedad4427fc523b5~SYfu8zF0A0331103311euoutp02d 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] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 kh2zkOxYwMiyilE8tbQ4Nz212Cgvt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qlbj2ZzwTxgIDEkj3nmSFsUYmXj/9BPaYjcfb6E0YI 20Bi69J9LBC2ksSfjoVQF+tJ3Jg6hQ3C1pZYtvA11DmCEidnPmGZwCg9C8m6WUhaZiFpmYWk ZQEjyypGkdTS4tz03GJDveLE3OLSvHS95PzcTYzA1LTt2M/NOxjnvfqod4iRiYPxEKMEB7OS CC+zo02qEG9KYmVValF+fFFpTmrxIUZTYBBNZJYSTc4HJse8knhDMwNTQxMzSwNTSzNjJXFe 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:17:52 -0700 (PDT) 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) } =20 /* - * 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. Re= turns + * the number of pages being freed. 0 means entry not found in XArray (0 p= ages + * 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 =3D 1UL << xa_get_order(&mapping->i_pages, index); =20 old =3D xa_cmpxchg_irq(&mapping->i_pages, index, radswap, NULL, 0); if (old !=3D radswap) - return -ENOENT; + return 0; free_swap_and_cache(radix_to_swp_entry(radswap)); - return 0; + + return swaps_freed; } =20 /* @@ -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 +=3D !shmem_free_swap(mapping, + nr_swaps_freed +=3D shmem_free_swap(mapping, indices[i], folio); continue; } @@ -1057,14 +1061,17 @@ static void shmem_undo_range(struct inode *inode, l= off_t lstart, loff_t lend, folio =3D fbatch.folios[i]; =20 if (xa_is_value(folio)) { + long swaps_freed; + if (unfalloc) continue; - if (shmem_free_swap(mapping, indices[i], folio)) { + swaps_freed =3D shmem_free_swap(mapping, indices[i], folio); + if (!swaps_freed) { /* Swap was replaced by page: retry */ index =3D indices[i]; break; } - nr_swaps_freed++; + nr_swaps_freed +=3D swaps_freed; continue; } =20 --=20 2.39.2