From patchwork Tue Mar 21 00:48:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13182070 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 969DFC761A6 for ; Tue, 21 Mar 2023 00:48:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65EB6B007B; Mon, 20 Mar 2023 20:48:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC5D76B007D; Mon, 20 Mar 2023 20:48:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C664F6B007E; Mon, 20 Mar 2023 20:48:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B8D6D6B007B for ; Mon, 20 Mar 2023 20:48:53 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7E1E4A0D60 for ; Tue, 21 Mar 2023 00:48:53 +0000 (UTC) X-FDA: 80591070546.16.4234E39 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf03.hostedemail.com (Postfix) with ESMTP id 81AF420010 for ; Tue, 21 Mar 2023 00:48:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=y0X51D+L; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=f2iFj0Ln; spf=pass (imf03.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679359731; a=rsa-sha256; cv=none; b=ig3J2Ao6WQ0IzWYU2b0pigfJ0K4rD+Xdzu+wIjVRQauiHQFrnMoDqaf5ct6kIcwg7bhoD2 MCn/fdupHvc0x8UIXQxpr0RDriwrTYdzrXws687ZAkaAtsO8hfY5tbdVsoFBrunoP5WEZD yGjU0FaUzVwn9YFK0SA2aK18laRbXHo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=y0X51D+L; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=f2iFj0Ln; spf=pass (imf03.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679359731; 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=vAnKio6G1pyRKqUfraKaMDB3b315AuN4QEdNLYxwdsw=; b=H9vlOh2Jq2L+k9ENIg0tyD0mwdpr7NC9KC9H9WgfBA16Ff4xfTzYzYUyqNbsZfjkqhUAmd IDwhWN2sYVIpKcbfTRSJhpGUzvuyIwINqryDNOJ7C7xw6wER0qOkdpChrFgGITwCf1CKMl 7D4PYhSaXNwo+5+4iQfHsq6yT0qQ00I= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1801D5C019D; Mon, 20 Mar 2023 20:48:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 20 Mar 2023 20:48:51 -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= 1679359731; x=1679446131; bh=vAnKio6G1pyRKqUfraKaMDB3b315AuN4QEd NLYxwdsw=; b=y0X51D+LQ86Kr2xYgtguu+CJsOoj3uGl1Biz+j6wtuucwB8Ul7G 1WU7SRSXYafwqUPT96W18O3eN0WP6EQ6gZJBfE7X7FtfP2DjlchcHq/YTkuOYxX0 NzareEUASz6hZ/r+xDoITDNVfwTl1xVKrVc5i9Ssgcr3UH65mCtpXHwuEg36qoNo 8p5VAs4u3KNLaBS7ErqjpQTq4F/u/FWtG+3b/sSH8E+JHm0AON8fDrdhSX7zSOOb pGdaU3jrncLEPT4epAOqz8dVLoWgrIyeU+Cbs2RGABx8EmNtYBCNSC+g+u/r5J46 wioYomd8A8HnLYPzzvXocT345MYdbUScO6Q== 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= 1679359731; x=1679446131; bh=vAnKio6G1pyRKqUfraKaMDB3b315AuN4QEd NLYxwdsw=; b=f2iFj0LnxbayE/fbdq57CRZmIzsyJ82mp2azTzaS663PefKwqL+ E94QFUztNR9qdKpPQi4ujDylfOkDKesls2LeDiVSRazIzMyIqviHl1iwWZafTozc 0gvkT43UqlIKu9sAcuCWJPBuyQBgyzIuwA0rZhNdXZgYMmqQqWMKYZ/eJLVrIgWB UT1OekG3FNdH+NmxwVpnNgX4JYJrbhU8fNNr7lAHSCCYonAArOJalBP8mQQaXJWo kj7pNe1mn6Mu8vwuvKgPMhUyNS9iJCAZQDcCyd35kd4WNKm4lWLdHenocZOSV2vG +01s43WmMNNACWLTWXTyMemqRH/Jwc/5Cxg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefledgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhhrggfgsedtqhertdertddtnecuhfhrohhmpegkihcu jggrnhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeegge ehudfgudduvdelheehteegledtteeiveeuhfffveekhfevueefieeijeegvdenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeiiihdrhigrnhessh gvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Mar 2023 20:48:50 -0400 (EDT) From: Zi Yan To: "Matthew Wilcox (Oracle)" , Yang Shi , Yu Zhao , linux-mm@kvack.org Cc: Zi Yan , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/5] mm: page_owner: add support for splitting to any order in split page_owner. Date: Mon, 20 Mar 2023 20:48:26 -0400 Message-Id: <20230321004829.2012847-3-zi.yan@sent.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230321004829.2012847-1-zi.yan@sent.com> References: <20230321004829.2012847-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 81AF420010 X-Rspamd-Server: rspam01 X-Stat-Signature: k85owg4q4sdwdotb7b9hx4csdc33ku47 X-HE-Tag: 1679359731-80351 X-HE-Meta: U2FsdGVkX18h73XW7Vult9jfY0WvjmfgSlBgYX8gH25knElllw8vX3HXHaHXEc4YMVPSNZiEl5JyJjIueJ28Y8QeSJ9Kye5mvGBiY0h4Xhge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fuPkZx/VfPngo3KxI37EtKypQFLF6JqcD+GhjnkcQlp1sxPOiNYiHbjE/Ef/C2teJ8vhnNJFsISWDd6nYb1o1/xTZ9XxKOWa9YcMYoK5/WD4HL94S78fa1DOK20UEB1WU0PSs2zgBeOzp+lYBAetHSvBSHrE+QPYtywhjWDGni0nLTD+s0fpUElXE4kpR9oESqAAAFfp6Btj5LRDY1OSbDP7sVn4wlWgqxlkQkLYuO8pa35s7gMC5IOnUTcTS5RIhv9nuTHQC/3od1MjmtaBMM8m0xfN/BGRxd1QsfgnwY3BhtDl2Qie8+RhmAzxMQV5LbL8p1BsBml+VRWZ4w== 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 and uses old_order instead of nr to make the parameters look consistent. It prepares for upcoming changes to support split huge page to any lower order. Signed-off-by: Zi Yan --- include/linux/page_owner.h | 12 +++++++----- mm/huge_memory.c | 3 ++- mm/page_alloc.c | 6 +++--- mm/page_owner.c | 11 ++++++----- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h index 119a0c9d2a8b..67d98de3d5a8 100644 --- a/include/linux/page_owner.h +++ b/include/linux/page_owner.h @@ -11,7 +11,8 @@ 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, unsigned int nr); +extern void __split_page_owner(struct page *page, unsigned short old_order, + unsigned short 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 +32,11 @@ 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, unsigned int nr) +static inline void split_page_owner(struct page *page, unsigned short old_order, + unsigned short new_order) { if (static_branch_unlikely(&page_owner_inited)) - __split_page_owner(page, nr); + __split_page_owner(page, old_order, new_order); } static inline void folio_copy_owner(struct folio *newfolio, struct folio *old) { @@ -56,11 +58,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, - unsigned short order) + unsigned short old_order, unsigned short 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 30e3e300c42e..710189885402 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2511,6 +2511,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, struct lruvec *lruvec; struct address_space *swap_cache = NULL; unsigned long offset = 0; + unsigned int order = thp_order(head); unsigned int nr = thp_nr_pages(head); int i; @@ -2556,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, nr); + 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 59c2b6696698..ec85562865fb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3530,7 +3530,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, 1 << order); + split_page_owner(page, order, 0); split_page_memcg(page, 1 << order, 1); } EXPORT_SYMBOL_GPL(split_page); @@ -5746,8 +5746,8 @@ 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, 1 << order); - split_page_memcg(page, 1 << order); + split_page_owner(page, 1 << order, 1); + split_page_memcg(page, 1 << order, 1); while (page < --last) set_page_refcounted(last); diff --git a/mm/page_owner.c b/mm/page_owner.c index 31169b3e7f06..33d1b6efe6a6 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, unsigned int nr) +void __split_page_owner(struct page *page, unsigned short old_order, + unsigned short new_order) { - int i; + int i, old_nr = 1 << old_order, new_nr = 1 << new_order; struct page_ext *page_ext = page_ext_get(page); struct page_owner *page_owner; if (unlikely(!page_ext)) return; - for (i = 0; i < nr; i++) { + for (i = 0; i < old_nr; i += new_nr) { + page_ext = lookup_page_ext(page + i); page_owner = get_page_owner(page_ext); - page_owner->order = 0; - page_ext = page_ext_next(page_ext); + page_owner->order = new_order; } page_ext_put(page_ext); }