From mboxrd@z Thu Jan 1 00:00:00 1970 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 CE65EEB64D7 for ; Sun, 18 Jun 2023 07:09:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 559686B0071; Sun, 18 Jun 2023 03:09:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5084D8E0001; Sun, 18 Jun 2023 03:09:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F7C06B0075; Sun, 18 Jun 2023 03:09:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2EDE56B0071 for ; Sun, 18 Jun 2023 03:09:34 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E7D831203F2 for ; Sun, 18 Jun 2023 07:09:33 +0000 (UTC) X-FDA: 80914993026.16.C5C5718 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 308A718001D for ; Sun, 18 Jun 2023 07:09:31 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WZCy4MTg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687072172; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KVT5uM6e6Oc6CWtleLyBGYVLuDCY6N7QaXZiONr/ovU=; b=zW/SZ8ZlLNVGeCJb+qbrg8yacGyK1BvIVzii5n4IN2sgpzrWSzx2qxxj+oXX3HsPkBA2MJ 7FbBA8smqvg3RCh4v5LRC2NdsDL4UeiCzKwdP1ZVo4yMYY1vRZMXbI+y8Kf1s8veM9ll3J ANDjHI9gHP7kQDkZrEPBn8MCgSIMy5s= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WZCy4MTg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687072172; a=rsa-sha256; cv=none; b=cKTNqGyHeEhkMb8parZ/NZ/wvzAGPRVJyvFp7mGhrOkubpL+TpPg75E144CYuU0PLTBRvn V3O6J/LLUjXWyqULHqvMsY5u6cKNIg94HUASoFudupf4ZW5Y/+G70qqFKMB32LlIgaf+3t XK8zL2Gb93Hvevpc4TErrHEwdhH7Qmg= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1BBCA60DE1; Sun, 18 Jun 2023 07:09:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62BC4C433C0; Sun, 18 Jun 2023 07:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687072170; bh=JtfdClECfN8YVYAgrgvYa8BILPJkj4nOja+go6KxzGk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WZCy4MTgaNYHL74aVzpVXXxSsnRC+Jc60nwps7hpZerQU0Cq/6p1QNRE02uqQ44vv SP41j7Zox7ACcdHNTfSysULK6V3d2L160EM2s4yTFKERK9vO5qfWPxNJVkyf7x1k+n pQQZ22VH66BKf1AOiIkON22JcHBHntmadMVibOzEp7W2CuXPy+RBWYDgYJ9Xk4V9rU A4vkl947/aPk6vk5rCmiHz7W4OwZIWC95rnL7sm5WEMCza/DmiwXdyqWdroykxHBjd BKKyT8E+ABUQaNGb76htQU8+GQ2PNvT9GENqQJ34+zRrJ2sUnqSSTCCrIF45XSJfbW 84+gotcSUkOVA== Date: Sun, 18 Jun 2023 10:08:50 +0300 From: Mike Rapoport To: Liam Ni Cc: dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, akpm@linux-foundation.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] x86,NUMA:Get the number of ram pages directly in numa_meminfo_cover_memory() Message-ID: <20230618070850.GY52412@kernel.org> References: <20230615142016.419570-1-zhiguangni01@gmail.com> <20230615170011.GK52412@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 308A718001D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: fc13a74egz4jgxsz94ui8w7oohwa61bz X-HE-Tag: 1687072171-748932 X-HE-Meta: U2FsdGVkX1/BI+3p+iXrAHzvm9DZCQb8CrFrfCrCFNfhH2F4SY8+VsMimRtU9Qs+dg2J0kUx1zhW2HnDG6sphJJKcOVQu3KP7awwqK9JRrX2+86K2PFWGqAEF8tYWuqpVLuZcWB/mpKG+4dQvtc9a9f7iOcX17c8bzbhJLoFeZ+/ibsOEYMzq3PljtY6AMyt9b8A6KDmpJ5Z+KQxvoSpd55FTp37ZVaOa1jwJeLX9TlEpnabkanyZC7JgpOMBk5ws0YnHDELinCljkp6YcubDvpDYbHqF/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zSsTb2RSmM5UWsxl3xBXElVGWMDsEzWw6L8vTYRfc33I0Q= 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: On Sat, Jun 17, 2023 at 06:47:11PM +0800, Liam Ni wrote: > On Fri, 16 Jun 2023 at 01:00, Mike Rapoport wrote: > > > > On Fri, Jun 16, 2023 at 12:20:16AM +1000, Liam Ni wrote: > > > In a previous implementation,The ram page is calculated > > > by counting the number of holes, > > > however,the number of ram pages is calculated during hole calculation. > > > Therefore,we can directly calculate the amount of ram pages. > > > > > > Signed-off-by: Liam Ni > > > --- > > > arch/x86/mm/numa.c | 4 ++-- > > > include/linux/mm.h | 4 ++++ > > > mm/mm_init.c | 33 +++++++++++++++++++++++++++++++++ > > > 3 files changed, 39 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > > > index 2aadb2019b4f..8ea0e956e3d7 100644 > > > --- a/arch/x86/mm/numa.c > > > +++ b/arch/x86/mm/numa.c > > > @@ -461,12 +461,12 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi) > > > u64 s = mi->blk[i].start >> PAGE_SHIFT; > > > u64 e = mi->blk[i].end >> PAGE_SHIFT; > > > numaram += e - s; > > > - numaram -= __absent_pages_in_range(mi->blk[i].nid, s, e); > > > + numaram += __available_pages_in_range(mi->blk[i].nid, s, e); > > > > This is wrong. You add number of pages in range core MM sees to the number > > of pages covered by the numa_meminfo. > > > > More generally, rather than traverse all the numa_meminfo's and for each of > > them traverse all the regions in memblock.memory it's enough to count > > memory in memblock that doesn't have the node assigned and compare it to > > memblock_phys_mem_size(). > > Logic like below? > static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi) > { > u64 error_value; > error_value = pages_without_nid_in_range(0,max_pfn); > if ((error_value ) >= (1 << (20 - PAGE_SHIFT))) { > //print error information > return false; > } > return true; > } > > I can't figure out why compare it with memblock_phys_mem_size(). > The number of pages in memblock that doesn't have the node > assigned,which also means that these pages are not in numa_info. > So these pages can represent the number of lose pages. Yes, there is no need to compare with memblock_phys_mem_size() if you count pages that don't have nid set in memblock. > Thanks > Liam Ni -- Sincerely yours, Mike.