From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C0CE4156661 for ; Sat, 18 Jul 2026 00:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784334230; cv=none; b=FV0WhTqnL+Lns0bZ/KGCtVCedw2pSE623/imImtaQLeLdGUob7fk7Ny6+pEfof4qNP0i+5+YXmdJPSHxdFdQIpQB9FSL3NtboMn0kaM/jKPwToOm7Yl8KN7ZbMlhBgva+6ofvArVUbEhD9kaRHZhw7Y8gnafrx2SqeDdLc5DfZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784334230; c=relaxed/simple; bh=FhJ3OdQ22euzYUiMrQyi4q2voMgu+jdGtOq6GL/c3gg=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=HqnYCRv1WW3R7+IShBz7o55V+Z3wTKtiNCadzfh+byE1xdG7OB70qvPuWOAaMQnoF8lbcoMTaBnk/J/+G3T4ozX+XiTBrIzJUAp16tb8KpveQjd4atMLfXeb1Z+OG/zwj8sG7v3Ns00PPrK2gweMnZL2MHxnGfmnOzIgGqHmOuQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=pGPyVGzQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="pGPyVGzQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 086821F00A3A; Sat, 18 Jul 2026 00:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1784334228; bh=sT1lMmOrvNVAoIz5Gs7S2ofc6t5sDGbTcquhmwqvl/s=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=pGPyVGzQUsnyeLeRC5KIXdrpQnKuV8ByqqH2HF6O5KhmV5slfq7DDPW95iGZso3kO hINIOY1lG+QG6CzvXyUXY6/WLJnDp0vnMnljXHy0WmNIpI/I+Fl4/bQzxw/GwyoBO9 Ri1cBv8WJE+ozFeyg7OmRK+6hppNZFRnSsgM1xk0= Date: Fri, 17 Jul 2026 17:23:47 -0700 From: Andrew Morton To: Paul Sherman Cc: linux-mm@kvack.org, tj@kernel.org, vbabka@suse.cz, dennis@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/percpu: allow embed allocator when total size fits in vmalloc Message-Id: <20260717172347.18b3c01b7553da75f6344c65@linux-foundation.org> In-Reply-To: <20260717231616.9126-1-shermanpauldylan@gmail.com> References: <20260717231616.9126-1-shermanpauldylan@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 17 Jul 2026 16:16:16 -0700 Paul Sherman wrote: > On large NUMA systems (e.g. 4-node 128GB), the physical span between > NUMA nodes may exceed 75% of vmalloc space even though the total percpu > allocation is tiny (e.g. ~6MB for 64 CPUs). > > The 75% check was designed for pcpu_get_vm_areas() used by dynamic > percpu chunks, where vmalloc congruency is required. The embed > allocator uses the linear map directly for the first chunk -- physical > addresses are accessible as virtual addresses without vmalloc mapping. > The relevant constraint is total percpu size, not physical span. > > Replace the unconditional fallback with a total-size check: if the > aggregate percpu allocation fits within 75% of vmalloc space, proceed > with embed regardless of physical NUMA span. Systems where total percpu > size genuinely exceeds the vmalloc bound retain the page allocator > fallback. > > Tested on Sophgo SG2042 (64-hart, 4-NUMA, 128GB DDR4, RISC-V Sv39): > percpu: embed: span 0x17def7a000 > vmalloc 75% but total 0x5c0000 > fits -- linear map used > percpu: Embedded 23 pages/cpu s54168 r8192 d31848 u94208 Nicely presented patch, thanks. > Link: https://lkml.iu.edu/hypermail/linux/kernel/1707.3/00337.html > Cc: Tejun Heo > Cc: Vlastimil Babka > Cc: Dennis Zhou > Signed-off-by: Paul Sherman > --- > > This fix is inert on systems where the original check never fired; > it only activates when physical span exceeds 75% of vmalloc but total > percpu size does not. > > Architecture analysis: > > Architecture | vmalloc | phys span | total percpu | result > ---------------|--------------|--------------|--------------|-------- > RISC-V Sv39 | ~88 GB | ~102 GB | ~6 MB | fixed > RISC-V Sv48 | ~88 TB | ~102 GB | ~6 MB | unaffected > RISC-V Sv57 | ~44 PB | ~102 GB | ~6 MB | unaffected > ARM64 large | ~248 TB | varies | tiny | unaffected > 32-bit NUMA | ~128 MB | varies | may exceed | correct fallback > > Tejun Heo noted in 2017 [Link] that the only constraint is vmalloc > size relative to NUMA node distances, and that making vmalloc bigger > would be the best fix. On RISC-V Sv39 with 88GB vmalloc and 102GB > physical NUMA span that is not an option -- but the embed allocator > does not need congruent vmalloc mapping for the first chunk anyway. I suggest all the above be moved above the "---" separator. It's useful info for the permanent record. (And replace "[Link]" with "[1]" in the usual fashion). > mm/percpu.c | 29 ++++++++++++++++++++++++----- > 1 file changed, 24 insertions(+), 5 deletions(-) AI review asked a question: https://sashiko.dev/#/patchset/20260717231616.9126-1-shermanpauldylan@gmail.com