Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp843099rdb; Tue, 19 Sep 2023 11:47:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiEDILag9HM6bgE9rJBYpPccyNfxPCWjFyQf5inrvDGLG43o8mFYOwbaIwd4Lg7Lzfa6kD X-Received: by 2002:a17:90a:ca93:b0:273:dfb1:2439 with SMTP id y19-20020a17090aca9300b00273dfb12439mr4087101pjt.21.1695149258644; Tue, 19 Sep 2023 11:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695149258; cv=none; d=google.com; s=arc-20160816; b=VyS+8hq7MoJcNVaDH3/1eClYPWjbhwNZIpaaZmsSNiaf3fE5CbbR9/+LUKcnT6Lwok LEx5dmevbQkB1XyOgvj9ibaBA2pH5+bKAj5AWG8U68foRsZQ0VByH3Lrrexx3G2xZGMm xu84LWxEA3WrXYgoMUjYSc7UDgZrlpsfDQNNepDv9ZAFR48uFlAPCGErNAzrixAHA0YW 3MoRHFmFNSNeOsn4fIeHMXK54tW6B6kVN6WhvpY/UuD+ZjNu8Jr4D8M/9ibYpaqLxtid uHryiKSAqZ9A1m3JyYC6xYmuYCvm6cDRiJITFtrsxC/9Z/PGgQDwioP77U+mLnRw0wx/ Y0Fg== 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=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=M2nMBiTZd5j1892QPYWO6TsmBB5jyshwAT0VCE8LY5iwUP2/EW0HHVOxud0F3S/PZL 0pZWVC2VeDjQs3PzH2X3VylnHortWg2EsnMIACoJmoFvQSMQoBZUpvbHmm7U7A7baZ9i b4izlGq0WucL5h3Bx9Zimo2YAXYbXlRdpO+dL6uy6F8WpGdPzVzx6lUNZzNFqp68ZqTz DiU+JhBYtqxmTKWA/JqguItudP3VeoE5UzkvfmxivUHdhZk3P2+0qePpQubbdV6cx2Kq 23FAjxN5XUdKEeu0OwGJLQl7R9gSeJEDcf70mPxhEx8R+i3B7xhewUtPdA6N+YQkkoua p2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tyM4uvQd; 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 Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z17-20020a631911000000b0057790a5a8e7si9980884pgl.190.2023.09.19.11.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:47:38 -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=tyM4uvQd; 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 8643280BCB94; Tue, 19 Sep 2023 06:56:30 -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 S232539AbjISN4T (ORCPT + 99 others); Tue, 19 Sep 2023 09:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232564AbjISN4P (ORCPT ); Tue, 19 Sep 2023 09:56:15 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A01E128 for ; Tue, 19 Sep 2023 06:55:52 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230919135551euoutp02f32555391bed790dd27f9bf2a816b0fb~GUVjcKe_x1585015850euoutp02Y for ; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230919135551euoutp02f32555391bed790dd27f9bf2a816b0fb~GUVjcKe_x1585015850euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695131751; bh=zPiGytBfegEqHRUsVtZKimf8fdUTs88Qyc8YPePHcIk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tyM4uvQdUR1AS3aYkBsxN32j/P4q2FARUnPi8UjEsUaK/RInj4GTTsgiqt3Abi0EZ xPp6E2q79rArO2yh4Pg1Npb2OgCS+RY3naCuqZ/ExDsJ2hMNQOmyGDyPb3/9yCnggt 2eHzkHBjYlJcVe2tWGleBwTU4JIrtv0QzsVvrREg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230919135551eucas1p1c2f79426cc02c6873649747c6b5ebe77~GUVjFDdBx1658916589eucas1p1F; Tue, 19 Sep 2023 13:55:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 23.8E.11320.768A9056; Tue, 19 Sep 2023 14:55:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db~GUVilHeug1635116351eucas1p2u; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230919135550eusmtrp2e393e76eb8216b24e9888cc400ce0942~GUVikiwv92324623246eusmtrp2F; Tue, 19 Sep 2023 13:55:50 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-c7-6509a8674f70 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 32.55.14344.668A9056; Tue, 19 Sep 2023 14:55:50 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230919135550eusmtip17b6283cd8a9ef8f53119b7dcf49ffc0f~GUViY2AR61888818888eusmtip1z; Tue, 19 Sep 2023 13:55: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; Tue, 19 Sep 2023 14:55: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; Tue, 19 Sep 2023 14:55: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: [PATCH v2 3/6] shmem: account for large order folios Thread-Topic: [PATCH v2 3/6] shmem: account for large order folios Thread-Index: AQHZ6wD+Wqd1jPdfPEKUQlAv9fdGJA== Date: Tue, 19 Sep 2023 13:55:49 +0000 Message-ID: <20230919135536.2165715-4-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: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7rpKzhTDb42SVrMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MaTNfsRS8kai4uvAaUwPjPpEuRk4OCQETibMrJzJ2MXJxCAmsYJTYP7mNGcL5wihx fdYtNgjnM6PEkY3/WboYOcBaur+mQMSXM0p0nfvGCjIKrOjUFKjuM4wSc7vXMkE4KxklmrvW MIJUsQloSuw7uYkdJCEiMJtV4vDiDrAEs0CdxJpns1hAbGEBW4n3C7+yg9giAk4Sj+dvYoGw 9SS2zb7DBHIGi4CqxOdTbiBhXgFriVc79zKD2JwCNhI35jaxgdiMArISj1b+YocYLy5x68l8 JoinBSUWzd7DDGGLSfzb9ZANwtaROHv9CSOEbSCxdek+FghbSeJPx0KoM/UkbkydwgZha0ss W/iaGeIGQYmTM5+wgPwlIdDEJfGqYynUUBeJXUtnskPYwhKvjm+BsmUk/u+czzSBUXsWkvtm IdkxC8mOWUh2LGBkWcUonlpanJueWmyUl1quV5yYW1yal66XnJ+7iRGY2k7/O/5lB+P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J/pSJy9/oQRwjaQ 2Lp0HwuErSTxp2Mh1Ml6EjemTmGDsLUlli18zQxxj6DEyZlPWCYwSs9Csm4WkpZZSFpmIWlZ wMiyilEktbQ4Nz232EivODG3uDQvXS85P3cTIzA5bTv2c8sOxpWvPuodYmTiYDzEKMHBrCTC O9OQLVWINyWxsiq1KD++qDQntfgQoykwiCYyS4km5wPTY15JvKGZgamhiZmlgamlmbGSOK9n QUeikEB6YklqdmpqQWoRTB8TB6dUA5P5/KOrf+Q5HfRasdX4ybW+kpuybSYvX79bfZg51+ma YurLWUFnTh1ek3HpLQOLkHjzr7DurS/YQnNWmqye9EPiRvwBrqV6V9b/bj/y2sZ5Bc82zY2p z1lvLBR4u+BrxvMnrA1Xmh46vFSeyvtqrf2NwDrdj+qHzRbdLedcuyVTvJDlt3KleeHRw2r/ 7P5lGS774MfGtjo8XbQshue7561TZ1ZxZKUc9pqWxT7Td8Epg2d8pyZrROQHW6d//CQjeG71 V+Yzt88wpfxYGPusTSU1/KAst5ldK19A1Mygz7mf5XO9CpW4Zj4QPH/F49XJZqG4u/ZXj8he uXbrg+n9Z4xrLzXkuS7f68zpd6lVIn65EktxRqKhFnNRcSIAM2aVQtcDAAA= X-CMS-MailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-Msg-Generator: CA X-RootMTR: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230919135550eucas1p2c19565924daeecf71734ea89d95c84db References: <20230919135536.2165715-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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 06:56:31 -0700 (PDT) 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 5c9e80207cbf..d41ee5983fd4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -871,16 +871,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 =3D 0; unsigned long max =3D end - 1; =20 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 +=3D folio_nr_pages(folio); if (xas.xa_index =3D=3D max) break; if (need_resched()) { @@ -1530,7 +1530,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) =3D=3D 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)); =20 @@ -1803,6 +1803,7 @@ static void shmem_set_folio_swapin_error(struct inode= *inode, pgoff_t index, struct address_space *mapping =3D inode->i_mapping; swp_entry_t swapin_error; void *old; + long num_swap_pages; =20 swapin_error =3D make_poisoned_swp_entry(); old =3D xa_cmpxchg_irq(&mapping->i_pages, index, @@ -1812,13 +1813,14 @@ static void shmem_set_folio_swapin_error(struct ino= de *inode, pgoff_t index, return; =20 folio_wait_writeback(folio); + num_swap_pages =3D 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); } =20 @@ -1905,7 +1907,7 @@ static int shmem_swapin_folio(struct inode *inode, pg= off_t index, if (error) goto failed; =20 - shmem_recalc_inode(inode, 0, -1); + shmem_recalc_inode(inode, 0, -folio_nr_pages(folio)); =20 if (sgp =3D=3D SGP_WRITE) folio_mark_accessed(folio); @@ -2665,7 +2667,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (ret) goto out_delete_from_cache; =20 - shmem_recalc_inode(inode, 1, 0); + shmem_recalc_inode(inode, folio_nr_pages(folio), 0); folio_unlock(folio); return 0; out_delete_from_cache: --=20 2.39.2