From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795537128; b=Tbn8c+eGkIsTo8+JX0Vbf5n4P8s2tjuH00MaHlx8RzchHiFqSdo7BfiUoulagUy+/OqS +4b9/hv/aobMsqxS51c0t8T4CBPaPDVBvPVDz79qe7tnSShjp6fQrkHdx/IlkajU+7a45 7B1YOLqs7vcBBKF7NDWtlCoFH8T5LfAg0VzbsORDB12NNiEZH2bGCYCk/04cpdYCsToza c5PM39whOH+6DD3vv9rfvEiBXs3PZyfQpAVRFxQ5azhsMrv1rOt0tayDR5vnhQEy15iG8 3jrs3Z47NcDpny5VFpmCd4X8Fi6GuPEJVsw1J4hZl4vMVcUnPGlsD9EDajUPw5WLRwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795537128; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=ujMTuwPOsmr1whJF+yqRvOV96KTaU05Y6dPCwFRLQMs=; b=ds/S9f7xKUwWxUWA/aebqbykd3s6dQyzmvb7WmOimA2TqNewVHZ16tk+B9/7OHM5JLV7 I+I0O8yXH49df+8fe7f2ogJXoPR80Nw0R+JsJyYtwwZ2J51Ze3uoXzNLRXFcIB0VbZKAm /DIDZB12rKhcSDsf61/a3t6/bCfiqmvYzYMLVBda8CHNgumAlDV17MPeUNu9OpZ+vI/7C A+3V1mA3jybIKj+AnRh1hXw2r7sbkntL3Ea+ECjNHkD86HU9tEq6CLamQhBRFcwgFBFqv bSDeC2BS6W9ukobrLcyHj2M7+B4d+/9HKss3B0hCScI+3Kj3I+gJcllL53JJkcpbMFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=yjUiG9uA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87DC3606A326; Tue, 24 Nov 2026 16:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=yjUiG9uA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C0691F000D4; Tue, 24 Nov 2026 16:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1795537128; bh=ujMTuwPOsmr1whJF+yqRvOV96KTaU05Y6dPCwFRLQMs=; h=Date:To:From:In-Reply-To:References:Subject; b=yjUiG9uABcG5/WVN7CU7nmnxBVAR8rh+AeleR2fTNlZt2khdUKrUs6M+WPghDGsNL 9Rt3ZwfvBF4yNjTfGOz0bOkJCmYEB/KvwzEmQq8dmTJ3cSQ1fzytSBCzWTGCBWtxnD QKgRzjrIKJpBisoyElYP+k+lvbfyqHy04nRn0yjo= Date: Tue, 24 Nov 2026 08:18:47 -0800 To: mm-commits@vger.kernel.org,ziy@nvidia.com,yu-cheng.yu@intel.com, ying.huang@linux.alibaba.com,willy@infradead.org,vbabka@kernel.org, usama.arif@linux.dev,tj@kernel.org,surenb@google.com,stable@vger.kernel.org, shakeel.butt@linux.dev,rppt@kernel.org,rientjes@google.com, rick.p.edgecombe@intel.com,pfalcato@suse.de,peng.fan@nxp.com, nphamcs@gmail.com,mhocko@suse.com,matthew.brost@intel.com,mason@kernel.org, liam@infradead.org,kasong@tencent.com,kas@kernel.org,joshua.hahnjy@gmail.com, jglisse@redhat.com,jbacik@fb.com,jannh@google.com,jack@suse.cz, hannes@cmpxchg.org,gourry@gourry.net,dennisszhou@gmail.com,dennis@kernel.org, david@kernel.org,dave.hansen@linux.intel.com,cl@gentwo.org, chris@chrisdown.name,byungchul@sk.com,broonie@kernel.org,bp@alien8.de, balbirs@nvidia.com,apopple@nvidia.com,ljs@kernel.org, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261113-mason-migrate-et-al-fixes-v2-12-50a2ed382b61@kernel.org> References: <20261113-mason-migrate-et-al-fixes-v2-12-50a2ed382b61@kernel.org> Subject: + percpu-search-the-whole-reserved-chunk.patch added to mm-unstable branch Message-Id: <20261124161848.2C0691F000D4@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: percpu: search the whole reserved chunk has been added to the -mm mm-unstable branch. Its filename is percpu-search-the-whole-reserved-chunk.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/percpu-search-the-whole-reserved-chunk.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "Lorenzo Stoakes (ARM)" Subject: percpu: search the whole reserved chunk Date: Fri, 13 Nov 2026 21:45:30 +0000 Loading a module with static percpu data can fail with -ENOMEM even though the reserved chunk has a free area that fits the data. pcpu_find_block_fit() does not scan the allocation bitmap, rather it tests the request against hints, starting with the contig_hint of the chunk, which describes its largest free area. If that area is too small once aligned, the search gives up even if a smaller free area fits. Consider: request: 256 bytes, aligned to 256 bytes contig_hint: 260 bytes, starts 4 bytes after a 256-byte boundary, so 8 bytes remain after alignment also free: 256 bytes, starts on a 256-byte boundary Ordinarily this is fine as the allocator moves on to the next chunk or creates a new one, but the static percpu data of modules can only come from the reserved chunk. Fix this by searching the allocation bitmap of the reserved chunk directly rather than using hints. Link: https://patch.msgid.link/20261113-mason-migrate-et-al-fixes-v2-12-50a2ed382b61@kernel.org Fixes: 13f966373f92 ("percpu: skip chunks if the alloc does not fit in the contig hint") Fixes: b4c2116cfae6 ("percpu: update pcpu_find_block_fit to use an iterator") Signed-off-by: Lorenzo Stoakes (ARM) Signed-off-by: Andrew Morton Reported-by: Chris Mason Tested-by: Gregory Price (Meta) Reviewed-by: Gregory Price (Meta) Reviewed-by: Chris Down Cc: David Hildenbrand Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Suren Baghdasaryan Cc: Michal Hocko Cc: David Rientjes Cc: Shakeel Butt Cc: Jann Horn Cc: Pedro Falcato Cc: Matthew Wilcox (Oracle) Cc: Jan Kara Cc: Nhat Pham Cc: Johannes Weiner Cc: Zi Yan Cc: Matthew Brost Cc: Joshua Hahn Cc: Byungchul Park Cc: Ying Huang Cc: Alistair Popple Cc: Usama Arif Cc: Kairui Song Cc: Balbir Singh Cc: Jérôme Glisse Cc: Kiryl Shutsemau Cc: Yu, Yu-cheng Cc: Dave Hansen Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Peng Fan Cc: Josef Bacik Cc: Borislav Petkov Cc: Mark Brown Cc: Dennis Zhou (Facebook) Cc: Rick Edgecombe Cc: mm/percpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/mm/percpu.c~percpu-search-the-whole-reserved-chunk +++ a/mm/percpu.c @@ -1778,8 +1778,11 @@ void __percpu *pcpu_alloc_noprof(size_t if (reserved && pcpu_reserved_chunk) { chunk = pcpu_reserved_chunk; - off = pcpu_find_block_fit(chunk, bits, bit_align, is_atomic); - if (off < 0) { + /* No other chunk to fall back on, so don't rely on hints. */ + off = bitmap_find_next_zero_area(chunk->alloc_map, + pcpu_chunk_map_bits(chunk), 0, + bits, bit_align - 1); + if (off >= pcpu_chunk_map_bits(chunk)) { err = "alloc from reserved chunk failed"; goto fail_unlock; } _ Patches currently in -mm which might be from ljs@kernel.org are mm-msync-return-enomem-if-page-aligned-length-overflows.patch mm-vma-predicate-vma_assert_stabilised-on-config_debug_vm.patch mm-only-assert-mmap-locks-if-config_debug_vm-or-lockdep-is-set.patch mm-only-assert-vma-locks-if-config_debug_vm-is-set.patch mm-convert-warn_on_onces-to-vm_warn_on_once-in-vma-lock-code.patch mm-madvise-zap-markers-from-guard-regions.patch mm-mmap-free-gathered-pages-before-mmf_oom_skip.patch percpu-fix-contig-hints-that-are-too-low.patch percpu-search-the-whole-reserved-chunk.patch