diff mbox series

[v10] um: Enable preemption in UML

Message ID 20240702102549.d2fcea450854.I12f5a53d80ec1e425e66ef272b1e95cb523b608e@changeid
State Accepted
Headers show
Series [v10] um: Enable preemption in UML | expand

Commit Message

Johannes Berg July 2, 2024, 8:25 a.m. UTC
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Since userspace state is saved in the MM process, kernel using
FPU still doesn't really need to do anything, so this really
is as simple as enabling preemption. The irq critical section
in sigio_handler() needs preempt_disable()/preempt_enable().

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
[vastly simplify, fix x86/um Makefile, rewrite commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
v10:
 - rebase on top of various other patchsets, including Benjamin's
   page table updates: https://patchwork.ozlabs.org/project/linux-um/list/?series=408104
 - fix x86/um Makefile
 - remove FPU save/restore code since it's not needed
---
 arch/um/Kconfig      | 2 +-
 arch/um/kernel/irq.c | 2 ++
 arch/x86/um/Makefile | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)

Comments

Anton Ivanov July 2, 2024, 10:07 a.m. UTC | #1
On 02/07/2024 09:25, Johannes Berg wrote:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> 
> Since userspace state is saved in the MM process, kernel using
> FPU still doesn't really need to do anything, so this really
> is as simple as enabling preemption. The irq critical section
> in sigio_handler() needs preempt_disable()/preempt_enable().
> 
> Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> [vastly simplify, fix x86/um Makefile, rewrite commit message]
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> v10:
>   - rebase on top of various other patchsets, including Benjamin's
>     page table updates: https://patchwork.ozlabs.org/project/linux-um/list/?series=408104
>   - fix x86/um Makefile
>   - remove FPU save/restore code since it's not needed
> ---
>   arch/um/Kconfig      | 2 +-
>   arch/um/kernel/irq.c | 2 ++
>   arch/x86/um/Makefile | 1 -
>   3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index 1faefc0a18ea..dca84fd6d00a 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -11,7 +11,7 @@ config UML
>   	select ARCH_HAS_KCOV
>   	select ARCH_HAS_STRNCPY_FROM_USER
>   	select ARCH_HAS_STRNLEN_USER
> -	select ARCH_NO_PREEMPT
> +	select ARCH_NO_PREEMPT_DYNAMIC
>   	select HAVE_ARCH_AUDITSYSCALL
>   	select HAVE_ARCH_KASAN if X86_64
>   	select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
> diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
> index ceda4bd2e5ed..534e91797f89 100644
> --- a/arch/um/kernel/irq.c
> +++ b/arch/um/kernel/irq.c
> @@ -238,7 +238,9 @@ static void _sigio_handler(struct uml_pt_regs *regs,
>   
>   void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
>   {
> +	preempt_disable();
>   	_sigio_handler(regs, irqs_suspended);
> +	preempt_enable();
>   }
>   
>   static struct irq_entry *get_irq_entry_by_fd(int fd)
> diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
> index 17b85209c43d..36e67fc97c22 100644
> --- a/arch/x86/um/Makefile
> +++ b/arch/x86/um/Makefile
> @@ -31,7 +31,6 @@ obj-y += syscalls_64.o vdso/
>   
>   subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o \
>   	../lib/memmove_64.o ../lib/memset_64.o
> -subarch-$(CONFIG_PREEMPTION) += ../entry/thunk_64.o
>   
>   endif
>   

Is that all we have left? I lost track of your mm patches and they do not apply cleanly to master at present.

Otherwise, the fpu-less on top of the older mm works fine for me. Testing it at the moment.
Johannes Berg July 2, 2024, 10:18 a.m. UTC | #2
On Tue, 2024-07-02 at 11:07 +0100, Anton Ivanov wrote:
> 
> 
> Is that all we have left? 

I think so, yes.

> I lost track of your mm patches and they do not apply cleanly to master at present.

Mine actually mostly went away, in favour of Benjamin's, but his also
didn't apply cleanly due to the compiler warning cleanups.

> Otherwise, the fpu-less on top of the older mm works fine for me. Testing it at the moment.

:-)

We have 40 patches in patchwork now, including the 7 64-bit address
space ones from Benjamin where I think some rework is needed. I've
rebased/applied the other 33, I've just pushed that to the 'pending'
branch:

https://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git/log/?h=pending

johannes
Johannes Berg July 2, 2024, 10:20 a.m. UTC | #3
On Tue, 2024-07-02 at 12:18 +0200, Johannes Berg wrote:
> 
> We have 40 patches in patchwork now, including the 7 64-bit address
> space ones from Benjamin where I think some rework is needed. I've
> rebased/applied the other 33, I've just pushed that to the 'pending'
> branch:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git/log/?h=pending
> 

I should add - the hostfs fix really should go to 'fixes', not 'next',
perhaps soon? Otherwise I think it's all fine for 'next', some fixes are
there but they're limited to unusual (time-travel) configs.

johannes
Anton Ivanov July 2, 2024, 10:21 a.m. UTC | #4
On 02/07/2024 11:18, Johannes Berg wrote:
> On Tue, 2024-07-02 at 11:07 +0100, Anton Ivanov wrote:
>>
>>
>> Is that all we have left?
> 
> I think so, yes.
> 
>> I lost track of your mm patches and they do not apply cleanly to master at present.
> 
> Mine actually mostly went away, in favour of Benjamin's, but his also
> didn't apply cleanly due to the compiler warning cleanups.

Ack.

> 
>> Otherwise, the fpu-less on top of the older mm works fine for me. Testing it at the moment.
> 
> :-)
> 
> We have 40 patches in patchwork now, including the 7 64-bit address
> space ones from Benjamin where I think some rework is needed. I've
> rebased/applied the other 33, I've just pushed that to the 'pending'
> branch:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git/log/?h=pending

Cool. It will be nice to see all of it in the tree at last.

> 
> johannes
> 
> 
>
Johannes Berg July 2, 2024, 10:24 a.m. UTC | #5
On Tue, 2024-07-02 at 10:25 +0200, Johannes Berg wrote:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> 
> Since userspace state is saved in the MM process, kernel using
> FPU still doesn't really need to do anything, so this really
> is as simple as enabling preemption. The irq critical section
> in sigio_handler() needs preempt_disable()/preempt_enable().

For the record, my main interest in this is to unlock debugging for RCU
lists, sleep, etc.

johannes
diff mbox series

Patch

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 1faefc0a18ea..dca84fd6d00a 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -11,7 +11,7 @@  config UML
 	select ARCH_HAS_KCOV
 	select ARCH_HAS_STRNCPY_FROM_USER
 	select ARCH_HAS_STRNLEN_USER
-	select ARCH_NO_PREEMPT
+	select ARCH_NO_PREEMPT_DYNAMIC
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_KASAN if X86_64
 	select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index ceda4bd2e5ed..534e91797f89 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -238,7 +238,9 @@  static void _sigio_handler(struct uml_pt_regs *regs,
 
 void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
 {
+	preempt_disable();
 	_sigio_handler(regs, irqs_suspended);
+	preempt_enable();
 }
 
 static struct irq_entry *get_irq_entry_by_fd(int fd)
diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
index 17b85209c43d..36e67fc97c22 100644
--- a/arch/x86/um/Makefile
+++ b/arch/x86/um/Makefile
@@ -31,7 +31,6 @@  obj-y += syscalls_64.o vdso/
 
 subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o \
 	../lib/memmove_64.o ../lib/memset_64.o
-subarch-$(CONFIG_PREEMPTION) += ../entry/thunk_64.o
 
 endif