Message ID | 20231028211518.3424020-5-da.gomez@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1401217vqb; Sat, 28 Oct 2023 14:17:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEV8sPd8BP7X/wnJCLchRRm4zhhzYBoVhWEh3wcZI71gVxMDdLQmDQRWKqwvXDQekM3otU X-Received: by 2002:a05:6808:2796:b0:3b2:e95d:8b2 with SMTP id es22-20020a056808279600b003b2e95d08b2mr6329120oib.12.1698527828120; Sat, 28 Oct 2023 14:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698527828; cv=none; d=google.com; s=arc-20160816; b=HW68U7WWK393G1NoM7KyuplFL2WbzdoqZ9S9W4D2cqpcwgVJKNJpHjcFkijAoMSJVL 6MfaFhOhWAYWBsn43OfReYW6jstyID15eKOMQ51Q1DRWv7+8isWF0FSJ76wOgi7ogFbD VLp0WvnOW2qF50ANNmLeUqYZhavCUp7RiO2YNnb4oqd7nHA4H+s8FSX4wAPhkVvczo8A GEiynkkHK99jXo/sejUu+aDxOBczBfyZvBLjJ5Hqjw3mfDBd5ZVlmxuNIL/BlmECNUX1 tE1clizVOCLVNDHr45ZalXeEAwE3PPRbqDt1LtLoBu+1E5Tm09xAqZNiJ6SKMHx007jg iuUg== 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 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b4-20020aa79504000000b006bf6b23d6d9si2727290pfp.400.2023.10.28.14.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id B070E8046C81; Sat, 28 Oct 2023 14:16:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjJ1VQA (ORCPT <rfc822;peter110.wang@gmail.com> + 29 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <linux-kernel@vger.kernel.org>; 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 <da.gomez@samsung.com> To: "minchan@kernel.org" <minchan@kernel.org>, "senozhatsky@chromium.org" <senozhatsky@chromium.org>, "axboe@kernel.dk" <axboe@kernel.dk>, "djwong@kernel.org" <djwong@kernel.org>, "willy@infradead.org" <willy@infradead.org>, "hughd@google.com" <hughd@google.com>, "akpm@linux-foundation.org" <akpm@linux-foundation.org>, "mcgrof@kernel.org" <mcgrof@kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>, "linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>, "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>, "linux-mm@kvack.org" <linux-mm@kvack.org> CC: "gost.dev@samsung.com" <gost.dev@samsung.com>, Pankaj Raghav <p.raghav@samsung.com>, Daniel Gomez <da.gomez@samsung.com> 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 h1mfoTKfGSUmXdjKBN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p26663bd957cb449c7346b9dd00e33a20f 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> <CGME20231028211541eucas1p26663bd957cb449c7346b9dd00e33a20f@eucas1p2.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 pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:16:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781035515925270791 X-GMAIL-MSGID: 1781035515925270791 |
Series |
shmem: high order folios support in write path
|
|
Commit Message
Daniel Gomez
Oct. 28, 2023, 9:15 p.m. UTC
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 <willy@infradead.org> Signed-off-by: Daniel Gomez <da.gomez@samsung.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> --- 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; }