From patchwork Mon Apr 3 20:18:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13198730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85A9CC761AF for ; Mon, 3 Apr 2023 20:19:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B519C6B007E; Mon, 3 Apr 2023 16:19:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B01D36B0081; Mon, 3 Apr 2023 16:19:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DFC3900002; Mon, 3 Apr 2023 16:19:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 74EB56B007E for ; Mon, 3 Apr 2023 16:19:09 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4765EABDA6 for ; Mon, 3 Apr 2023 20:19:09 +0000 (UTC) X-FDA: 80641194018.22.67C776C Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by imf16.hostedemail.com (Postfix) with ESMTP id 255F8180004 for ; Mon, 3 Apr 2023 20:19:06 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b="nz/6OkYj"; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=N+H9wuit; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf16.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.27 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680553147; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/Fyda6DdrS5eQAxPutJLWU7rPSEY+1UbDEAwHHIWfJU=; b=lPkB7Vw4YEezYRokPRhnGUh4oGdkB7FLLB5PuVYQjSfmdz6juxHZEPiIrf81pR3Yk0frJ/ RlmolN7GocGj5iGGCvfMHBjUp0dz2KQzP5ZN/OhJPZhcwDcTsQw8kY53w+A02CjrCuIBYV hsKyH7u+8ZRfmWsza/zIdcNt6qfhDVo= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b="nz/6OkYj"; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=N+H9wuit; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf16.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.27 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680553147; a=rsa-sha256; cv=none; b=bkNcPuZwyScil41+JG2GDbc36AAdlca8/c4jJMjwK1XCvTC6lM3XwM79jRvH8jmMdrhm5D O3YolR5QKq0ETZ558f/UB9qlVpf3jQpub5S06s1sLuP5NWeI7BmVJn8NgK4762mfUtKuuu joXxFiOL+JP3fmkz4Tank+ifPsEEfXo= Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7DE075C01D4; Mon, 3 Apr 2023 16:19:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 03 Apr 2023 16:19:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to; s=fm2; t= 1680553146; x=1680639546; bh=/Fyda6DdrS5eQAxPutJLWU7rPSEY+1UbDEA wHHIWfJU=; b=nz/6OkYjLbCZX+ixfPsX979MsgC+XBBrD4ldyEfa/BZo60sfHsp z/ityPXAu8IL/HKTy3HBCG3CJn6kCJWKjTcsf8y3lAiZlzSuMmKnUEhuRZajXGeo tm2Kslm94MRfstlsxAeWjXTfyZYyVK9zt9N1AocGdn5hWS/lNGatQfldBWmMfkZS dOsE2fMrcgFu2KJ5PFqRylGCWWeHqjxUVlcKN2T2tKEagRTtNo0GpgDrgipRLGEE +uADnX0J4NstF3xR7llS00aEZXSLFOK9VLm52ytHn+6BbMXN8Oq61caDfYiAZUSp b58E1ySQUSi59D7M3+ZB4fBnCBL1mqAQBgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1680553146; x=1680639546; bh=/Fyda6DdrS5eQAxPutJLWU7rPSEY+1UbDEA wHHIWfJU=; b=N+H9wuitSDaOyzs7mde+61NwgHhTfzBzdBVkWra5jyk0ReWUrrX rpK0QabHxDx8blNWX6nbr262B1krQ92qPL7mwEguLhuNhmPrm/bGm1wjNQXDFWF5 5+X8ZeX1Y5++dP1TmUj5rMaUdNfk3xLEcfeJo4fK80qP7qBe0RHLPdJw8eWK3Urr srsfAYspeZ7kyUHsa48gvNQWMyr8JbcqY474rlV3zpWAxJ078HENXuMZS8oA7+D4 a7tOAGxMgd5F1W5jZmpCDFo3sqqIIZk+Y+ftLUZ/esjhYpq1Pb18aoXSKFee6O7I 3U0L7NaJHqMvYxnRnaJoEOMMiF9uRp7atDw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeijedgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghi ucgjrghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepge eghedugfduuddvleehheetgeeltdetieevuefhffevkefhveeufeeiieejgedvnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnse hsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Apr 2023 16:19:05 -0400 (EDT) From: Zi Yan To: "Matthew Wilcox (Oracle)" , Yang Shi , Yu Zhao , linux-mm@kvack.org Cc: Zi Yan , "Kirill A . Shutemov" , Ryan Roberts , =?utf-8?q?Michal_Koutn=C3=BD?= , Roman Gushchin , "Zach O'Keefe" , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 4/7] mm: page_owner: add support for splitting to any order in split page_owner. Date: Mon, 3 Apr 2023 16:18:36 -0400 Message-Id: <20230403201839.4097845-5-zi.yan@sent.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230403201839.4097845-1-zi.yan@sent.com> References: <20230403201839.4097845-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 255F8180004 X-Stat-Signature: me1z3ns9bk69m18m7j19my5jreqimxwd X-HE-Tag: 1680553146-620027 X-HE-Meta: U2FsdGVkX19h0jMAJw5xqE2hTT9zY0RXMmvxDcZMrowgYeO50My1IH+y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BtRXq9OHfhl0qWm21jCCdxcqCz4nU8lQ62tnMpFAO5445MEx8GmwniD+G1uYUaP/lCJG8UN55FOySCrywglK4cIdbZ2bDLrFbTPZ/253RQHHRPb79QILfFVE+HOE979fnRdr5T5RSH37WdOHkL0w2dAyfkatlTAIAoDpQEDQfQMnSQxRHoBXraE/qiR6QtWlUbF4B8MzqMVy9Be7Zcx5HpoD41veKWLFQ5RRcQ/7ZNTVU8Tm4AtfyIftHFEIU062cbbUyydYGy6M9SVBtFXscFwZVAZjBYj/8HV3x6/by7P6kNCvpqfv/JD9dX7CjSGAID2zm+wtCSkBW7iTWC3RNab9lSAd5CFUMmLGO+/XdeLyQJwuwsSpwVEEhv+1kGVQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan It adds a new_order parameter to set new page order in page owner. It prepares for upcoming changes to support split huge page to any lower order. Signed-off-by: Zi Yan --- include/linux/page_owner.h | 10 +++++----- mm/huge_memory.c | 2 +- mm/page_alloc.c | 4 ++-- mm/page_owner.c | 9 +++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h index d7878523adfc..a784ba69f67f 100644 --- a/include/linux/page_owner.h +++ b/include/linux/page_owner.h @@ -11,7 +11,7 @@ extern struct page_ext_operations page_owner_ops; extern void __reset_page_owner(struct page *page, unsigned short order); extern void __set_page_owner(struct page *page, unsigned short order, gfp_t gfp_mask); -extern void __split_page_owner(struct page *page, int order); +extern void __split_page_owner(struct page *page, int old_order, int new_order); extern void __folio_copy_owner(struct folio *newfolio, struct folio *old); extern void __set_page_owner_migrate_reason(struct page *page, int reason); extern void __dump_page_owner(const struct page *page); @@ -31,10 +31,10 @@ static inline void set_page_owner(struct page *page, __set_page_owner(page, order, gfp_mask); } -static inline void split_page_owner(struct page *page, int order) +static inline void split_page_owner(struct page *page, int old_order, int new_order) { if (static_branch_unlikely(&page_owner_inited)) - __split_page_owner(page, order); + __split_page_owner(page, old_order, new_order); } static inline void folio_copy_owner(struct folio *newfolio, struct folio *old) { @@ -56,11 +56,11 @@ static inline void reset_page_owner(struct page *page, unsigned short order) { } static inline void set_page_owner(struct page *page, - unsigned int order, gfp_t gfp_mask) + unsigned short order, gfp_t gfp_mask) { } static inline void split_page_owner(struct page *page, - int order) + int old_order, int new_order) { } static inline void folio_copy_owner(struct folio *newfolio, struct folio *folio) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 106cde74d933..f8a8a72b207d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2557,7 +2557,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, unlock_page_lruvec(lruvec); /* Caller disabled irqs, so they are still disabled here */ - split_page_owner(head, order); + split_page_owner(head, order, 0); /* See comment in __split_huge_page_tail() */ if (PageAnon(head)) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ef559795525b..4845ff6c4223 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2780,7 +2780,7 @@ void split_page(struct page *page, unsigned int order) for (i = 1; i < (1 << order); i++) set_page_refcounted(page + i); - split_page_owner(page, order); + split_page_owner(page, order, 0); split_page_memcg(page, order, 0); } EXPORT_SYMBOL_GPL(split_page); @@ -4996,7 +4996,7 @@ static void *make_alloc_exact(unsigned long addr, unsigned int order, struct page *page = virt_to_page((void *)addr); struct page *last = page + nr; - split_page_owner(page, order); + split_page_owner(page, order, 0); split_page_memcg(page, order, 0); while (page < --last) set_page_refcounted(last); diff --git a/mm/page_owner.c b/mm/page_owner.c index 64233b5b09d5..72244a4f1a31 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -211,19 +211,20 @@ void __set_page_owner_migrate_reason(struct page *page, int reason) page_ext_put(page_ext); } -void __split_page_owner(struct page *page, int order) +void __split_page_owner(struct page *page, int old_order, int new_order) { int i; struct page_ext *page_ext = page_ext_get(page); struct page_owner *page_owner; - unsigned int nr = 1 << order; + unsigned int old_nr = 1 << old_order; + unsigned int new_nr = 1 << new_order; if (unlikely(!page_ext)) return; - for (i = 0; i < nr; i++) { + for (i = 0; i < old_nr; i += new_nr) { page_owner = get_page_owner(page_ext); - page_owner->order = 0; + page_owner->order = new_order; page_ext = page_ext_next(page_ext); } page_ext_put(page_ext);