Message ID | 20230919135536.2165715-3-da.gomez@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3413800vqi; Tue, 19 Sep 2023 07:06:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXvNBTP0t5HZa7rtqa1kbv65SJS0yTz2RL7bg+w+sBI24JlGN0TocW1kCgwFKgyZvsuLET X-Received: by 2002:a17:902:e80a:b0:1b3:d4d5:beb2 with SMTP id u10-20020a170902e80a00b001b3d4d5beb2mr14522525plg.9.1695132401753; Tue, 19 Sep 2023 07:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695132401; cv=none; d=google.com; s=arc-20160816; b=aYzuR1uQ9ycTMNOSLqk/LC/BVWG7zSk8uv4gXz5uSZbgV1d5gTanB530TjGu0UvpUS qzyczrImEqRy0GPLmllq9XOmPQ7WG4bIlFtwaY1d/8+POI1uOKy2NaykwCHGRyFMKsV2 TpmwNEPWvjlzQO/vGSXYhcjLxWabjgpYVZ2Y2jYhePDVPZZlnhL8UzYaP9Tv0OYls8Ar 4IZuVlf+SEkn4GW/rzG3IZw3IK00mevuuBA7I+rApBubJc8hd8WFnFl+aKHuBFb6HDFl hBSxWqyexVRk85L/m/j82LQp9c9TFSwlKFRg+VNqp7QWUz13jGtSfIzL9g5TeJLBP3vr AeAg== 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=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=0nMJXNMEWM3r3NxfSrFUqKN3QpE0A/RnobkmmeVN4jJC505y9DrKzn1PW/izVVtxOu uOo2e6R8KCSLeppnWtCfzXaPJz3IB8eL3pclxeq/h4JhalcCYgDsZZR0B9fMZJZAzdgR 7/9tTuZ7dXXbn9jCiViCjZvQ+omf65PKZLDywIR0NfkzZvVFUKenIEC52UeZNXm4Mh/A 2Ghbqa3GjNS579OIb19gd6scS7SsLJsQit1VDnnSrUfE9Rq9LH5Bp8NkrGSED7aCNtBw AI40X/+CSOFFs965Lfwz826cGdiE5Yanx0Xo7xXs1japC2kZh6vtaF1rym5rr7Zee1jn qbCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="S/I8tzNo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id kq13-20020a170903284d00b001bf1973eafcsi9616956plb.571.2023.09.19.07.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="S/I8tzNo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 466B88073DC7; Tue, 19 Sep 2023 06:58:06 -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 S232487AbjISN4X (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Tue, 19 Sep 2023 09:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232566AbjISN4P (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 19 Sep 2023 09:56:15 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4745512D for <linux-kernel@vger.kernel.org>; Tue, 19 Sep 2023 06:55:53 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135549euoutp015e5a146ef879536908da6a9aa9d30519~GUVhq9Q2M3233132331euoutp01k for <linux-kernel@vger.kernel.org>; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230919135549euoutp015e5a146ef879536908da6a9aa9d30519~GUVhq9Q2M3233132331euoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131749; bh=LMHYH9ZTyrJA3zeIZ8Cw61+9DcuHoaxdnpNBuheefF0=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=S/I8tzNocRjVASDHLDVbZG1o0m5ySXDg7TpgNah3igHxxkIwUNZaIoedmh5F0HTBW dQo39hU3zNUXeSOhpV4FI2QiTwztjIioq1rd7Fsu8ItAWEjIVj4OLU9qcBike/4XPs KUXaM379aAsK8wBVtRcwGb7tZ3MbF+HOcWNmVaPI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eucas1p214bb8ae09e148c563a02f19655c58a3a~GUVhZ4Z1R1835818358eucas1p2Q; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C6.D1.42423.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf~GUVg-ov7A0405704057eucas1p1k; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135549eusmtrp2a092f04f72f32deca907d314cdbdbe2a~GUVg_3kxB2320823208eusmtrp2r; Tue, 19 Sep 2023 13:55:49 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-68-6509a8655322 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 00.55.14344.568A9056; Tue, 19 Sep 2023 14:55:49 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135548eusmtip10e8f5eaa57c7ececc0fd70ba9f61c00f~GUVgvl2li1382813828eusmtip1a; Tue, 19 Sep 2023 13:55:48 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 19 Sep 2023 14:55:48 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 19 Sep 2023 14:55:48 +0100 From: Daniel Gomez <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: [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Topic: [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Thread-Index: AQHZ6wD9pblMkq2/yUu1kd4yGg7G6w== Date: Tue, 19 Sep 2023 13:55:47 +0000 Message-ID: <20230919135536.2165715-3-da.gomez@samsung.com> In-Reply-To: <20230919135536.2165715-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Sf0yMcRzH973nueeeO07PXakvkjk/NsXphD1NrE3y+JU2P4fFqa/OXCd3 Hfm5hriaYSrc0+knSYXdlTqnQkwlJ2lomSy7s2Q0ISoV3XNZ/70+e38+n/f7s31ITFrHn0ju 1iQgrUaplhEivPxJ7/M5qFCIAiseTKVNt0sIuvjdOYJudoyjnd1ncbqqNYCurKrH6WabiaDb Sob4tO2PVUC3nHcCuuBnl4C+Z84j6P7fJiJUzGQmNeFMjkXPlBb6M812PWMpSiEYS/cFAV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635bf X-Msg-Generator: CA X-RootMTR: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf References: <20230919135536.2165715-1-da.gomez@samsung.com> <CGME20230919135549eucas1p1f67e7879a14a87724a9462fb8dd635bf@eucas1p1.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]); Tue, 19 Sep 2023 06:58:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777475153546484183 X-GMAIL-MSGID: 1777475153546484183 |
Series |
shmem: high order folios support in write path
|
|
Commit Message
Daniel Gomez
Sept. 19, 2023, 1:55 p.m. UTC
Both shmem_free_swap callers require to get the number of pages in the
folio after calling shmem_free_swap. Make shmem_free_swap return the
expected value directly and return 0 number of pages being freed
to avoid error handling in the external accounting.
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
mm/shmem.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
Comments
On Tue, Sep 19, 2023 at 01:55:47PM +0000, Daniel Gomez wrote: > +++ b/mm/shmem.c > @@ -846,16 +846,18 @@ static void shmem_delete_from_page_cache(struct folio *folio, void *radswap) > /* > * Remove swap entry from page cache, free the swap and its page cache. > */ > -static int shmem_free_swap(struct address_space *mapping, > +static long shmem_free_swap(struct address_space *mapping, > pgoff_t index, void *radswap) > { > void *old; > > old = xa_cmpxchg_irq(&mapping->i_pages, index, radswap, NULL, 0); > if (old != radswap) > - return -ENOENT; > + return 0; > + > free_swap_and_cache(radix_to_swp_entry(radswap)); > - return 0; > + > + return folio_nr_pages((struct folio *)radswap); > } Oh my goodness. I have led you astray; my apologies. shmem_free_swap() is called when the 'folio' is NOT actually a folio. It's an 'exceptional' / 'value' entry. We can't do this. Do we encode the size of the swap entry in the swp_entry_t or do we have to get that information from the XArray (which no longer knows it after we've stored a NULL there)?
diff --git a/mm/shmem.c b/mm/shmem.c index de0d0fa0349e..5c9e80207cbf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -846,16 +846,18 @@ static void shmem_delete_from_page_cache(struct folio *folio, void *radswap) /* * Remove swap entry from page cache, free the swap and its page cache. */ -static int shmem_free_swap(struct address_space *mapping, +static long shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap) { void *old; old = xa_cmpxchg_irq(&mapping->i_pages, index, radswap, NULL, 0); if (old != radswap) - return -ENOENT; + return 0; + free_swap_and_cache(radix_to_swp_entry(radswap)); - return 0; + + return folio_nr_pages((struct folio *)radswap); } /* @@ -1008,7 +1010,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - nr_swaps_freed += !shmem_free_swap(mapping, + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); continue; } @@ -1077,12 +1079,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (xa_is_value(folio)) { if (unfalloc) continue; - if (shmem_free_swap(mapping, indices[i], folio)) { + nr_swaps_freed += shmem_free_swap(mapping, indices[i], folio); + if (!nr_swaps_freed) { /* Swap was replaced by page: retry */ index = indices[i]; break; } - nr_swaps_freed++; continue; }