From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 0AE9046AEE1 for ; Wed, 6 May 2026 14:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778076181; cv=none; b=TjXIwPRKgQDjYVW+LdUPkWH4IXsg6F+3pnazziMRC9SHKbV5Dj/2c+DyTTHGgEfBpFTjPHA51Mo7QOk0WITITUPMzZQDNWrJ7St93pDRazn+q8HfHpN8j3PIEK8PLQZjrl0vdkJxKffZHCap836cOCUGjdmEcFoqmMHrm1q9jHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778076181; c=relaxed/simple; bh=g/iHhBLpMRLaXE1pKgvsFD/MxIEIxlLK9f+5vJN1aZQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RgYrI5j3YSyt+ICw9yajjHodF9B0xqTv+07hr5GqTDx4FYJMLEm2iokONR06JrZeKFNBypQ8RXoey4VInxVjJLgFYbgo8Em9ALQQU1FCUChIdbRls8uaseCHUegoqx+QvhLGpYygNEaEe7/RZMiRqT06m5PXczjEXT00N3sHvJM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ecOm6TJD; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ecOm6TJD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778076179; h=from:from: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=cvWmAmDG/XvsMl+0RCDn4wp9PG0Hw46hC5IS5vSmoN8=; b=ecOm6TJD/vU53ARAo8cvpJJf+bq3l6kSL2EoNKKNbWRKRZJUSHTe3Cst7MMNpMi6iAHlls 4BlABZVqkDpepOtUgno5K0tLxDss0/MjGXEThhT2bkh07c3YthW74il9HS2/1lbcmR4aLV fv/cBq9OddsLH3YhVp0msKSIEjnzSgo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-ulP6Ei_9Otu1z4TF3wSIaw-1; Wed, 06 May 2026 10:02:53 -0400 X-MC-Unique: ulP6Ei_9Otu1z4TF3wSIaw-1 X-Mimecast-MFC-AGG-ID: ulP6Ei_9Otu1z4TF3wSIaw_1778076170 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D3CE619560B5; Wed, 6 May 2026 14:02:49 +0000 (UTC) Received: from [10.2.16.208] (unknown [10.2.16.208]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 13DCE1800240; Wed, 6 May 2026 14:02:46 +0000 (UTC) Message-ID: Date: Wed, 6 May 2026 10:02:46 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/isolation: Don't free memblock allocated cpumasks To: Valentin Schneider , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , K Prateek Nayak , Frederic Weisbecker , Mike Rapoport Cc: linux-kernel@vger.kernel.org References: <20260505051821.1107133-1-longman@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 On 5/6/26 9:25 AM, Valentin Schneider wrote: > On 05/05/26 01:18, Waiman Long wrote: >> When testing a v7.1 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. >> >> [ 0.080911] Cannot free reserved memory because of deferred initialization of the memory map >> [ 0.080911] WARNING: mm/memblock.c:904 at __free_reserved_area+0xde/0xf0, CPU#0: swapper/0/0 >> : >> [ 0.080945] Call Trace: >> [ 0.080947] >> [ 0.080949] memblock_phys_free+0xcb/0x100 >> [ 0.080953] housekeeping_init+0x14c/0x170 >> [ 0.080957] start_kernel+0x207/0x450 >> [ 0.080961] x86_64_start_reservations+0x24/0x30 >> [ 0.080965] x86_64_start_kernel+0xda/0xe0 >> [ 0.080967] common_startup_64+0x13e/0x141 >> [ 0.080972] >> >> The commit states that freeing of reserved memory before the memory >> map is fully initialized in deferred_init_memmap() would cause access >> to uninitialized struct pages and may crash when accessing spurious >> list pointers. However, if the memblock_free() call is deferred to >> the start of initcall processing in the bootup process, for instance, >> the following KASAN warning can appear. >> >> [ 8.514775] BUG: KASAN: use-after-free in memblock_isolate_range+0x4ac/0x650 >> [ 8.514775] Read of size 8 at addr ffff88a07fe6a000 by task swapper/0/1 >> : >> [ 8.514775] Call Trace: >> [ 8.514775] >> [ 8.514775] kasan_report+0xb2/0x1b0 >> [ 8.514775] memblock_isolate_range+0x4ac/0x650 >> [ 8.514775] memblock_phys_free+0xc4/0x190 >> [ 8.514775] housekeeping_late_init+0x257/0x280 >> [ 8.514775] do_one_initcall+0xaa/0x470 >> [ 8.514775] do_initcalls+0x1b4/0x1f0 >> [ 8.514775] kernel_init_freeable+0x4b5/0x550 >> [ 8.514775] kernel_init+0x1c/0x150 >> [ 8.514775] ret_from_fork+0x5dc/0x8e0 >> [ 8.514775] ret_from_fork_asm+0x1a/0x30 >> [ 8.514775] >> > Darn, I just saw the previous version doing this. > >> It is likely that memblock_discard() may discard memblock data needed >> for memblock_free(). One workaround for now to avoid these warning/bug >> messages is to keep the memblock allocated cpumasks even if they are >> no longer needed until the memblock subsystem is properly updated to >> handle memblock_free(). > Pardon my ignorance, but how come this isn't the case for the other > memblock users? It sounds like there is no right place for freeing this > mask. My current thought is to chain all the memblock memory blocks to be freed in a singly linked list first and then freed them at the right moment by the memblock code. That will require some more investigation into the memblock code. This patch is just a temporary workaround which I hope will be reverted in the future. Cheers, Longman