From: Cong Wang <xiyou.wangcong@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: jiri@resnulli.us, stefanha@redhat.com,
multikernel@lists.linux.dev, pasha.tatashin@soleen.com,
Cong Wang <cwang@multikernel.io>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <bhe@redhat.com>, Alexander Graf <graf@amazon.com>,
Mike Rapoport <rppt@kernel.org>,
Changyuan Lyu <changyuanl@google.com>,
kexec@lists.infradead.org, linux-mm@kvack.org
Subject: [RFC Patch v2 05/16] x86: Introduce arch_cpu_physical_id() to obtain physical CPU ID
Date: Sat, 18 Oct 2025 23:16:19 -0700 [thread overview]
Message-ID: <20251019061631.2235405-6-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20251019061631.2235405-1-xiyou.wangcong@gmail.com>
From: Cong Wang <cwang@multikernel.io>
The tranditional smp_processor_id() is a software-defined CPU ID which
is only unique within the same kernel. With Multikernel architecture, we
run multiple Linux kernels on different CPU's, hence the host kernel
needs a globally unique CPU ID to manage the CPU's. The physical CPU ID
is perfect for this case.
This API will be used to globally distinguish CPU's among different
multikernels.
Signed-off-by: Cong Wang <cwang@multikernel.io>
---
arch/x86/include/asm/smp.h | 6 ++++++
arch/x86/kernel/smp.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 1a59fd0de759..378be65ceafa 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -40,6 +40,7 @@ struct smp_ops {
void (*send_call_func_ipi)(const struct cpumask *mask);
void (*send_call_func_single_ipi)(int cpu);
+ int (*cpu_physical_id)(int cpu);
};
/* Globals due to paravirt */
@@ -100,6 +101,11 @@ static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
smp_ops.send_call_func_ipi(mask);
}
+static inline int arch_cpu_physical_id(int cpu)
+{
+ return smp_ops.cpu_physical_id(cpu);
+}
+
void cpu_disable_common(void);
void native_smp_prepare_boot_cpu(void);
void smp_prepare_cpus_common(void);
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index 59658fcd9037..e2eba09da7fc 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -288,6 +288,11 @@ static int __init nonmi_ipi_setup(char *str)
__setup("nonmi_ipi", nonmi_ipi_setup);
+static int native_cpu_physical_id(int cpu)
+{
+ return cpu_physical_id(cpu);
+}
+
struct smp_ops smp_ops = {
.smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
.smp_prepare_cpus = native_smp_prepare_cpus,
@@ -305,6 +310,7 @@ struct smp_ops smp_ops = {
.send_call_func_ipi = native_send_call_func_ipi,
.send_call_func_single_ipi = native_send_call_func_single_ipi,
+ .cpu_physical_id = native_cpu_physical_id,
};
EXPORT_SYMBOL_GPL(smp_ops);
--
2.34.1
next prev parent reply other threads:[~2025-10-19 6:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-19 6:16 [RFC Patch v2 00/16] kernel: Introduce multikernel architecture support Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 01/16] kexec: Introduce multikernel support via kexec Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 02/16] x86: Introduce SMP INIT trampoline for multikernel CPU bootstrap Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 03/16] multikernel: Introduce basic multikernel subsystem infrastructure Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 04/16] x86: Introduce MULTIKERNEL_VECTOR for inter-kernel communication Cong Wang
2025-10-19 6:16 ` Cong Wang [this message]
2025-10-19 6:16 ` [RFC Patch v2 06/16] multikernel: Introduce physical memory reservation and allocation Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 07/16] kexec: Implement dynamic kimage tracking Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 08/16] multikernel: Introduce device-tree based kernfs interface Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 09/16] kexec: Integrate multikernel instance management with kexec subsystem Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 10/16] Documentation: Add multikernel usage Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 11/16] kexec: Add /proc/kimage interface for kimage tracking Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 12/16] multikernel: Introduce per-instance memory allocation interface Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 13/16] kernel: Introduce generic multikernel IPI communication framework Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 14/16] multikernel: Add messaging layer for inter-kernel communication Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 15/16] kexec: Integrate multikernel support with kexec_file_load() Cong Wang
2025-10-19 6:16 ` [RFC Patch v2 16/16] multikernel: Integrate Kexec HandOver framework for DTB preservation Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251019061631.2235405-6-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=changyuanl@google.com \
--cc=cwang@multikernel.io \
--cc=graf@amazon.com \
--cc=jiri@resnulli.us \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=multikernel@lists.linux.dev \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox