From nobody Wed Sep 30 03:45:54 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C41413A872C; Thu, 13 Aug 2026 10:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786617512; cv=none; b=Ci8Be01HvVPBF6CyQYzuz0pSvCDDuGyJVZPPgGEDFUcx3WY47UwSdZXr2AI1SXk7VxPDkiMvrOI7zhNBKe9Antyop5wUbn20bc9lm2tZ7VyI9Vm8coTjTBcLEaHYGw5Da47LpUuVdI1Nshw3P4at9M/nPN4G7FcN2g08xaqv5AE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786617512; c=relaxed/simple; bh=SLsLcdC9CLg7bv7csmFjXqCb3E26U2XZOjIiPbFZZWY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=CRKHNMZv4/C5iNsRcmXn2pWZA1JeUXc3sSh73qaxcBSoiUXT4ckFgGQtw2oTESK3bDPHQK4MM3pNgEsPJmP7ljPdEgpUKMreeNUr1A8PHlildLHJ9NNIyYe0XpLRy0uooX2ugjASPoNDw5Ei76BdWpFxZnRZBLKJ9TaOQU6gA0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rELaBzla; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Q8XJ/SF7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rELaBzla"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Q8XJ/SF7" Date: Thu, 13 Aug 2026 10:38:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786617502; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNs8z4rRAb2pHxBxZ6YOMl7BLoL3ys6iMq6GYx1tRhg=; b=rELaBzlaYRd7I6MSEyaRDtElo3DmMqjlc6yh0AhNxbNwRT3zNs06UUBxIZgW6ZJ//ptttD D+L9iQpsNRZoU68YkZb+doPW8SwwtJFWIYmvJrAhgmRvJWhXwjCtJWWGmq4XAUW0uBa1qw PC7mrI8KBfjkF29qcvq1AH8uev0zOHoZOQ8ECNZK2eWEDPoAdXZzMS9IxvI8FHl/M02TVw tTsmyAHgdAh3vTFyCaNw/EVWn95TlzSiSp81LLcPY1ml2qX2AazqUZWj1tgLqQAekYVyqL Yzik/G3ijla6M1grrin0iqTM0ljUwbL6n5vSCh4HZNTLqqJL50UJd/IyOCuZiA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786617502; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNs8z4rRAb2pHxBxZ6YOMl7BLoL3ys6iMq6GYx1tRhg=; b=Q8XJ/SF7mfqrhO5Z4ksHnXr7aAN3vuqSUSz7mwJPbkBCzUXctPk0IZ2SQxy8oytk4hcWQC xzBObxL+6lqExcCg== From: "tip-bot2 for Waiman Long" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/isolation: Defer freeing of cpumask memblock memory to initcall Cc: Waiman Long , "Peter Zijlstra (Intel)" , Frederic Weisbecker , Phil Auld , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260701195810.477326-1-longman@redhat.com> References: <20260701195810.477326-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178661750070.442315.9798852306229676494.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: 2b58c749b8c5244e259a0230bc57b10b010dc545 Gitweb: https://git.kernel.org/tip/2b58c749b8c5244e259a0230bc57b10b0= 10dc545 Author: Waiman Long AuthorDate: Wed, 01 Jul 2026 15:58:10 -04:00 Committer: Peter Zijlstra CommitterDate: Thu, 13 Aug 2026 12:37:03 +02:00 sched/isolation: Defer freeing of cpumask memblock memory to initcall When testing a linux-next kernel with commit 59bd1d914bb5 ("memblock: warn when freeing reserved memory before memory map is initialized"), the following warning was hit when there was a "nohz_full" kernel boot parameter. Cannot free reserved memory because of deferred initialization of the mem= ory map WARNING: mm/memblock.c:904 at __free_reserved_area+0xde/0xf0, CPU#0: swap= per/0/0 : Call Trace: memblock_phys_free+0xcb/0x100 housekeeping_init+0x14c/0x170 start_kernel+0x207/0x450 x86_64_start_reservations+0x24/0x30 x86_64_start_kernel+0xda/0xe0 common_startup_64+0x13e/0x141 IOW, we shouldn't free memblock allocated memory so early in the boot process when memory map isn't fully initialized in deferred_init_memmap(). Fix it by saving the housekeeping cpumask memblock memory to be freed into a llist free list in housekeeping_init() and add a new housekeeping_late_init() helper to defer the actual freeing of memblock memory to when initcall's are being processed. The cpumask memblock memory is treated as a llist_node with the size of a "long" type which is also smallest cpumask size that can be allocated. The non-atomic version of the llist APIs are used as there is no contention. This commit depends on the presence of commit 7c2eee9c1367 ("memblock: don't touch memblock arrays when memblock_free() is called late") to prevent a KASAN UAF bug report [1]. [1] https://lore.kernel.org/lkml/20260505051821.1107133-1-longman@redhat.c= om/ Fixes: 27c3a5967f05 ("sched/isolation: Convert housekeeping cpumasks to rcu= pointers") Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Frederic Weisbecker Reviewed-by: Phil Auld Link: https://patch.msgid.link/20260701195810.477326-1-longman@redhat.com --- kernel/sched/isolation.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index ef152d4..156025e 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -8,6 +8,7 @@ * */ #include +#include #include #include "sched.h" =20 @@ -27,6 +28,7 @@ struct housekeeping { }; =20 static struct housekeeping housekeeping; +static __initdata LLIST_HEAD(memblock_freelist); =20 bool housekeeping_enabled(enum hk_type type) { @@ -189,10 +191,22 @@ void __init housekeeping_init(void) WARN_ON_ONCE(cpumask_empty(omask)); cpumask_copy(nmask, omask); RCU_INIT_POINTER(housekeeping.cpumasks[type], nmask); - memblock_free(omask, cpumask_size()); + __llist_add((struct llist_node *)omask, &memblock_freelist); } } =20 +static int __init housekeeping_late_init(void) +{ + struct llist_node *llnode, *pos, *t; + + /* Free allocated memblock memory, if any */ + llnode =3D __llist_del_all(&memblock_freelist); + llist_for_each_safe(pos, t, llnode) + memblock_free(pos, cpumask_size()); + return 0; +} +pure_initcall(housekeeping_late_init); + static void __init housekeeping_setup_type(enum hk_type type, cpumask_var_t housekeeping_staging) {