Skip to contentSkip to conversation

Xen: Force non-irq keyhandler to be run in tasklet when receive a debugkey from serial port

PATCH In review Lan Tianyu 4 participants 18 messages Oct 22, 2016 – Oct 24, 2016

lore
Share & tools
lore

Lan Tianyu

author
#0 lore raw

PATCH 1/1 Xen: Force non-irq keyhandler to be run in tasklet when receive a debugkey from serial port

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +1 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);
 
     /* Deliver input to guest buffer, unless it is already full. */
     if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE )
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

Quoted 22 lines
---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +1 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);
 
     /* Deliver input to guest buffer, unless it is already full. */
     if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE )
Signature · 1 line
2.9.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
In reply to Lan Tianyu
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -0
index b0f74ce..184b523 100644

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 5 lines
xen/drivers/char/console.c +1 -1
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c. In any case quite likely the other patch of yours (which the one here basically modifies) may then also want to be reverted.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw
Quoted 28 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -0
index b0f74ce..184b523 100644

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 5 lines
xen/drivers/char/console.c +1 -1
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

Quoted 7 lines

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c. In any case quite likely the other patch of yours (which the one here basically modifies) may then also want to be reverted.

Feel free to do so. We don't really need to rush this into 4.8.

Wei.

Quoted 2 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Quoted 19 lines
Quoted 19 lines
---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +1 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);
 
Quoted 5 lines
Quoted 5 lines
xen/drivers/char/console.c +0 -1
     /* Deliver input to guest buffer, unless it is already full. */
     if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE )
--

2.9.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines · Tianyu
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

Quoted 7 lines
Quoted 3 lines

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Right, but the tasklet won't get to run at that point - as for example the IRQ handler is stuck - so tasklets never get run? Or maybe they do on another CPU?

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +1 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
+        return handle_keypress(c, regs, true);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
xen/drivers/char/console.c +0 -1
     /* Deliver input to guest buffer, unless it is already full. */
     if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE )
--

2.9.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Lan, Tianyu
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

Quoted 7 lines
Quoted 3 lines

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

As indicated already by Konrad's reply, this is not going to be acceptable.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#14 lore raw
In reply to Jan Beulich
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
Quoted 8 lines

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 1 line
xen/drivers/char/console.c +1 -0
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

I think the issue here is that my previous patch commit
610b4eda2c("keyhandler: rework process of nonirq keyhandler") makes
non-irq keyhandler run in irq context. This is caused by input param
"!in_irq()" which is false in irq context. handle_keypress() runs keyhandler synchronically. This patch fixes the issue.

Quoted 5 lines

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c.

Yes, but this sounds like a new feature or framework rework rather than a fix patch.

Quoted 3 lines

In any case quite likely the
other patch of yours (which the one here basically modifies) may then also want to be reverted.

I think patch "timer: process softirq during dumping timer" does right thing. The issue is triggered by previous patch.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Tianyu
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

Quoted 8 lines
Quoted 3 lines

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Right, but the tasklet won't get to run at that point - as for example the IRQ handler is stuck - so tasklets never get run? Or maybe they do on another CPU?

If serial interrupt handler works, the cpu receiving serial port interrupt should work normally. Tasklet_schedule() in the handle_keypress() queues keyhandler tasklet to that cpu and tasklet also should get to run at that point.
.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Sorry. A typo. I meant the behavior wasn't changed by my patches.

Quoted 4 lines

As indicated already by Konrad's reply, this is not going to be acceptable.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw
In reply to Lan, Tianyu
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:01, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
Quoted 8 lines

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 1 line
xen/drivers/char/console.c +1 -0
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

Quoted 5 lines

I think the issue here is that my previous patch commit 610b4eda2c("keyhandler: rework process of nonirq keyhandler") makes non-irq keyhandler run in irq context. This is caused by input param "!in_irq()" which is false in irq context. handle_keypress() runs keyhandler synchronically. This patch fixes the issue.

Not really - your earlier patch only moved the !in_irq() check, i.e. things continued to run in the same context they always did _except_ for the one special case you cared about. Plus your other patch fixed the respective issue only for one individual handler, instead of generally.

Quoted 7 lines
Quoted 4 lines

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c.

Yes, but this sounds like a new feature or framework rework rather than a fix patch.

In a way, sure. It's a more extensive fix, which would avoid someone else running into the same issue with another handler.

Quoted 6 lines
Quoted 3 lines

In any case quite likely the
other patch of yours (which the one here basically modifies) may then also want to be reverted.

I think patch "timer: process softirq during dumping timer" does right thing. The issue is triggered by previous patch.

Well - the issue did not exist prior to both of your patches going in, and I think it would have continued to exist if the keyhandler rework patch alone had been reverted. (And I'm afraid anyway that "previous" is ambiguous here, as the timer handler change went in first.)

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
In reply to Lan, Tianyu
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:12, <[email protected]> wrote:
Quoted 15 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Tianyu
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Quoted 8 lines
Quoted 3 lines

Right, but the tasklet won't get to run at that point - as for example the IRQ handler is stuck - so tasklets never get run? Or maybe they do on another CPU?

If serial interrupt handler works, the cpu receiving serial port interrupt should work normally. Tasklet_schedule() in the handle_keypress() queues keyhandler tasklet to that cpu and tasklet also should get to run at that point.

Unless something else in the system is in a state preventing that.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
In reply to Lan, Tianyu
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:15, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Sorry. A typo. I meant the behavior wasn't changed by my patches.

How was it not? The softirq machinery didn't get invoked in that case prior to your patch, afaict.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:15, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Sorry. A typo. I meant the behavior wasn't changed by my patches.

How was it not? The softirq machinery didn't get invoked in that case prior to your patch, afaict.

Which softirq? You mean addiing process_pending_softirqs() in the dump_timerq()?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
Quoted 22 lines · Tianyu
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:15, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Sorry. A typo. I meant the behavior wasn't changed by my patches.

How was it not? The softirq machinery didn't get invoked in that case prior to your patch, afaict.

Which softirq? You mean addiing process_pending_softirqs() in the dump_timerq()?

The softirq code gets executed _after_ the IRQ handler (do_IRQ) is finished doing whatever it needs to do.

Which means that if have say:

1) an errant piece of code that is spinning forever in a loop (say in do_IRQ and then perhaps in __do_IRQ_guest?)

2) The system admin pressed 'Ctrl-A' three times followed by 'C', and ends up in the serial code. We schedule the tasklet, which calls 'tasklet_schedule_on_cpu' - which means the tasklet will only run on _this_ CPU. And then return back to 1) code.

3) The 1) code keeps spinning forever, and we never call do_softirq which means we never process the tasklet.

That is the concern I have. I really really need 'C' to work so that when things go wrong we can analyze the crashdump and figure out what went wrong. But with your patch I can't create the crash dump.

I may also be wrong - maybe this is not the case and the crash dump handler runs just fine (which is just fine). In which case please please explain that in the commit description.

Thanks!

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw
In reply to Lan, Tianyu
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:43, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:15, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 15:29, <[email protected]> wrote:
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Lan Tianyu

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

If the machine is hung with an IRQ handler being stuck, and one does 'Ctrl-Ax3` followed by 'C' .. which would not be invoked (as it is not an IRQ handler??

If serial port's interrupt still works in this case, the 'C' keyhandler kexec_crash() will be invoked in a tasklet. This behavior was changed by my patches if includes this patch.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Sorry. A typo. I meant the behavior wasn't changed by my patches.

How was it not? The softirq machinery didn't get invoked in that case prior to your patch, afaict.

Which softirq? You mean addiing process_pending_softirqs() in the dump_timerq()?

I'm sorry - s/softirq/tasklet/.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw
In reply to Jan Beulich
Quoted 36 lines · Jan Beulich
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:01, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
Quoted 8 lines

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 1 line
xen/drivers/char/console.c +1 -0
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

Quoted 5 lines

I think the issue here is that my previous patch commit 610b4eda2c("keyhandler: rework process of nonirq keyhandler") makes non-irq keyhandler run in irq context. This is caused by input param "!in_irq()" which is false in irq context. handle_keypress() runs keyhandler synchronically. This patch fixes the issue.

Quoted 3 lines

Not really - your earlier patch only moved the !in_irq() check, i.e. things continued to run in the same context they always did _except_ for the one special case you cared about.

I supposed the special case you meant is to run keyhandler in timer handler. It's necessary to make any timer handler run in a short time otherwise it will trigger watchdog problem.

Quoted 3 lines

Plus your
other patch fixed the respective issue only for one individual handler, instead of generally.

So you think adding process_pending_softirqs() in the keyhandler isn't general? But this is a common solution so far.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c.

Yes, but this sounds like a new feature or framework rework rather than a fix patch.

In a way, sure. It's a more extensive fix, which would avoid someone else running into the same issue with another handler.

This seems a big change and a lot of dump function needs to rework, right?

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

In any case quite likely the
other patch of yours (which the one here basically modifies) may then also want to be reverted.

I think patch "timer: process softirq during dumping timer" does right thing. The issue is triggered by previous patch.

Quoted 8 lines

Well - the issue did not exist prior to both of your patches going in, and I think it would have continued to exist if the keyhandler rework patch alone had been reverted. (And I'm afraid anyway that "previous" is ambiguous here, as the timer handler change went in first.)

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#17 lore raw
Quoted 49 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 17:03, <[email protected]> wrote:
Quoted 36 lines · Jan Beulich
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 24.10.16 at 16:01, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 22.10.16 at 13:23, <[email protected]> wrote:

__serial_rx() runs in either irq handler or timer handler and non-irq keyhandler should not run in these contexts. So always force non-irq keyhandler to run in tasklet when receive a debugkey from serial port

---
 xen/drivers/char/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/console.c +0 -1
index b0f74ce..184b523 100644
@@ -347,7 +347,7 @@ static void switch_serial_input(void)
 static void __serial_rx(char c, struct cpu_user_regs *regs)
 {
     if ( xen_rx )
-        return handle_keypress(c, regs, !in_irq());
Quoted 8 lines

xen/drivers/char/console.c static void switch_serial_input(void) · line 350

Quoted 1 line
xen/drivers/char/console.c +1 -0
+        return handle_keypress(c, regs, true);

Together with one of your earlier patches having got reverted, I think we need to take a step back here instead of going back to what was requested to be changed from v2 of the original patch. In particular I assume that the problem you're trying to address is not limited to dump_timerq() - at least dump_runq() should be as problematic on many-CPU systems.

Quoted 5 lines

I think the issue here is that my previous patch commit 610b4eda2c("keyhandler: rework process of nonirq keyhandler") makes non-irq keyhandler run in irq context. This is caused by input param "!in_irq()" which is false in irq context. handle_keypress() runs keyhandler synchronically. This patch fixes the issue.

Quoted 3 lines

Not really - your earlier patch only moved the !in_irq() check, i.e. things continued to run in the same context they always did _except_ for the one special case you cared about.

I supposed the special case you meant is to run keyhandler in timer handler. It's necessary to make any timer handler run in a short time otherwise it will trigger watchdog problem.

Quoted 6 lines
Quoted 3 lines

Plus your
other patch fixed the respective issue only for one individual handler, instead of generally.

So you think adding process_pending_softirqs() in the keyhandler isn't general?

No - it fixes just the one handler where you do that addition. As already said, you for instance leave dump_runq() unfixed, yet I believe it has the same issue.

Quoted 1 line

But this is a common solution so far.

It's a solution which has been used in a few special cases; I wouldn't call this a "common solution", and I know I had expressed this already during review of your original series.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I think (and I vaguely recall possibly having said so during earlier review) that dump functions the output of which depends on CPU count should get modeled after dump_registers(), and it might be worth abstracting this in keyhandler.c.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yes, but this sounds like a new feature or framework rework rather than a fix patch.

In a way, sure. It's a more extensive fix, which would avoid someone else running into the same issue with another handler.

This seems a big change and a lot of dump function needs to rework, right?

I'm not sure. In particular I didn't go check which dump functions have their output really scale with CPU count.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel