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: 159297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1401340vqb; Sat, 28 Oct 2023 14:17:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfUwialcnwb0vMmP62clzE8JEmM4bY6Q3sJfyKCHDd9ssjb52aPjpRxWtwL1QB85CH4a4I X-Received: by 2002:a05:6a20:748b:b0:17a:de5d:1d7e with SMTP id p11-20020a056a20748b00b0017ade5d1d7emr8173613pzd.55.1698527848992; Sat, 28 Oct 2023 14:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698527848; cv=none; d=google.com; s=arc-20160816; b=Tj6H6NO7/KVNBsz6reWNB4I0l9QpEle3hlslhMTrPUJDDqrqa4V8q5BEjyBDbg9LZt QGIece0u2ySiVw+c8/5h3ytnTyGz9tirIxloudNTIusVx+U45vMpj4cgDGw39VeXZxcY xAYGDMGe+GipuRWAhqt4ZKYEYCN13yZqFEzMEHEq0T2A3SZnsmIZtg6mjW1Y0qicYV3q fyTEODq1ZsXjViHjmS2g9/Udv6VHjhAiE/ox+6Garu1FfKlg+YPxo9etvgjLYnnIq4Ch 6j4pXaUS4oTMsTo4xqw+01u4ln7JHXaxJ4kK9shvXHnc8HzJyRfGPDAE3GvDCW0bChnu EIaA== 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=/CvASZfCabc/Ew9WG/OE+/8Wt2GCjn+VDx2yMe2ZiFk=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=C8VnUPYeYqS1fjoPxmbxhz/VuxJFBFKMA41oY2KcIcVrKjwNjTuTm0u7s678C4IIR+ u3NkpfOBKQMgpmrdNfez07lULKGe6lR/gkwFVdPQPc1SAE8rgqfTe8CD1IiPT3IlVLV+ U2pQDu33cVuoKCih5/AV2Q6HufqU0cHCV4mpfJAkyPj4m+j1kEGljiL2ufE4HYsF4uBx Act+gWVM4rqU5zlYI24B1z+dMNB3mbrbfIMPfUisjMx2rE7JyNesWCsfE7SLFA84C8xA c2tIbzjjy0YuXqhLJ+Nk1cpDSvM5SEpODWJqlzM2WfKQJyNHGabmhOHN4/CItpHQ2r2u omZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d0BEWt0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u76-20020a63794f000000b005aa644010a6si2828025pgc.205.2023.10.28.14.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d0BEWt0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 19D0D806CC20; Sat, 28 Oct 2023 14:16:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbjJ1VP4 (ORCPT + 29 others); Sat, 28 Oct 2023 17:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbjJ1VPt (ORCPT ); Sat, 28 Oct 2023 17:15:49 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF10EB for ; Sat, 28 Oct 2023 14:15:46 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211545euoutp02ada22d889c7a55213f5e8e7d4b210431~SYfwzLCgM0879208792euoutp02M for ; Sat, 28 Oct 2023 21:15:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211545euoutp02ada22d889c7a55213f5e8e7d4b210431~SYfwzLCgM0879208792euoutp02M 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 In27BK6Mm39bmAveSFRMmHSIvYFxn0gXIyeHhICJRNfqZWxdjFwcQgIrGCUeXZjFCuF8YZT4 8uIPO0iVkMBnRom2zjCYjl/HJrJCxJczSpy9lQLRAFTz6P9BZgjnDKPEyS+7GSGclYwSl06+ BRvFJqApse/kJnaQhIjAbFaJw4s7GEESzAJ1EmuezWLpYuTgEBZwkHi7pAQkLCLgKnFtbQc7 SFhEQE9i6pdCkDCLgKrE72W7mUDCvALWEj+u1YGEOQVsJO5/284GYjMKyEo8WvmLHWK4uMSt J/OZIB4QlFg0ew8zhC0m8W/XQzYIW0fi7PUnjBC2gcTWpftYIGwliT8dC6GO1JO4MXUKG4St LbFs4WuwObxAM0/OfMIC8pWEQBeXxNeGLVDNLhI3fmxlh7C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zCKhK/F62mwkkzCtgLfHjWh2IKSSQK9Hf lglSwSlgI3H/23Y2EJtRQFbi0cpf7BB7xCVuPZnPBHG/gMSSPeeZIWxRiZeP/0H9pSNx9voT RgjbQGLr0n0sELaSxJ+OhVD36kncmDqFDcLWlli28DXYHF4BQYmTM5+wTGCUnoVk3SwkLbOQ tMxC0rKAkWUVo0hqaXFuem6xkV5xYm5xaV66XnJ+7iZGYGraduznlh2MK1991DvEyMTBeIhR goNZSYSX2dEmVYg3JbGyKrUoP76oNCe1+BCjKTCEJjJLiSbnA5NjXkm8oZmBqaGJmaWBqaWZ sZI4r2dBR6KQQHpiSWp2ampBahFMHxMHp1QDk/fytR9TvLfETli83Ur+17c7XmwevVNerzoz Z1/Ty5XWT21PfvvuYcp9+YBq0ETujSeLm0Nj+X16t2jZG6VKuljv9GRZdeGRZdtL7rM7xNi3 ltXujS561NBpck7XdsuJ6es3aa+Z+e7m7rsRHCqxE5K18zqVLbdw6JvqFzHN491+aknSTaaI VbL9v/1sdP+d5Fyx/27I3um6p1d8OMm7uM5QVbmrjm8Ly82mo8v+Ha0XdXDzNHHJ3SlnJWf0 4+OxtbGiwvlzZ7w5dtrzZ8sr973zpa8d+sIVfqbj6/QTS+Lzf2kG89xbIbi/VvGGbLfajIem O2xv3Pd+fUjos8EHluizHJv9WW7Mkbp08RhbgLUSS3FGoqEWc1FxIgDmdKNI1gMAAA== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:16:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777494263952570371 X-GMAIL-MSGID: 1781035537861823790 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: