From: Tiwei Bie <tiwei.bie@linux.dev>
To: richard@nod.at, anton.ivanov@cambridgegreys.com,
johannes@sipsolutions.net
Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org,
benjamin@sipsolutions.net, arnd@arndb.de, tiwei.btw@antgroup.com,
tiwei.bie@linux.dev
Subject: [PATCH v3 0/7] um: Add SMP support
Date: Sun, 14 Sep 2025 23:56:51 +0800 [thread overview]
Message-ID: <20250914155658.1028790-1-tiwei.bie@linux.dev> (raw)
From: Tiwei Bie <tiwei.btw@antgroup.com>
This series adds initial symmetric multi-processing (SMP) support
to UML. With this support, it is now possible for users to tell
UML to start multiple virtual CPUs, each represented as a separate
host thread.
In UML, kthreads and normal threads (when running in kernel mode)
can be scheduled and executed simultaneously on different virtual
CPUs. However, the userspace code of normal threads currently still
runs within their respective single-threaded stubs.
So SMP within the kernel is supported. SMP across different processes
in userspace is also supported. Currently, the limitation is that
multi-threading within the same process does not yet support true SMP
in userspace, because it would require converting the stub into a
multi-threaded implementation, which is not covered in this series.
Extending the stub to support true SMP in userspace within the same
process could be done later and requires careful design. It may be
better to handle it in a follow-up series.
Here are some steps to try out SMP support in UML:
1. Build UML with CONFIG_SMP=y and, for example, CONFIG_NR_CPUS=8.
2. Launch a UML instance with, for example, 8 virtual CPUs.
$ ./linux mem=16G ncpus=8 seccomp=on init=/bin/sh ubd0=$your_rootfs_image
v3:
- Fix need_resched based idle sleep; (Johannes)
- Remove getcpu support from the vdso on UML/x86; (Johannes)
- Describe 'cpu' parameter of os_timer_disable; (lkp@intel.com)
- Misc fixes and cleanups;
v2 (https://lore.kernel.org/all/20250810055136.897712-1-tiwei.bie@linux.dev/):
- Implement IPI based on RT signal; (Johannes)
- Fix raw_smp_processor_id() for non-SMP case; (Johannes)
- Add sparse check for turnstile; (Johannes)
- Implement spinlock in $SUBARCH;
- Fix potential race on stub's siginfo;
- Rewrite AP bring-up (e.g. switch to generic idle thread);
- Misc fixes and cleanups;
v1: https://lore.kernel.org/all/20250727062937.1369050-1-tiwei.bie@linux.dev/
RFC: https://lore.kernel.org/all/20250713172536.404809-1-tiwei.bie@linux.dev/
Tiwei Bie (7):
um: Turn signals_* into thread-local variables
um: Determine sleep based on need_resched()
um: Define timers on a per-CPU basis
um: Add initial SMP support
um: vdso: Remove getcpu support on x86
asm-generic: percpu: Add assembly guard
um: Enable SMP support on x86
.../core/generic-idle-thread/arch-support.txt | 2 +-
arch/um/Kconfig | 46 +++-
arch/um/include/asm/current.h | 5 +-
arch/um/include/asm/hardirq.h | 24 +-
arch/um/include/asm/irqflags.h | 4 +-
arch/um/include/asm/mmu.h | 10 +
arch/um/include/asm/pgtable.h | 2 +
arch/um/include/asm/smp.h | 15 +-
arch/um/include/linux/smp-internal.h | 17 ++
arch/um/include/linux/time-internal.h | 3 +
arch/um/include/shared/kern_util.h | 2 +
arch/um/include/shared/longjmp.h | 3 +-
arch/um/include/shared/os.h | 24 +-
arch/um/include/shared/skas/mm_id.h | 5 +
arch/um/include/shared/smp.h | 20 ++
arch/um/kernel/Makefile | 1 +
arch/um/kernel/irq.c | 27 +-
arch/um/kernel/ksyms.c | 2 +-
arch/um/kernel/mem.c | 2 +
arch/um/kernel/process.c | 17 +-
arch/um/kernel/skas/mmu.c | 33 ++-
arch/um/kernel/skas/process.c | 7 +-
arch/um/kernel/smp.c | 241 ++++++++++++++++++
arch/um/kernel/time.c | 58 +++--
arch/um/kernel/tlb.c | 5 +-
arch/um/kernel/trap.c | 2 +-
arch/um/kernel/um_arch.c | 25 +-
arch/um/os-Linux/Makefile | 4 +-
arch/um/os-Linux/internal.h | 13 +
arch/um/os-Linux/main.c | 5 +-
arch/um/os-Linux/process.c | 20 ++
arch/um/os-Linux/signal.c | 46 +++-
arch/um/os-Linux/skas/process.c | 22 +-
arch/um/os-Linux/smp.c | 148 +++++++++++
arch/um/os-Linux/start_up.c | 4 +
arch/um/os-Linux/time.c | 78 ++++--
arch/x86/um/Kconfig | 3 +
arch/x86/um/asm/spinlock.h | 8 +
arch/x86/um/vdso/um_vdso.c | 20 --
arch/x86/um/vdso/vdso.lds.S | 2 -
include/asm-generic/percpu.h | 3 +
41 files changed, 870 insertions(+), 108 deletions(-)
create mode 100644 arch/um/include/linux/smp-internal.h
create mode 100644 arch/um/include/shared/smp.h
create mode 100644 arch/um/kernel/smp.c
create mode 100644 arch/um/os-Linux/smp.c
create mode 100644 arch/x86/um/asm/spinlock.h
base-commit: e66ae377fe219c98d3d5b8a0d35da4413a5390ca
--
2.34.1
next reply other threads:[~2025-09-14 15:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-14 15:56 Tiwei Bie [this message]
2025-09-14 15:56 ` [PATCH v3 1/7] um: Turn signals_* into thread-local variables Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 2/7] um: Determine sleep based on need_resched() Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 3/7] um: Define timers on a per-CPU basis Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 4/7] um: Add initial SMP support Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 5/7] um: vdso: Remove getcpu support on x86 Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 6/7] asm-generic: percpu: Add assembly guard Tiwei Bie
2025-09-15 7:40 ` Arnd Bergmann
2025-09-15 15:29 ` Tiwei Bie
2025-09-14 15:56 ` [PATCH v3 7/7] um: Enable SMP support on x86 Tiwei Bie
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=20250914155658.1028790-1-tiwei.bie@linux.dev \
--to=tiwei.bie@linux.dev \
--cc=anton.ivanov@cambridgegreys.com \
--cc=arnd@arndb.de \
--cc=benjamin@sipsolutions.net \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=richard@nod.at \
--cc=tiwei.btw@antgroup.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;
as well as URLs for NNTP newsgroup(s).