From patchwork Tue Feb 13 21:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 200674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp829955dyb; Tue, 13 Feb 2024 13:59:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyQfa1Dwni8TjXwn4uEeeztLtOqAP41OLMD/35M+G1JvLhYJiyfXuxPsFVScwElxOd2oZsDZ4I3XY0N8XGMUxSCHgNvA== X-Google-Smtp-Source: AGHT+IEj9oXcEXCtr+MjrEyGbWLCbiCT1egz39gLzRDyV5HlsH2e54BRuJz+yXe+B4iw/gusV+t0 X-Received: by 2002:a05:620a:100d:b0:785:c124:4fab with SMTP id z13-20020a05620a100d00b00785c1244fabmr936774qkj.10.1707861562580; Tue, 13 Feb 2024 13:59:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707861562; cv=pass; d=google.com; s=arc-20160816; b=bv9mU3qySd6UcP3hINhl51Slax1sucrj5oMpB2LaVUHLaDy+EWTlCqFCxmlcmxg1uU X0Z7MvjzchbQEG8y232agSD1cb+4woObBnxNVJbHitS+0ER7pKRkvmNzB34vDkyvZ1Xy 3JsmlGK05bFcTjk7u1ZVzCkbc4CN1pqpo03sBZf6JK1yIbkpPaqTj2VN8sUPiJYKu3Wb M+WyUt2D9w8orhGgoxKjcJUW8CzsoSGke8vogi4pAI1UvfIbKBieuZ7Pq5Y1Mx27t8Ha tIJt3wveTC5hx5CuE9O5jgAHzlmRJb6pkuGgFbyZjG7AT48N1v/bv7VDzV3++qi1mcDM xcrQ== 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=wJBfeFCeCXlsVboyNZCAlUASDo+mI/mq6x/aZS6p7CI=; fh=cZc3aR52obEN0u1wpSRQjctA896xqXbcdttYaUO3C8o=; b=dnJ/56HOjVChUx7SX3ndGIueKYb24BpJ8RMeW5A0dBVsk24+8N/7A2KjY4BsbSu2ng iyjgREIgcLasIA0i+V3+fLa6LUN0UT6kU39dbKDY4QcDo6ecDMNc1Wnr7CLVdL6nisWD jlQf/gAqrQt4UnJovakuQBSY2mG/BZlCFKQJXFAmak6ZwOO1viExB4Fn7Ie7GI3mhlwq 4a5Y3FwlelsY0utsYnE5hej9cb8DK4MnJ2qHzhAAZik/4LuzCK2AtTtrNU+NuxK+Csba VKSE8YPWqybfk3ekjzuVxj+x8R6AYUFb8AVYTQo+zvBiW0YIbuA2bMPjiEvsuT0hZoAj WiMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sent.com header.s=fm3 header.b=IFte4mTO; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OUf61+g9; 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-64392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com X-Forwarded-Encrypted: i=2; AJvYcCX2q1cHY8SpvJrQ97P6SN2aNM6wc8DpRf1ZGNTc17oSKs2e1hhqna0KrfxeCC1xT6A/3NRzu84S9R98LNq5jrMEJU/E2g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z23-20020a05620a101700b00785c0ad1601si9314134qkj.22.2024.02.13.13.59.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:59:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64392-ouuuleilei=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=fm3 header.b=IFte4mTO; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OUf61+g9; 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-64392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64392-ouuuleilei=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 517A91C229D9 for ; Tue, 13 Feb 2024 21:59:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0E8B63517; Tue, 13 Feb 2024 21:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="IFte4mTO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OUf61+g9" 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 C53A86217C; Tue, 13 Feb 2024 21:55:49 +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=1707861351; cv=none; b=KApB2vSCBMkaPKcwGah88sH6SwMhT2yIeFDg2h6DdBYrFVO/x8UEuqxq5urz3zrA1n7ysgrcZb/ZpSvnxA5zx9RkbuTJtTzYupMNlepIDCN7VhYNZke89Owf89a4t/2sEPxUktpwXcsLRcg0rb2kOqk170zNow4Owl8jY4veTJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861351; c=relaxed/simple; bh=W+t9ky4Cs9vVz5Q7cEU44YRwRv+9h4htLo26lHE7ZEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aunpMtXRo2FaTf281ZZ8zyIVKIS8iz42YQgGmRst4s8g7dBx7G/LBx1XNBt1sG9jfUYssdNSolIyJ12cxAjN9sBiLEUbJSbcNNyMc1A/Th09j3dJm+ib6TnAcZWyU2Ut+P2MKWutHx6N457LS0+SYnXLRQ3Qig5CrEGVnbP8fSs= 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=IFte4mTO; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OUf61+g9; 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 compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9DBE15C010A; Tue, 13 Feb 2024 16:55:48 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 13 Feb 2024 16:55:48 -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=fm3; t= 1707861348; x=1707947748; bh=wJBfeFCeCXlsVboyNZCAlUASDo+mI/mq6x/ aZS6p7CI=; b=IFte4mTOyYLgDFzhTe1Wzq+D8KLldWfEdKzAAWhih+Jc94YdTIO R0BPQL5lKaXGs6sCl8paJTtefcKhm9m0bRwd/i6kdUFAuiPIMec2zURErXQ9n9sl kS6nagE2F7UorEzQnFoYn61dJNGJG5pkVoMNakmIrcraDu19kx5UHG5A9ynE67xO 7Uo/+Y2qjRm6uGlG13h3taJdK72R2jbLwghg9moZPJsmub8Q3Uzx3DI65/NFjREL of/pmsNfUj1phFgchBQ069nJ6mI4Q0BTUPTITAJQMiR5BKhmq8T6VS4FJsbBZsas arxVzg3miTSIGfy9pFSECe+I8Y6WQ4ia+bQ== 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=fm3; t= 1707861348; x=1707947748; bh=wJBfeFCeCXlsVboyNZCAlUASDo+mI/mq6x/ aZS6p7CI=; b=OUf61+g9RDW6eTwtmDEW0Y+9JYoyVi7jrk/8UURdj3XuQ8gJdqi D+Wm7S4JwLfZft36Xex237rwqqDOrYIAB8Vn4FC1eTEZrVPqTBeoYBltVx/8FyCb Xo2zmq/GKvveXx+/iA1jH7puduI3eQGrFpDrnHVFY/zhrVQvaXV/E/vlZ9POzSLY fyA1PPAPdyI/pN/tA1j+iaX5D2ROugh0o6JwgzqGQVLuppBadE1gVPR4m3NFqSNS m6QQvw7RO1QIS/sA9XMFPYx9i4liYS94t6zWHI9cCo4SHbXczMt38B7vVW/oZH6/ NIpeymsD6Ee0PX4V35EFUeGscJb/jyKAx+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehgdduheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhhrgggtgfesthekredtredtjeenucfhrhhomhepkghi ucgjrghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepje ekteekffelleekudfftdefvddtjeejuedtuedtteegjefgvedtfedujeekieevnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnse hsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Feb 2024 16:55:47 -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_Koutn=C3=BD?= , Roman Gushchin , "Zach O'Keefe" , Hugh Dickins , Mcgrof Chamberlain , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v4 2/7] mm/page_owner: use order instead of nr in split_page_owner() Date: Tue, 13 Feb 2024 16:55:15 -0500 Message-ID: <20240213215520.1048625-3-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213215520.1048625-1-zi.yan@sent.com> References: <20240213215520.1048625-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790822645888381458 X-GMAIL-MSGID: 1790822645888381458 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 | 8 ++++---- mm/huge_memory.c | 2 +- mm/page_alloc.c | 4 ++-- mm/page_owner.c | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h index 119a0c9d2a8b..d7878523adfc 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) { @@ -60,7 +60,7 @@ static inline void set_page_owner(struct page *page, { } static inline void split_page_owner(struct page *page, - unsigned short order) + 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 0cd5fba0923c..f079b02f1f59 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2919,7 +2919,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 7c927b84e16c..b6e8fe6fed67 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); @@ -4837,7 +4837,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 c4f9e5506e93..1319e402c2cf 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -292,11 +292,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;