diff mbox series

[RFC,v7,07/21] um: extend arch_switch_to for alternate SUBARCH

Message ID d4a65be8d05d945885f53bc168fd85f08e72adf1.1601960644.git.thehajime@gmail.com
State Not Applicable
Headers show
Series [RFC,v7,01/21] um: split build in kernel and host parts | expand

Commit Message

Hajime Tazaki Oct. 6, 2020, 9:44 a.m. UTC
This commit introduces additional argument of previous task when
context switch happens.  New SUBARCH can use the new information to
switch tasks in a subarch-specific manner.

The patch is particularly required by nommu mode implemented as a
SUBARCH of UML.

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
---
 arch/um/kernel/process.c  | 6 +++---
 arch/x86/um/ptrace_32.c   | 2 +-
 arch/x86/um/syscalls_64.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

Johannes Berg Oct. 7, 2020, 3:25 p.m. UTC | #1
On Tue, 2020-10-06 at 18:44 +0900, Hajime Tazaki wrote:
> This commit introduces additional argument of previous task when
> context switch happens.  New SUBARCH can use the new information to
> switch tasks in a subarch-specific manner.
> 
> The patch is particularly required by nommu mode implemented as a
> SUBARCH of UML.

Would probably be good to already say why here?

johannes
Hajime Tazaki Oct. 9, 2020, 1:24 a.m. UTC | #2
On Thu, 08 Oct 2020 00:25:06 +0900,
Johannes Berg wrote:
> 
> On Tue, 2020-10-06 at 18:44 +0900, Hajime Tazaki wrote:
> > This commit introduces additional argument of previous task when
> > context switch happens.  New SUBARCH can use the new information to
> > switch tasks in a subarch-specific manner.
> > 
> > The patch is particularly required by nommu mode implemented as a
> > SUBARCH of UML.
> 
> Would probably be good to already say why here?

Agree.

The patch is particularly required by nommu mode because it uses
previous task information to control the previous thread (e.g., down
semaphore, terminate thread, clean up thread flags).

Something like this ?

-- Hajime
Johannes Berg Oct. 9, 2020, 4:02 p.m. UTC | #3
On Fri, 2020-10-09 at 10:24 +0900, Hajime Tazaki wrote:
> On Thu, 08 Oct 2020 00:25:06 +0900,
> Johannes Berg wrote:
> > On Tue, 2020-10-06 at 18:44 +0900, Hajime Tazaki wrote:
> > > This commit introduces additional argument of previous task when
> > > context switch happens.  New SUBARCH can use the new information to
> > > switch tasks in a subarch-specific manner.
> > > 
> > > The patch is particularly required by nommu mode implemented as a
> > > SUBARCH of UML.
> > 
> > Would probably be good to already say why here?
> 
> Agree.
> 
> The patch is particularly required by nommu mode because it uses
> previous task information to control the previous thread (e.g., down
> semaphore, terminate thread, clean up thread flags).
> 
> Something like this ?

Well, still not sure I like "nommu" to refer to "library mode", but I'm
also not sure that you can understand that without the context of how
threads actually work in library mode?

Maybe even something vague like

   Having access to the previous thread will be required in library mode
   for it to implement thread switching correctly.

would give some rationale?

johannes
diff mbox series

Patch

diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 26b5e243d3fc..87a8cfa228ca 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -80,7 +80,7 @@  static inline void set_current(struct task_struct *task)
 		{ external_pid(), task });
 }
 
-extern void arch_switch_to(struct task_struct *to);
+extern void arch_switch_to(struct task_struct *from, struct task_struct *to);
 
 void *__switch_to(struct task_struct *from, struct task_struct *to)
 {
@@ -88,7 +88,7 @@  void *__switch_to(struct task_struct *from, struct task_struct *to)
 	set_current(to);
 
 	switch_threads(&from->thread.switch_buf, &to->thread.switch_buf);
-	arch_switch_to(current);
+	arch_switch_to(from, to);
 
 	return current->thread.prev_sched;
 }
@@ -145,7 +145,7 @@  void fork_handler(void)
 	 * arch_switch_to isn't needed. We could want to apply this to
 	 * improve performance. -bb
 	 */
-	arch_switch_to(current);
+	arch_switch_to(NULL, current);
 
 	current->thread.prev_sched = NULL;
 
diff --git a/arch/x86/um/ptrace_32.c b/arch/x86/um/ptrace_32.c
index 2497bac56066..0f184710d4ca 100644
--- a/arch/x86/um/ptrace_32.c
+++ b/arch/x86/um/ptrace_32.c
@@ -11,7 +11,7 @@ 
 
 extern int arch_switch_tls(struct task_struct *to);
 
-void arch_switch_to(struct task_struct *to)
+void arch_switch_to(struct task_struct *from, struct task_struct *to)
 {
 	int err = arch_switch_tls(to);
 	if (!err)
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c
index 58f51667e2e4..2ef9474d2bd2 100644
--- a/arch/x86/um/syscalls_64.c
+++ b/arch/x86/um/syscalls_64.c
@@ -80,7 +80,7 @@  SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
 	return arch_prctl(current, option, (unsigned long __user *) arg2);
 }
 
-void arch_switch_to(struct task_struct *to)
+void arch_switch_to(struct task_struct *from, struct task_struct *to)
 {
 	if ((to->thread.arch.fs == 0) || (to->mm == NULL))
 		return;