[RFC PATCH 0/4] um: Add SMP support

Tiwei Bie tiwei.bie at linux.dev
Mon Jul 14 07:56:01 PDT 2025


Hi Benjamin,

On Mon, 14 Jul 2025 14:37:33 +0200, Benjamin Berg wrote:
> Hi Tiwei,
> 
> this is pretty cool, I really did not expect patches for SMP :-)

I'm really happy you like it. :)

> 
> I have not dived in a lot. From a cursory glance, I expect that there
> are currently still issues if a process is actually multi-threaded. But
> even this state is really neat already.
> 
> As for proper multi-threading support, I would like to make sure you
> are aware of the flush_tlb_* functions in tlbflush.h. These will need
> to be updated so that these flushes happen synchronously as another
> thread might otherwise access data for too long.
> 
> There are probably a few things to figure out in that regard about
> where/when to flush the TLB entries in a multi-threaded userspace.
> After all, there can be up to the number of CPUs worker threads and one
> probably only wants one of them to sync the TLBs at any point in tmie.

That makes sense! Thanks for the heads-up! I'll take a closer look.

> 
> Anyway, nice work!

Thanks! :)
Tiwei

> Benjamin
> 
> On Mon, 2025-07-14 at 01:25 +0800, Tiwei Bie wrote:
> > From: Tiwei Bie <tiwei.btw at antgroup.com>
> > 
> > This is a follow-up to the discussion in this thread:
> > https://lore.kernel.org/linux-um/20250711065021.2535362-4-tiwei.bie@linux.dev/
> > 
> > Currently, this is still a PoC and requires further improvements.
> > 
> > I performed a kernel build test inside UML with 8 virtual CPUs
> > enabled:
> > 
> > $ tar xf linux-6.15.tar.gz
> > $ cd linux-6.15
> > $ make ARCH=um defconfig > /dev/null
> > $ time make ARCH=um -j16 > /dev/null
> > 
> > real    6m2.529s
> > user    43m37.665s
> > sys     0m34.585s
> > $ ./linux --version
> > 6.15.0
> > $ cat /proc/cpuinfo | grep -c '^processor'
> > 8
> > 
> > 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 nohz=n seccomp=on init=/bin/sh \
> >            ubd0=$your_rootfs_image
> > 
> > This patchset depends on the following patchset:
> > https://lore.kernel.org/linux-um/20250711065021.2535362-1-tiwei.bie@linux.dev/
> > 
> > Tiwei Bie (4):
> >   um: Stop tracking virtual CPUs via mm_cpumask()
> >   um: Remove unused cpu_data and current_cpu_data macros
> >   um: vdso: Implement __vdso_getcpu() via syscall
> >   um: Add SMP support
> > 
> >  arch/um/Kconfig                         |  28 ++-
> >  arch/um/include/asm/Kbuild              |   3 +
> >  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               |   7 +
> >  arch/um/include/asm/mmu_context.h       |  11 --
> >  arch/um/include/asm/pgtable.h           |   2 +
> >  arch/um/include/asm/processor-generic.h |   8 +-
> >  arch/um/include/asm/smp.h               |  31 +++-
> >  arch/um/include/asm/spinlock.h          |   8 +
> >  arch/um/include/linux/smp-internal.h    |   8 +
> >  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             |  12 +-
> >  arch/um/include/shared/smp.h            |  14 ++
> >  arch/um/kernel/Makefile                 |   1 +
> >  arch/um/kernel/irq.c                    |  31 +++-
> >  arch/um/kernel/ksyms.c                  |   2 +-
> >  arch/um/kernel/mem.c                    |   2 +
> >  arch/um/kernel/process.c                |  19 +-
> >  arch/um/kernel/skas/mmu.c               |  16 +-
> >  arch/um/kernel/smp.c                    | 223
> > ++++++++++++++++++++++++
> >  arch/um/kernel/time.c                   |  48 +++--
> >  arch/um/kernel/tlb.c                    |   5 +-
> >  arch/um/kernel/trap.c                   |   2 +-
> >  arch/um/kernel/um_arch.c                |  60 ++++++-
> >  arch/um/os-Linux/Makefile               |   4 +-
> >  arch/um/os-Linux/file.c                 |  72 ++++++--
> >  arch/um/os-Linux/main.c                 |   5 +-
> >  arch/um/os-Linux/process.c              |  15 ++
> >  arch/um/os-Linux/signal.c               |  16 +-
> >  arch/um/os-Linux/skas/process.c         |   1 +
> >  arch/um/os-Linux/smp.c                  |  44 +++++
> >  arch/um/os-Linux/start_up.c             |   3 +
> >  arch/um/os-Linux/time.c                 |  29 +--
> >  arch/um/os-Linux/user_syms.c            |   5 +
> >  arch/x86/um/vdso/um_vdso.c              |  18 +-
> >  39 files changed, 695 insertions(+), 99 deletions(-)
> >  create mode 100644 arch/um/include/asm/spinlock.h
> >  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
> > 
> 



More information about the linux-um mailing list