From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796066293; b=ACf9C6OxnX7vqKeI79IdhYsCDK48ejfCKctzwUWYBV8l+51s2XUpulhuLTZ/U2V0tuWZ 4HMMHnKiSjVLsxkV4aw9KO87egQ/vDjCcy2pVaPVdml0AaOi9ydKXSW2vFrqzdTCG4HvG GeDamZiDYG2cbotYZzWR8sU3PPkCZDOM1mhw6UKcrKmBxnzYv4ghG1eNkEyNdtCjOUG95 hdrJYnSEkfJEAd/NWq3QZTqdPUYH2xeAVNru8tC2GAt8Bau63j0eeBmEo7CttsMuK8awK pcXOZ0JZzy+EMuhYwXKUmseEzQ3CB5TX+hiSm02H4o7u6S3HdCWncRTnVl0rZeMQTYw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796066293; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Subject:Message-ID:Mail-Followup-To:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=e0jMNnS2iXl0w9BU16JEmjAAAZM73DmVU0PBiZOx3c4=; b=B45lZX9OJOZdxuQkqIVMMnd+1NIVqInBodHej72dGJH0FxQaLZ3VrzqJP8YkpwvZ3KLa xo/P10wLitcn+dKTwspCKlXlhaHGWg+4PUKSu4D0WIHpnNvu4PECNzf4IGTvbYITSzrO6 E8e7YhlJXrm/Av5NDE2JqSlEqEbuLZ/iNyK4bZ+RllldQ/YQO4Dhsei9piF6KZUVzpY6F R94/3e0KQb9rHA3vW5vID06lJDPoR6svMMWkN5PtpFYqtKKaX0x31dDGmNAqqpGu5F5aA VxWLPxDyNy1DSQC4qpfjSqhpHg7v37oD28YkMkF4QVRTj0pXFpE+2wfPdU0wZO3HaSg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=urQoJ4gq; arc=none smtp.remote-ip=209.85.210.51 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 901F1606A687 for ; Mon, 30 Nov 2026 19:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 901F1606A687 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=urQoJ4gq Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-84a248254f4so6387534a34.0 for ; Mon, 30 Nov 2026 11:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796066292; x=1796671092; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:mail-followup-to:message-id:subject:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=e0jMNnS2iXl0w9BU16JEmjAAAZM73DmVU0PBiZOx3c4=; b=urQoJ4gqhD63nOmumzC/OciKJSOynvG3kPFnEPWsJaBBm2vTwN92Qu3SQzpCSMGeAj LWPS4FkF7I1wIazKdejwj6cCFffSIaxe3Q9IcKq5rWezPKu1xULesjAZdFywTnQx9s+f LQeyUmYVH28GkmbogKkuu7dSXOLPUQbxc+O8PYoplt3Iuy7BqnwOyL51+I1xdCxs6sDZ 06ikKDp4TvBVY2HxAjc+Q/0bq2WU9XHXFVD7+czsGjkGBNJpMvtFaswjCNbpvbsah+bv GffedDXG/fKK+2jM5bGhnYPEw7yIXTO+GFYX9Yy4JWG45d7+CnFTMe3wJN9z8awo5Hsc PKHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796066292; x=1796671092; h=in-reply-to:content-disposition:content-type:mime-version :references:mail-followup-to:message-id:subject:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=e0jMNnS2iXl0w9BU16JEmjAAAZM73DmVU0PBiZOx3c4=; b=ooa9/riGZ0km2Nm/2VbOVpD+cVyferOYf0oacfFGFBFD6cjFeqQT4c6GRC5HJk/KCf ECzQHtnGOg/wVK8ILvTtBnuPw1Fyga4rkvPyh/KOkL629YtmyWG0ixEnwVkPKVN+oHYd aCL9X9p+OwEXadjOLroUbyAyjc0SDHBcvJgF6CWaD3wiLI/SDewp9LhlW0LP2LK/vPvL mMI8NGxKcvlObWya6xQ/J4sTtAORrsXy+OBp/aYFwxETKE85Tn9XAhjr6F+y/eZ57ceC 5NTqIieSSi6ZwP0daOxLD56PS5ky67fvUjVMz+qRYtw+R0/mrda7Y2wCCNU1aI9sVXqO 07Iw== X-Forwarded-Encrypted: i=1; AL+hErGRXORAninZ5VZb/e4aC6By8aRzXREZWvCd1MWJQL0vyXD0DDmA9mraRZU6KZzo2Eul2qwwy+cUW+D0@vger.kernel.org X-Gm-Message-State: APuU4Z+sVLpU14+a3oHdOnAJrB87cpB7qV7TaAM1jFKfZ+NM5CKEX/OT cqgKamV8mPOO3g9B01lQ5Nyw7tkWUX6YxsMPNy+GVBnsHEM4+OMUTBFf X-Gm-Gg: AZFdTZdIwVPOow3AH3OXyY4Lm7zkgKhH8GOcvvZBSI8Mv+m5uXYMxohGqFz5MAnB+Ak sDBQu4ufBGgMnXrupBMxxLp1/GEwZDWR3QCCZHhJ+eN6Sb2UyVLh6HOOX8BoCqeC9YKKjq/v1Xp rr6jBe7Q8mSINY4DF+BL/4irdt25Ta2zs4gNJHrC1D+Dldv2kV3GTz3Fi2NsmCpWpTZwWRcSDsn oSMKvJZIRqZQZ+PnXmtB1qFm0cOgZf46ADEmPLffPLI+kHUdZ+vlsjwpaWjsIxgSfdOoCTI46LV k28Td1He9KWFJhocc1YyI5tjZIZQCHGM680BhzcqhUKybyWTpLONbnS/l1JKgDXTuXiHYfA4GSa /CYCD5hiyreBTUSnCvDCahWfJsosSNRMt4haLavyHAKg+DRUKlHhUhfwoJRgt58nBrb0+zaAJKy bWkL0MacyVcJglLeMEZTKOomyhJ9aFstZiv6VaqpOMt82DcT8M6yWl+fl7jFma4RmB9b4Q2HpQP MB+LYhFHtEV1L8Tnfnk2wLOibhARnXy2zyNA7JkwZiC/94/PKAtk/U2OT8i+JbkQVnlYeHHuNmR xm0tNA1zYMhtysB0LJo3R19x54/XlI7bPp86FqqtM1x2fDPQX9qnstqxw4Y+XO2JbgBEW0sh4lt ZrmQ2 X-Received: by 2002:a05:6830:82f6:b0:862:bc33:da95 with SMTP id 46e09a7af769-86315995c28mr35880490a34.20.1796066292301; Mon, 30 Nov 2026 11:18:12 -0800 (PST) Received: from localhost ([2a03:2880:10ff:a::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-86316910337sm23287210a34.23.2026.11.30.11.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 11:18:11 -0800 (PST) Date: Mon, 30 Nov 2026 11:18:11 -0800 From: Joshua Hahn To: Yury Norov , linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org, Rasmus Villemoes , David Hildenbrand , Gregory Price , Zi Yan , Rakie Kim , Ying Huang , Muchun Song , Oscar Salvador , Johannes Weiner , Kairui Song , Thomas Bogendoerfer , "Rafael J. Wysocki" , Len Brown , Jens Axboe , Peter Zijlstra , Mel Gorman , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-mips@vger.kernel.org, linux-acpi@vger.kernel.org, linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org, "Liam R. Howlett" , Axel Rasmussen , Baolin Wang , Baoquan He , Barry Song , Linus Torvalds , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Qi Zheng , Shakeel Butt , Suren Baghdasaryan , Vlastimil Babka , Wei Xu , Yuanchu Xie , Yury Norov Subject: Re: [PATCH 00/11] nodemask: switch to runtime nr_node_ids Message-ID: Mail-Followup-To: Yury Norov , linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org, Rasmus Villemoes , David Hildenbrand , Gregory Price , Zi Yan , Rakie Kim , Ying Huang , Muchun Song , Oscar Salvador , Johannes Weiner , Kairui Song , Thomas Bogendoerfer , "Rafael J. Wysocki" , Len Brown , Jens Axboe , Peter Zijlstra , Mel Gorman , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-mips@vger.kernel.org, linux-acpi@vger.kernel.org, linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org, "Liam R. Howlett" , Axel Rasmussen , Baolin Wang , Baoquan He , Barry Song , Linus Torvalds , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Qi Zheng , Shakeel Butt , Suren Baghdasaryan , Vlastimil Babka , Wei Xu , Yuanchu Xie , Yury Norov References: <20261127230128.111933-1-ynorov@nvidia.com> X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 30, 2026 at 08:48:24AM -0800, Joshua Hahn wrote: > On Fri, Nov 27, 2026 at 06:01:17PM -0500, Yury Norov wrote: > > Nodemasks have a compile-time capacity of MAX_NUMNODES, and > > nr_node_ids describes the runtime node ID usage. > > > > Modern distros, like my Ubuntu, default MAX_NUMNODES to 1024, while the > > actual number of nodes is typically smaller. All nodemask functions > > currently refer to the MAX_NUMNODES, which adds a substantial overhead > > on every traversing operation. > > > > This series switches the kernel to runtime length of nodemasks, which > > also saves up to 8K of .text for minimal config, and accelerates basic > > nodemask operations ~4x if MAX_NUMNODES == 1024 and nr_node_ids == 2. > > Hi Yury, > > Thanks for the series. I think it looks good and a 4x speedup on the > nodemask operations is pretty awesome. I had a question that was a bit > orthogonal to this series, I wanted your opinion on right-sizing > MAX_NUMNODES. > > Something that's been bugging me is how much memory is wasted by > statically allocating MAX_NUMNODES sized arrays, e.g: > > - mm/page_alloc.c: node_load[MAX_NUMNODES] > - mm/mempolicy.c: preferred_node_policy[MAX_NUMNODES] > - mm/hugetlb_cma.c: hugetlb_cma[MAX_NUMNODES] > hugetlb_cma_size_in_node[MAX_NUMNODES] > hugetlb_cma_percent_in_node[MAX_NUMNODES] > ... etc ... > > In addition to the script to build the configs to match the local > configs... I was wondering if you've thought about this side of the > problem too. To be honest I'm not sure if there is much we can do, but > I thought I would just bring it up : -) On reflecting on this over lunch... I did a quick check and it turns out that the static overhead associated with wastage coming from MAX_NUMNODES >> nr_node_ids isn't really that big. I do believe the real cost comes in the nodemask iterations, which you handle here. Sorry for the noise, I should have checked before commenting! > Thanks, Yury. As for the series I agree with Lorenzo, I think some > additional context for the cover letter would help me think about these > changes. > > Have a great day! > Joshua > > > Yury Norov (11): > > nodemask: add 'small' and 'large' compile-time sizes > > nodemask: pass nodemask length to node search functions > > mm/mempolicy: reject migrate_pages source IDs beyond nr_node_ids > > mm/mempolicy: preserve full-width userspace nodemasks > > mm: switch to runtime nodemask length > > MIPS: IP27: switch nmi_dump to runtime nodemask length > > ACPI: NUMA: switch acpi_map_pxm_to_node to runtime nodemask length > > mtip32xx: switch next_online_node() to runtime nodemask length > > nodemask: add nodes_copy_and_extend() > > sched/numa: bound cpuset trace masks by nr_node_ids > > nodemask: add cpumask-style operation size bounds > > > > arch/mips/sgi-ip27/ip27-nmi.c | 2 +- > > drivers/acpi/numa/srat.c | 2 +- > > drivers/block/mtip32xx/mtip32xx.c | 2 +- > > include/linux/nodemask.h | 122 +++++++++++++++++++----------- > > include/trace/events/sched.h | 7 +- > > mm/hugetlb_internal.h | 2 +- > > mm/mempolicy.c | 55 +++++++++----- > > mm/mmzone.c | 2 +- > > mm/vmscan.c | 2 +- > > 9 files changed, 123 insertions(+), 73 deletions(-) > > > > -- > > 2.53.0 > > > >