Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1547104rbb; Mon, 26 Feb 2024 12:57:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQTk7XpJvg1R85bbaumgNPHpyQRfoLAP9FbRLV8rDnGRai9+vYY7G4MwlQZMeRBYpJLA8x0MeDbzSjrPETAZl9qvqgV+AyPKbC5bti6w== X-Google-Smtp-Source: AGHT+IF3NuDTMCHiT4bthldlGD5pW8CN8+K3qqHi7sVjA5zUC3OXs8X1HfV0nFXcIpMEpuEFvCga X-Received: by 2002:a0c:aa5b:0:b0:690:18ff:9e70 with SMTP id e27-20020a0caa5b000000b0069018ff9e70mr262776qvb.60.1708981035873; Mon, 26 Feb 2024 12:57:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708981035; cv=pass; d=google.com; s=arc-20160816; b=tbr1a38MsQakJz7hIrr9MjYVH5siGqhSGFyL1n6QLvjK3okI0yh6bgHuIxJXy6Pln2 pxtW3pOUnMev9xZ2ISz4KVNyAVGiPCxKk48uAItaxIbJJ1hOhzLJrYdGlDxeHrRpiiID zAgmKYH7LXreqFWLqnmovBXF7nxyvigyMGLKIhnD/G6iZOBiY7u0vrLL66C+Ut8PMqY3 dZnd6zdXWNa2/AywxvyBqoZUA1PcgUmj5cnn8+2tg66rX6V0zbw6d1M4Fe6YJ/LsY/Io 64PptlulKlh1Tpoz5pdFG/gq7rIDVzEVWXtr7j5DyM6/Ng9bpG0kJytPhIE82axHn67/ ye6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=k4tW1Ix2BuSNkN1WHXYSmN5X0ZeSMgYeZ0gG0yp9vIY=; fh=chAWxDyUzR1fRdzViNE01Bcd9wPKK4ot8WI+7Hca+9w=; b=hJktpknBZqFnXCBSR9DDBlggf9C18oWB+nJdxzQW6yZjEI7JE3hxR1PpRjMnNTd+dW S0TSD8W07o1/KOT3eKUbUXbJfyU6U7g3SG2yXktVcLlTgsXvICsAUzlfvA1OzAZpx4h5 aY4ROYlk6PViMn1U1b7zkfed3iy5npu9qjuluURm0jnagnzcLlrbWvTAum2N6Zau348o 1qkxgcesxx+/J1ouzr7QiBOmf22gWec5MVMZIKDGKO/WLZB060MfD0jimpVdoKE/wYUO 6icN63M+CTIc0ct+iIaclpT86n+CmgErqZWARmBfgnykcxYUuHnmZa2C2dFUcnE9s8Ci Oa8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=PsGtgEud; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MXQaLIK2; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-82309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r11-20020a0562140c4b00b0068f7e322364si5861978qvj.176.2024.02.26.12.57.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 12:57:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=PsGtgEud; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=MXQaLIK2; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-82309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 88D051C23D89 for ; Mon, 26 Feb 2024 20:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8736A132C18; Mon, 26 Feb 2024 20:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="PsGtgEud"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MXQaLIK2" Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8207113173A; Mon, 26 Feb 2024 20:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.29 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708980975; cv=none; b=adio0bnwDO7zp9R+ZmuCsQ/KdMWV6jjod1IuwIV+zKJxgMM1rCZhe1zb7bz2JYl4oEcvmT0ze9uGu7aQXJZxjgICezpqueMDQ6eiQc1TomjOtAKkLnWOW8DshKdS+Z1zzBNzKuRz+d6XkT4wkaOXI1LPSE0Pc1Hpn4XOu6NLfME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708980975; c=relaxed/simple; bh=HbrSwnkkjzgDPr9Qqs/XsufXHKtUIzBk6wsYMI1kzqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OZFTAulElikRLo8Aaybe96XnzAE8A7B/OZRPl6QkejgnPKADrxKakUA3iWIZCa8HtIENNhx6HoDnZcfEQ+r2/dOWORhcnLaelkPzdwoImPrOD12rlK+zUQSTsxkUcGDCGzNJ+FMhqi52w1EyGlMOwn6hjnGzpCwoBLYIfWo7qPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com; spf=pass smtp.mailfrom=sent.com; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b=PsGtgEud; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MXQaLIK2; arc=none smtp.client-ip=66.111.4.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sent.com Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 845035C0083; Mon, 26 Feb 2024 15:56:12 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 26 Feb 2024 15:56:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:reply-to:subject:subject:to:to; s=fm1; t= 1708980972; x=1709067372; bh=k4tW1Ix2BuSNkN1WHXYSmN5X0ZeSMgYeZ0g G0yp9vIY=; b=PsGtgEudtl5OWZIMN/QmYcFTzFIwskYJv2SShnXgHjfbIBRHd6c tLFxkANerh0TDSw0aIJ+BRFw3TtwrtnEWmHqtjReaka5XRT4kCVu+/JxTHJUARVP TTaS/ervzETdMoGvlOvQkGU5Vr8k5tDe2HWq4O22UqWyxXceqtEs8oF4xp6w3ILj E+Nn7cDMv2KP+WObR1wfXgZt4SVjLn62IgkbUTVyraMDgD4LC0tnPeSgCrhiQXlI dpijTzey8JMArvsD76watmwYOLbgBoLoa6lmS0djEggreXdhpxLkoa+zAeqDTiVh XpV3/H7xUFtWwTsw2W+RLI8tAthTa0kVP7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1708980972; x=1709067372; bh=k4tW1Ix2BuSNkN1WHXYSmN5X0ZeSMgYeZ0g G0yp9vIY=; b=MXQaLIK2tOLWX7tSDG9quAtyz0XtE5uEWLvjXAt6WWz4fuCtIq+ iW5V2mlkR6XtmBDh4IXp0NZH4C8YwuqKervIeM/9EVpHBYcPoWcIkSre/3nQS4z4 deN9QC9eqGj98qO7roEFIt9SV8tO7akXARi4gsDw06jxzAwz5zubvukbV7i4gDO/ zRNBPrfZQzljXqj9vbHt0+V2dLDxewtoVWSQgxCBKRL013TC1g1nj0dxzgkun57/ ZLz8/iUoCZO+anVVQtkHxMUVyw526I4oYS5ikt412Vg+KTvUHxFRAI9uUJp+t7bp th0cOJ+ulQTE92LtOYFZ9c3xS3VyDo9UjLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrgedvgddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhhrgggtgfesthekredtredtjeenucfhrhhomhepkghi ucgjrghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepje ekteekffelleekudfftdefvddtjeejuedtuedtteegjefgvedtfedujeekieevnecuvehl uhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnse hsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Feb 2024 15:56:11 -0500 (EST) From: Zi Yan To: "Pankaj Raghav (Samsung)" , linux-mm@kvack.org Cc: Zi Yan , "Matthew Wilcox (Oracle)" , David Hildenbrand , Yang Shi , Yu Zhao , "Kirill A . Shutemov" , Ryan Roberts , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Roman Gushchin , "Zach O'Keefe" , Hugh Dickins , Luis Chamberlain , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v5 4/8] mm/page_owner: use order instead of nr in split_page_owner() Date: Mon, 26 Feb 2024 15:55:30 -0500 Message-ID: <20240226205534.1603748-5-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226205534.1603748-1-zi.yan@sent.com> References: <20240226205534.1603748-1-zi.yan@sent.com> Reply-To: Zi Yan Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit From: Zi Yan We do not have non power of two pages, using nr is error prone if nr is not power-of-two. Use page order instead. Signed-off-by: Zi Yan Acked-by: David Hildenbrand --- include/linux/page_owner.h | 9 ++++----- mm/huge_memory.c | 2 +- mm/page_alloc.c | 4 ++-- mm/page_owner.c | 3 ++- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h index 119a0c9d2a8b..2b39c8e19d98 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, unsigned int nr); +extern void __split_page_owner(struct page *page, int 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, unsigned int nr) +static inline void split_page_owner(struct page *page, int order) { if (static_branch_unlikely(&page_owner_inited)) - __split_page_owner(page, nr); + __split_page_owner(page, order); } static inline void folio_copy_owner(struct folio *newfolio, struct folio *old) { @@ -59,8 +59,7 @@ static inline void set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) { } -static inline void split_page_owner(struct page *page, - unsigned short order) +static inline void split_page_owner(struct page *page, int 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 96ac7c62c375..2b95dbc95fae 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2933,7 +2933,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); /* See comment in __split_huge_page_tail() */ if (PageAnon(head)) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a7a96bc97e0b..eae77e76a671 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2652,7 +2652,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); split_page_memcg(page, order); } EXPORT_SYMBOL_GPL(split_page); @@ -4839,7 +4839,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, 1 << order); + split_page_owner(page, order); split_page_memcg(page, order); while (page < --last) set_page_refcounted(last); diff --git a/mm/page_owner.c b/mm/page_owner.c index e56c1e92eccf..b678f7a6e702 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -306,11 +306,12 @@ 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, int order) { int i; struct page_ext *page_ext = page_ext_get(page); struct page_owner *page_owner; + unsigned int nr = 1 << order; if (unlikely(!page_ext)) return; -- 2.43.0