From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 65D223148D2 for ; Mon, 20 Apr 2026 01:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776648567; cv=none; b=toAA6gsFHtGA6JfM2QyPrmpau/7l7p9gV7wH6vxjRuaOui69E5wMgkng8nwvp3vcuE8DQkPDS2V+e4f4AEQ6LYdHbLCOuqjPxj76zU2XYG518fSvyxNETExRrSv1WfsGfb7mm/azlZGJDjdNFdygRaRQXdSX2FIZXtBhkm7pE10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776648567; c=relaxed/simple; bh=W9RcAedBr79scY8fdDn31q9gMBVntirJ/glatEGOSVc=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=WtON8SLRms3hvUXzL7JzboUbaINZZ8ZimDUKibKfIFHaN3N2lrSYKJKQsLbW0N4Brr4G+7ElOmMRDAp5bqnpi66IlUY/JgzIsdiIySVXJPeIQarRCg1wQLZ3y87Mx6AGoqlHu00a06uQd+pmrCMnVhi955S4aDOxEjuHoGuSlyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=y7GGsT4g; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="y7GGsT4g" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=pzV1iXC7+vl6whAibS6Ur39FhY1WOB3MInBD16/Nu9U=; b=y7GGsT4gaA4oL/pT6TtVfZp3VCP1EjeOtlB2HQ/zEZLLCDz1pkz0FyomH8c0QIf0P+9rbLH74 cSuNj9u1edWEKqojD4BE7S1X099yRASuAROktIYivXz2wN3+io2THer3f3MZSXnFUrYGnOUoyZf 9XbuYHknfM36JGra6eypOUg= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fzSR04rxHzKm4w; Mon, 20 Apr 2026 09:22:52 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id BDC4040573; Mon, 20 Apr 2026 09:29:15 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 20 Apr 2026 09:29:15 +0800 Message-ID: <6d2b0c3d-2c59-4c6c-b86a-9c45e743a064@huawei.com> Date: Mon, 20 Apr 2026 09:29:11 +0800 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] cpu/hotplug: Fix NULL kobject warning in cpuhp_smt_enable() To: Catalin Marinas CC: , , , , , , , James Morse , References: <20260417075534.3745793-1-ruanjinjie@huawei.com> From: Jinjie Ruan In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To dggpemf500011.china.huawei.com (7.185.36.131) On 4/18/2026 11:05 PM, Catalin Marinas wrote: > On Sat, Apr 18, 2026 at 12:55:22PM +0100, Catalin Marinas wrote: >> On Fri, Apr 17, 2026 at 03:55:34PM +0800, Jinjie Ruan wrote: >>> When booting with `maxcpus` greater than the number of present CPUs (e.g., >>> QEMU -smp cpus=4,maxcpus=8), some CPUs are marked as 'present' but have not >>> yet been registered via register_cpu(). Consequently, the per-cpu device >>> objects for these CPUs are not yet initialized. > [...] >> Another option would have been to avoid marking such CPUs present but I >> think this will break other things. Yet another option is to register >> all CPU devices even if they never come up (like maxcpus greater than >> actual CPUs). > > Something like below, untested (and I don't claim I properly understand > this code; just lots of tokens used trying to make sense of it ;)) > > ------------------------8<------------------------- > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index a9d884fd1d00..4c0a5ed906ea 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -448,12 +448,14 @@ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 apci_id, > return *pcpu; > } > > + set_cpu_present(*pcpu, true); > return 0; > } > EXPORT_SYMBOL(acpi_map_cpu); > > int acpi_unmap_cpu(int cpu) > { > + set_cpu_present(cpu, false); > return 0; > } > EXPORT_SYMBOL(acpi_unmap_cpu); > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 1aa324104afb..751a74d997e1 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -510,8 +510,10 @@ int arch_register_cpu(int cpu) > struct cpu *c = &per_cpu(cpu_devices, cpu); > > if (!acpi_disabled && !acpi_handle && > - IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU)) > + IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU)) { > + set_cpu_present(cpu, false); > return -EPROBE_DEFER; > + } I have verified this patch in my local environment, and it passes the test. > > #ifdef CONFIG_ACPI_HOTPLUG_CPU > /* For now block anything that looks like physical CPU Hotplug */ >