Skip to contentSkip to conversation

sh: add support for TIF_NOTIFY_SIGNAL

PATCH In review Jens Axboe 3 participants 20 messages Oct 29, 2020 – Jan 1, 2021 SuperH

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH 1/1 sh: add support for TIF_NOTIFY_SIGNAL

Wire up TIF_NOTIFY_SIGNAL handling for sh.

---

5.11 has support queued up for TIF_NOTIFY_SIGNAL, see this posting for details:

https://lore.kernel.org/io-uring/[email protected]/

As part of that work, I'm adding TIF_NOTIFY_SIGNAL support to all archs, as that will enable a set of cleanups once all of them support it. I'm happy carrying this patch if need be, or it can be funelled through the arch tree. Let me know.

 arch/sh/include/asm/thread_info.h | 4 +++-
 arch/sh/kernel/signal_32.c        | 7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/sh/include/asm/thread_info.h +3 -1
index 243ea5150aa0..598d0184ffea 100644
@@ -105,6 +105,7 @@ extern void init_thread_xstate(void);
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
+#define TIF_NOTIFY_SIGNAL	3	/* signal notifications exist */
 #define TIF_SINGLESTEP		4	/* singlestepping active */
 #define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
 #define TIF_SECCOMP		6	/* secure computing */
@@ -116,6 +117,7 @@ extern void init_thread_xstate(void);
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
@@ -132,7 +134,7 @@ extern void init_thread_xstate(void);
 #define _TIF_ALLWORK_MASK	(_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
 				 _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
 				 _TIF_SINGLESTEP    | _TIF_NOTIFY_RESUME   | \
-				 _TIF_SYSCALL_TRACEPOINT)
+				 _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
arch/sh/kernel/signal_32.c +5 -2
index 1add47fd31f6..8cfae5a75edb 100644
@@ -466,7 +466,10 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
 	if (!user_mode(regs))
 		return;
 
-	if (get_signal(&ksig)) {
+	if (ti_work & _TIF_NOTIFY_SIGNAL)
+		tracehook_notify_signal();
+
+	if ((ti_work & _TIF_SIGPENDING) && get_signal(&ksig)) {
 		handle_syscall_restart(save_r0, regs, &ksig.ka.sa);
 
 		/* Whee!  Actually deliver the signal.  */
@@ -499,7 +502,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
 				 unsigned long thread_info_flags)
 {
 	/* deal with pending signal delivery */
-	if (thread_info_flags & _TIF_SIGPENDING)
+	if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
 		do_signal(regs, save_r0);
 
 	if (thread_info_flags & _TIF_NOTIFY_RESUME)
Signature · 4 lines
2.29.0

-- 
Jens Axboe
author
#1 lore raw

Gentle nudge on this one.

Quoted 75 lines · Jens Axboe

Wire up TIF_NOTIFY_SIGNAL handling for sh.

---

5.11 has support queued up for TIF_NOTIFY_SIGNAL, see this posting for details:

https://lore.kernel.org/io-uring/[email protected]/

As part of that work, I'm adding TIF_NOTIFY_SIGNAL support to all archs, as that will enable a set of cleanups once all of them support it. I'm happy carrying this patch if need be, or it can be funelled through the arch tree. Let me know.

 arch/sh/include/asm/thread_info.h | 4 +++-
 arch/sh/kernel/signal_32.c        | 7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
arch/sh/include/asm/thread_info.h +3 -1
index 243ea5150aa0..598d0184ffea 100644
@@ -105,6 +105,7 @@ extern void init_thread_xstate(void);
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
+#define TIF_NOTIFY_SIGNAL	3	/* signal notifications exist */
 #define TIF_SINGLESTEP		4	/* singlestepping active */
 #define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
 #define TIF_SECCOMP		6	/* secure computing */
@@ -116,6 +117,7 @@ extern void init_thread_xstate(void);
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
@@ -132,7 +134,7 @@ extern void init_thread_xstate(void);
 #define _TIF_ALLWORK_MASK	(_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
 				 _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
 				 _TIF_SINGLESTEP    | _TIF_NOTIFY_RESUME   | \
-				 _TIF_SYSCALL_TRACEPOINT)
+				 _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
arch/sh/kernel/signal_32.c +5 -2
index 1add47fd31f6..8cfae5a75edb 100644
@@ -466,7 +466,10 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
 	if (!user_mode(regs))
 		return;
 
-	if (get_signal(&ksig)) {
+	if (ti_work & _TIF_NOTIFY_SIGNAL)
+		tracehook_notify_signal();
+
+	if ((ti_work & _TIF_SIGPENDING) && get_signal(&ksig)) {
 		handle_syscall_restart(save_r0, regs, &ksig.ka.sa);
 
 		/* Whee!  Actually deliver the signal.  */
@@ -499,7 +502,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
 				 unsigned long thread_info_flags)
 {
 	/* deal with pending signal delivery */
-	if (thread_info_flags & _TIF_SIGPENDING)
+	if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
 		do_signal(regs, save_r0);
 
 	if (thread_info_flags & _TIF_NOTIFY_RESUME)
Signature · 1 line
Jens Axboe
#2 lore raw
In reply to Jens Axboe

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

I can build- and boot-test on SH and IA64.

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#3 lore raw
In reply to Jens Axboe
Quoted 6 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

Signature · 1 line
Jens Axboe
#4 lore raw
In reply to Jens Axboe
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Rob

#5 lore raw
In reply to Jens Axboe

Hi Jens!

Quoted 9 lines · Jens Axboe
Quoted 6 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#6 lore raw
In reply to Jens Axboe
Quoted 23 lines · Rob Landley
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

Quoted 8 lines

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Yeah that's my fault, this one should be a lot better...

commit de2791b15d47a56854054da71064b9634896728b

Author: Jens Axboe <[email protected]>
Date:   Fri Oct 9 15:36:35 2020 -0600

sh: add support for TIF_NOTIFY_SIGNAL

Wire up TIF_NOTIFY_SIGNAL handling for sh.

arch/sh/include/asm/thread_info.h +3 -1
index 243ea5150aa0..598d0184ffea 100644
@@ -105,6 +105,7 @@ extern void init_thread_xstate(void);
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
+#define TIF_NOTIFY_SIGNAL	3	/* signal notifications exist */
 #define TIF_SINGLESTEP		4	/* singlestepping active */
 #define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
 #define TIF_SECCOMP		6	/* secure computing */
@@ -116,6 +117,7 @@ extern void init_thread_xstate(void);
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
@@ -132,7 +134,7 @@ extern void init_thread_xstate(void);
 #define _TIF_ALLWORK_MASK	(_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
 				 _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
 				 _TIF_SINGLESTEP    | _TIF_NOTIFY_RESUME   | \
-				 _TIF_SYSCALL_TRACEPOINT)
+				 _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
arch/sh/kernel/signal_32.c +8 -4
index 1add47fd31f6..e78d3e10a203 100644
@@ -453,7 +453,8 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs, unsigned int save_r0)
  * the kernel can handle, and then we build all the user-level signal handling
  * stack-frames in one go after that.
  */
-static void do_signal(struct pt_regs *regs, unsigned int save_r0)
+static void do_signal(struct pt_regs *regs, unsigned int save_r0,
+		      unsigned long ti_work)
 {
 	struct ksignal ksig;
 
@@ -466,7 +467,10 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
 	if (!user_mode(regs))
 		return;
 
-	if (get_signal(&ksig)) {
+	if (ti_work & _TIF_NOTIFY_SIGNAL)
+		tracehook_notify_signal();
+
+	if ((ti_work & _TIF_SIGPENDING) && get_signal(&ksig)) {
 		handle_syscall_restart(save_r0, regs, &ksig.ka.sa);
 
 		/* Whee!  Actually deliver the signal.  */
@@ -499,8 +503,8 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
 				 unsigned long thread_info_flags)
 {
 	/* deal with pending signal delivery */
-	if (thread_info_flags & _TIF_SIGPENDING)
-		do_signal(regs, save_r0);
+	if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
+		do_signal(regs, save_r0, thread_info_flags);
 
 	if (thread_info_flags & _TIF_NOTIFY_RESUME)
 		tracehook_notify_resume(regs);
Signature · 1 line
Jens Axboe
author
#7 lore raw
In reply to Jens Axboe
Quoted 9 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Thanks, both would be appreciated! Just CC'ed you on the updated patch for sh.

Signature · 1 line
Jens Axboe
author
#8 lore raw
In reply to Jens Axboe
Quoted 36 lines · Rob Landley
Quoted 33 lines · Jens Axboe
Quoted 31 lines · Rob Landley
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Quoted 8 lines
Quoted 1 line

Yeah that's my fault, this one should be a lot better...

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:471:3: error: implicit declaration of function 'tracehook_notify_signal'; did you mean 'tracehook_notify_resume'? [-Werror=implicit-function-declaration]

Keep 'em coming...

Gah, it was still using the old style. This one should work and be correct, promise, double checked :-)

commit 748887e0b8e7557d79a04e0f8e930027770d7b28

Author: Jens Axboe <[email protected]>
Date:   Fri Oct 9 15:36:35 2020 -0600

sh: add support for TIF_NOTIFY_SIGNAL

Wire up TIF_NOTIFY_SIGNAL handling for sh.

arch/sh/include/asm/thread_info.h +3 -1
index 243ea5150aa0..598d0184ffea 100644
@@ -105,6 +105,7 @@ extern void init_thread_xstate(void);
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 #define TIF_SIGPENDING		1	/* signal pending */
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
+#define TIF_NOTIFY_SIGNAL	3	/* signal notifications exist */
 #define TIF_SINGLESTEP		4	/* singlestepping active */
 #define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
 #define TIF_SECCOMP		6	/* secure computing */
@@ -116,6 +117,7 @@ extern void init_thread_xstate(void);
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
+#define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
@@ -132,7 +134,7 @@ extern void init_thread_xstate(void);
 #define _TIF_ALLWORK_MASK	(_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
 				 _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
 				 _TIF_SINGLESTEP    | _TIF_NOTIFY_RESUME   | \
-				 _TIF_SYSCALL_TRACEPOINT)
+				 _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL)
 
 /* work to do on interrupt/exception return */
 #define _TIF_WORK_MASK		(_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
arch/sh/kernel/signal_32.c +1 -1
index 1add47fd31f6..dd3092911efa 100644
@@ -499,7 +499,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
 				 unsigned long thread_info_flags)
 {
 	/* deal with pending signal delivery */
-	if (thread_info_flags & _TIF_SIGPENDING)
+	if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
 		do_signal(regs, save_r0);
 
 	if (thread_info_flags & _TIF_NOTIFY_RESUME)
Signature · 1 line
Jens Axboe
#9 lore raw
In reply to Jens Axboe
Quoted 31 lines · Jens Axboe
Quoted 30 lines · Rob Landley
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

Quoted 3 lines
Quoted 1 line

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Yeah that's my fault, this one should be a lot better...

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:471:3: error: implicit declaration of function 'tracehook_notify_signal'; did you mean 'tracehook_notify_resume'? [-Werror=implicit-function-declaration]

Keep 'em coming...

Rob

author
#10 lore raw
In reply to Jens Axboe
Quoted 45 lines · Rob Landley
Quoted 44 lines · Jens Axboe
Quoted 43 lines · Rob Landley
Quoted 31 lines · Jens Axboe
Quoted 30 lines · Rob Landley
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

Quoted 3 lines
Quoted 1 line

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Yeah that's my fault, this one should be a lot better...

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:471:3: error: implicit declaration of function 'tracehook_notify_signal'; did you mean 'tracehook_notify_resume'? [-Werror=implicit-function-declaration]

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Keep 'em coming...

Gah, it was still using the old style. This one should work and be correct, promise, double checked :-)

This one compiled fine. What does it do? (I ask having read
https://lwn.net/Articles/835340/ and come out none the wiser.)

The motivation is in another patch:

https://git.kernel.dk/cgit/linux-block/commit/?h=tif-task_work&idýb5f027ce662d1e10d8d16793b1f588b8543277

Basically it decouples TWA_SIGNAL task_work from actual signals, since they contend on the sighand lock, particularly for threads. Hence the goal is to get all archs supporting TIF_NOTIFY_SIGNAL, so we can use that for TWA_SIGNAL.

The patches are done such that the signal handling core still handles running the task_work, but if invoked without TIF_SIGPENDING, we don't do actual signal delivery, just the syscall restart part.

Quoted 1 line

I can try it on hardware in the morning, it's 1am in this time zone...

Thanks, that'd be great! It really should be a no-op, as you can see from the final patch, it's just masking in an extra flag for when to call get_signal(). At least it should've been, if I hadn't neglected to properly updated the 'sh' patch for the cleaner setup...

Signature · 1 line
Jens Axboe
#11 lore raw
In reply to Jens Axboe
Quoted 44 lines · Jens Axboe
Quoted 43 lines · Rob Landley
Quoted 31 lines · Jens Axboe
Quoted 30 lines · Rob Landley
Quoted 6 lines · Jens Axboe
Quoted 5 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 1 line · Jens Axboe

Gentle nudge on this one.

Quoted 7 lines
Quoted 1 line

I can build- and boot-test on SH and IA64.

That'd be great, thanks!

Quoted 1 line

I assume Rich will be fine with the SH changes, not sure about the IA64 and Tony.

Let's add Tony - maybe he'll have a chance to take a look at the ia64 change.

It breaks my ARCH=sh j2_defconfig build:

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:469:6: error: 'ti_work' undeclared (first use in this function)

Admittedly I'm testing a stack of 6 other patches at the same time:

[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE.eml [PATCH] sh: dma: fix kconfig dependency for G2_DMA.eml
[PATCH] sh: remove CONFIG_IDE from most defconfig.eml
[PATCH] sh: Remove unused HAVE_COPY_THREAD_TLS macro.eml
[PATCH v1] sh: Drop ARCH_NR_GPIOS definition.eml
[PATCH v2 RESEND +TRIVIAL] arch_sh: hyphenate Non-Uniform in Kconfig prompt.eml

Quoted 3 lines
Quoted 1 line

But this is the one I need to revert to get 5.10-rc3 to build, the rest compile.

Yeah that's my fault, this one should be a lot better...

arch/sh/kernel/signal_32.c: In function 'do_signal':
arch/sh/kernel/signal_32.c:471:3: error: implicit declaration of function 'tracehook_notify_signal'; did you mean 'tracehook_notify_resume'? [-Werror=implicit-function-declaration]

Quoted 4 lines
Quoted 1 line

Keep 'em coming...

Gah, it was still using the old style. This one should work and be correct, promise, double checked :-)

This one compiled fine. What does it do? (I ask having read
https://lwn.net/Articles/835340/ and come out none the wiser.)

I can try it on hardware in the morning, it's 1am in this time zone...

Rob

#12 lore raw
In reply to Jens Axboe

Hi Jens!

Quoted 6 lines · Jens Axboe
Quoted 3 lines

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Thanks, both would be appreciated! Just CC'ed you on the updated patch for sh.

Is this still relevant for testing? I'm ready to test now, much later than I thought, sorry.

I'm going to build Linus' latest kernel for my SH and IA64 machines now and then I can test additional patches on top of it.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#13 lore raw
In reply to Jens Axboe
Quoted 7 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 4 lines · Jens Axboe
Quoted 3 lines

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Quoted 8 lines
Quoted 2 lines

Thanks, both would be appreciated! Just CC'ed you on the updated patch for sh.

Is this still relevant for testing? I'm ready to test now, much later than I thought, sorry.

I'm going to build Linus' latest kernel for my SH and IA64 machines now and then I can test additional patches on top of it.

Thanks, would definitely still appreciate testing. You can just run linux-next if you want, it's got everything in there. Or apply the separate patches to -git, either approach is fine.

Signature · 1 line
Jens Axboe
#14 lore raw

Hi Jens!

Quoted 14 lines · Jens Axboe
Quoted 13 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 6 lines · Jens Axboe
Quoted 3 lines

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Thanks, both would be appreciated! Just CC'ed you on the updated patch for sh.

Is this still relevant for testing? I'm ready to test now, much later than I thought, sorry.

Quoted 6 lines
Quoted 2 lines

I'm going to build Linus' latest kernel for my SH and IA64 machines now and then I can test additional patches on top of it.

Thanks, would definitely still appreciate testing. You can just run linux-next if you want, it's got everything in there. Or apply the separate patches to -git, either approach is fine.

Apologies for the late reply.

I just pulled Linus' latest tree today with your patch for SH included and I'm not seeing any regressions.

Is there away to test the change itself?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#15 lore raw
Quoted 24 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 14 lines · Jens Axboe
Quoted 13 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 6 lines · Jens Axboe
Quoted 3 lines

Sorry for the delay. I'm busy at the moment and my SH board is currently building the Perl 5.32 package for Debian. Will try to test your patches by tomorrow, also ia64.

Thanks, both would be appreciated! Just CC'ed you on the updated patch for sh.

Is this still relevant for testing? I'm ready to test now, much later than I thought, sorry.

Quoted 6 lines
Quoted 2 lines

I'm going to build Linus' latest kernel for my SH and IA64 machines now and then I can test additional patches on top of it.

Thanks, would definitely still appreciate testing. You can just run linux-next if you want, it's got everything in there. Or apply the separate patches to -git, either approach is fine.

Quoted 6 lines

Apologies for the late reply.

I just pulled Linus' latest tree today with your patch for SH included and I'm not seeing any regressions.

Is there away to test the change itself?

The only user of TWA_SIGNAL, which uses TIF_NOTIFY_SIGNAL, so far is io_uring. You need something that triggers deferred task_work processing, which is basically anything that ends up being poll driven for data/space readiness. Here's a small test app from the liburing test suite, that'll trigger it.

If you install liburing, compile with:

gcc -Wall -O2 -o socket-rw socket-rw.c -luring

and run it without any arguments.

Signature · 1 line
Jens Axboe

/* SPDX-License-Identifier: MIT */
/*
* Check that a readv on a socket queued before a writev doesn't hang
* the processing.
*
* From Hrvoje Zeba <[email protected]>
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>

#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/tcp.h>
#include <netinet/in.h>

#include <liburing.h>

int main(int argc, char *argv[])

{
	int p_fd[2], ret;
	int32_t recv_s0;
	int32_t val = 1;
	struct sockaddr_in addr;

	if (argc > 1)
		return 0;

	recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);

	ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
	assert(ret != -1);
	ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
	assert(ret != -1);

	addr.sin_family = AF_INET;
	addr.sin_port = 0x1235;
	addr.sin_addr.s_addr = 0x0100007fU;

	ret = bind(recv_s0, (struct sockaddr*)&addr, sizeof(addr));
	assert(ret != -1);
	ret = listen(recv_s0, 128);
	assert(ret != -1);


	p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);

	val = 1;
	ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
	assert(ret != -1);

	int32_t flags = fcntl(p_fd[1], F_GETFL, 0);
	assert(flags != -1);

	flags |= O_NONBLOCK;
	ret = fcntl(p_fd[1], F_SETFL, flags);
	assert(ret != -1);

	ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
	assert(ret == -1);

	flags = fcntl(p_fd[1], F_GETFL, 0);
	assert(flags != -1);

	flags &= ~O_NONBLOCK;
	ret = fcntl(p_fd[1], F_SETFL, flags);
	assert(ret != -1);

	p_fd[0] = accept(recv_s0, NULL, NULL);
	assert(p_fd[0] != -1);

	while (1) {
		int32_t code;
		socklen_t code_len = sizeof(code);

		ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
		assert(ret != -1);

		if (!code)
			break;
	}

	struct io_uring m_io_uring;

	ret = io_uring_queue_init(32, &m_io_uring, 0);
	assert(ret >= 0);

	char recv_buff[128];
	char send_buff[128];

	{
		struct iovec iov[1];

		iov[0].iov_base = recv_buff;
		iov[0].iov_len = sizeof(recv_buff);

		struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
		assert(sqe != NULL);

		io_uring_prep_readv(sqe, p_fd[0], iov, 1, 0);
	}

	{
		struct iovec iov[1];

		iov[0].iov_base = send_buff;
		iov[0].iov_len = sizeof(send_buff);

		struct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);
		assert(sqe != NULL);

		io_uring_prep_writev(sqe, p_fd[1], iov, 1, 0);
	}

	ret = io_uring_submit_and_wait(&m_io_uring, 2);
	assert(ret != -1);

	struct io_uring_cqe* cqe;
	uint32_t head;
	uint32_t count = 0;

	while (count != 2) {
		io_uring_for_each_cqe(&m_io_uring, head, cqe) {
			assert(cqe->res == 128);
			count++;
		}

		assert(count <= 2);
		io_uring_cq_advance(&m_io_uring, count);
	}

	io_uring_queue_exit(&m_io_uring);
	return 0;
}
#16 lore raw

Hi Jens!

Quoted 8 lines · Jens Axboe
Quoted 1 line · John Paul Adrian Glaubitz

Is there away to test the change itself?

The only user of TWA_SIGNAL, which uses TIF_NOTIFY_SIGNAL, so far is io_uring. You need something that triggers deferred task_work processing, which is basically anything that ends up being poll driven for data/space readiness. Here's a small test app from the liburing test suite, that'll trigger it.

Quoted 5 lines

If you install liburing, compile with:

gcc -Wall -O2 -o socket-rw socket-rw.c -luring

and run it without any arguments.

How long is this test supposed to run? It's already been running for some minutes on my 600 MHz machine.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#17 lore raw
Quoted 11 lines · John Paul Adrian Glaubitz

Hi Jens!

Quoted 8 lines · Jens Axboe
Quoted 1 line · John Paul Adrian Glaubitz

Is there away to test the change itself?

The only user of TWA_SIGNAL, which uses TIF_NOTIFY_SIGNAL, so far is io_uring. You need something that triggers deferred task_work processing, which is basically anything that ends up being poll driven for data/space readiness. Here's a small test app from the liburing test suite, that'll trigger it.

Quoted 8 lines
Quoted 5 lines

If you install liburing, compile with:

gcc -Wall -O2 -o socket-rw socket-rw.c -luring

and run it without any arguments.

How long is this test supposed to run? It's already been running for some minutes on my 600 MHz machine.

It's supposed to finish very quickly:

axboe@p1 ~> time ./socket-rw 0.000s

________________________________________________________
Executed in 1.10 millis fish external
usr time 888.00 micros 278.00 micros 610.00 micros
sys time 35.00 micros 35.00 micros 0.00 micros

If it doesn't, can you try:

# echo 1 > /sys/kernel/debug/tracing/events/io_uring/enable

Then run the socket-rw app, and then do:

# cat /sys/kernel/debug/tracing/trace

and send that output? Might also be useful to include the strace of the socket-rw just in case, so maybe run it ala

strace -o foo ./socket-rw

and include foo in the reply as well.

Signature · 1 line
Jens Axboe
#18 lore raw

On 1/1/21 4:35 PM, Jens Axboe wrote:> It's supposed to finish very quickly:

Quoted 14 lines

axboe@p1 ~> time ./socket-rw 0.000s

________________________________________________________
Executed in 1.10 millis fish external
usr time 888.00 micros 278.00 micros 610.00 micros
sys time 35.00 micros 35.00 micros 0.00 micros

If it doesn't, can you try:

# echo 1 > /sys/kernel/debug/tracing/events/io_uring/enable

Then run the socket-rw app, and then do:

Quoted 8 lines
# cat /sys/kernel/debug/tracing/trace

and send that output? Might also be useful to include the strace of the socket-rw just in case, so maybe run it ala

strace -o foo ./socket-rw

and include foo in the reply as well.

Odd, I just ran it through strace and it exited immediately:

root@tirpitz:~> strace ./socket-rw
execve("./socket-rw", ["./socket-rw"], 0x7bb26670 /* 25 vars */) = 0
brk(NULL) = 0x412000
uname({sysname="Linux", nodename="tirpitz", ...}) = 0
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_sized232, ...}) = 0
mmap2(NULL, 64232, PROT_READ, MAP_PRIVATE, 3, 0) = 0x29584000
close(3) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x29574000 openat(AT_FDCWD, "/usr/lib/sh4-linux-gnu/liburing.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0*\0\1\0\0\0\324\17\0\0004\0\0\0"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0644, st_size•36, ...}) = 0
mmap2(NULL, 73852, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x29594000 mprotect(0x29596000, 61440, PROT_NONE) = 0
mmap2(0x295a5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x295a5000
close(3) = 0
openat(AT_FDCWD, "/lib/sh4-linux-gnu/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0*\0\1\0\0\0\224\306\1\0004\0\0\0"..., 512) = 512 pread64(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\3\0\0\0\2\0\0\0\0\0\0\0", 32, 1290836) = 32 fstat64(3, {st_mode=S_IFREG|0755, st_size97036, ...}) = 0
mmap2(NULL, 1366256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x295a8000 mprotect(0x296e1000, 61440, PROT_NONE) = 0
mmap2(0x296f0000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x138000) = 0x296f0000 mmap2(0x296f4000, 6384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x296f4000

close(3)                                = 0
mprotect(0x296f0000, 8192, PROT_READ)   = 0
mprotect(0x295a5000, 4096, PROT_READ)   = 0
mprotect(0x410000, 4096, PROT_READ)     = 0
mprotect(0x29582000, 4096, PROT_READ)   = 0
munmap(0x29584000, 64232)               = 0

socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sa_family¯_INET, sin_port=htons(13586), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
listen(3, 128) = 0
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 4
setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(4, {sa_family¯_INET, sin_port=htons(13586), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)

fcntl64(4, F_GETFL)                     = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl64(4, F_SETFL, O_RDWR)             = 0
accept(3, NULL, NULL)                   = 5
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
io_uring_setup(32, {flags=0, sq_thread_cpu=0, sq_thread_idle=0, sq_entries2, cq_entriesd, features=IORING_FEAT_SINGLE_MMAP|IORING_FEAT_NODROP|IORING_FEAT_SUBMIT_STABLE|IORING_FEAT_RW_CUR_POS|IORING_FEAT_CUR_PERSONALITY|0x1e0, sq_off={head=0, tail=4, ring_mask, ring_entries$, flags6, dropped2, array72}, cq_off={head=8, tail, ring_mask , ring_entries(, overflowD, cqesH, resv=[0x28, 0]}}) = 6
mmap2(NULL, 1200, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE, 6, 0) = 0x29576000
mmap2(NULL, 2048, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE, 6, 0x10000000) = 0x29578000
io_uring_enter(6, 2, 2, IORING_ENTER_GETEVENTS, NULL, 8) = 2
munmap(0x29578000, 2048)                = 0
munmap(0x29576000, 1200)                = 0
close(6)                                = 0
exit_group(0)                           = ?

+++ exited with 0 +++
root@tirpitz:~>

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#19 lore raw
Quoted 17 lines · John Paul Adrian Glaubitz

On 1/1/21 4:35 PM, Jens Axboe wrote:> It's supposed to finish very quickly:

Quoted 16 lines

axboe@p1 ~> time ./socket-rw 0.000s

________________________________________________________
Executed in 1.10 millis fish external
usr time 888.00 micros 278.00 micros 610.00 micros
sys time 35.00 micros 35.00 micros 0.00 micros

If it doesn't, can you try:

# echo 1 > /sys/kernel/debug/tracing/events/io_uring/enable

Then run the socket-rw app, and then do:

# cat /sys/kernel/debug/tracing/trace
Quoted 8 lines
Quoted 6 lines

and send that output? Might also be useful to include the strace of the socket-rw just in case, so maybe run it ala

strace -o foo ./socket-rw

and include foo in the reply as well.

Odd, I just ran it through strace and it exited immediately:

That looks correct, it sets up a ring, issues and waits for two requests. Both of those requests require TWA_SIGNAL processing.

Signature · 1 line
Jens Axboe