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=1796066294; b=ZthIlxYBjpJMSGSyTJ/NWydx4sB0vD9zyxCqtnm5u/Ul1N4w4/TRe7T8Fs1blbFBR2Iz xXvs2tSDrpXZeXH4gWDYx3oKUxs+EMW27xfKilQD/wtO8e18aUTPnCtikd2JYS/pg8ZCf Qw2M3AXzl1ii435JX+lh+ZHsl7iraJJYrp6oEZQYacR5xAqDQq/ulTo2vVEyjubwJ/Jv8 ceedAuccOlKgdy61uWF16u/7TPEPeoyVxZz2O0rJ3k/X8lx/3BhZbnFeVddLz+BE6+u28 AstvRlUtdqQQwrpFjCnzCSe9kQID4Cp/97ay497AR6nVf2pwb8Q9JPwQjqTx8kb7ynQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796066294; 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=Mr5n3ltKyu2a7DoPBmDOYgFAgzyE2VSlH1ILzWAn0y7wwQ0e0Op6T2EjZgQXBUz7+Lvb f/2p5hKy4FmWWFI2Ia9jyDstECzrH+QitKfsaIYAfb6fLf7rleiT1mvp9Tok81FLWkEid CA4v1kuQM90ung0TGjbMQP7dTIpqcxf7SQ+FcRnaYz4ullIboOThjqVMA3XFOL5HjqtV2 RfSrBTvK+LaY8DRCmlAQdPWx6uEWahAavQp/Iu3xJRlxEKsKZWQIYTSbpG8+mJ7AcFXoh y5vf9ML+L7JTKg4N5Pl6KJjGsjbq53DnKaBLKUyfdZ7juPkUa4uAb5qmjgyP6qmZ5Hg== 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 90F08606A688 for ; Mon, 30 Nov 2026 19:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90F08606A688 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-844a8bf7e25so6054761a34.1 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=y274PyH2qY8j8kpRUqmyuVv3fZVjPRMQI8Ym0CK+uUQAGwG9VeHeBOaVeM3JKnVv+r pdWceQkIdf/nHeNYgWMBd+RjHZAwOqHW/Z2wR3nui0tcmcjMzCySafTSlSARPuw5rFHg ObTZSQADuR2cMPI9ShREkrBcSaoLUf5/jAhHXTXtGQxYRD8HEZRV1uBOIbNcEg5Gp/+2 l+sLYtXjsMTGXAyuMZYrN9eDNZj8JAQ7fP33W/gIjwQ8dfJkbCOM8r/Mhicf32fyk9VO MkOVuHMRE7K+sVy6/IxOehYa6W+3aoDCUQLrc1HqckNW+9AlMrO31L0lC7DF3pZnKa7R kF0g== X-Forwarded-Encrypted: i=1; AL+hErF5fUjMN64eGFIMURabTO2G47dCdJDL7lfkPISSStz2MWHWaUpI/xzaYLZycpH4Lxk1uKVcEELI8Rhz@vger.kernel.org X-Gm-Message-State: APuU4Z87nH7mbtIXWPkrOc1ZtBDDXtuBCVEHFqRBufEwPbZ4o0ceF+jH HJ7ELYPxI2jadu1mI8cpdl68iRSCEZ10gP8HP38P0KwJdQwVMRn4ePJi X-Gm-Gg: AZFdTZfMktea4mT9/WsME/55n/8zrxNiMuWJPD5u3UQfg3d5Ji4pkIFzb0Av83MsBw1 eTDfyLY+xKvPR1+DMUwrI7JFhlVVib4o2XoFmxpwtMrwOY4tFWXakomCi23GYU9XhTrhc5R/fHT LgTXkwAwhaRffHtF5OQm0vpo/QCpEl/UGpHnqFLZ7GG8H7+kReUk7TfZZe1cSxKthNAj0fgSoZd 3E11s3T+qow0FS/5UBmjj32r9La2RJ9C4AvT5Or5MO50WojfLAO/NsAEAHdW40ugqJbJx6X09C6 a/q9+aXRdNUZoRnTs+x2OY6uzXpvfh4j6m8a+2qL+v3BGFE1EM8wi9INn95y1GU6hNFQlPlo8YV gQohaDuCBYrl6ABS8U5SbAetmSmFc8FX8SBbjPjoWHsjNHx2T1yr/Pf+24zw7vkxsLqrHrLOZBN arsPnV+IRazNJwSp7HIOH+20gvT9SJw9W7bdsn197rJBQYD6DMzmxOtq5bYZ6gSwPNQrjpeXkf+ UvV4+c7JlE2Rea7eSgLEHbp5UmXHhrJlU2Lmx5mC2uFVmK9Ry1Gm+NWwgoL7n4nrTf6AwJkeaCk e7X/bBTikZg5Ze8NMvsQzeDhKRjb+4ufJ+/nAr44ETKpxHzicHwQwWvCWocF0DwYlnKfNu9vdxu Esjq2 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-acpi@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 > > > >