clean up ret_from_{irq,exception}
PATCH 1/1 clean up ret_from_{irq,exception}
From: Franck Bui-Huu <[email protected]>
This patch makes these routines a lot more readable whatever the value of CONFIG_PREEMPT.
It also moves one branch instruction from ret_from_irq() to ret_from_exception(). Therefore we favour the return from irq path which should be more common than the other one.
--- arch/mips/kernel/entry.S | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-)
arch/mips/kernel/entry.S +5 -10
@@ -21,23 +21,18 @@ #endif #ifndef CONFIG_PREEMPT - .macro preempt_stop - local_irq_disable - .endm #define resume_kernel restore_all #endif .text .align 5 -FEXPORT(ret_from_irq) - LONG_S s0, TI_REGS($28) -#ifdef CONFIG_PREEMPT -FEXPORT(ret_from_exception) -#else - b _ret_from_irq FEXPORT(ret_from_exception) - preempt_stop +#ifndef CONFIG_PREEMPT + local_irq_disable # preempt stop #endif + b _ret_from_irq +FEXPORT(ret_from_irq) + LONG_S s0, TI_REGS($28) FEXPORT(_ret_from_irq) LONG_L t0, PT_STATUS(sp) # returning to kernel mode? andi t0, t0, KU_USER
Signature · 1 line
1.4.4.3.ge6d4
Quoted 7 lines · Franck Bui-Huu
This patch makes these routines a lot more readable whatever the value of
CONFIG_PREEMPT.It also moves one branch instruction from
ret_from_irq()toret_from_exception(). Therefore we favour the return from irq path which should be more common than the other one.
After this patch, entry.S becomes:
FEXPORT(ret_from_exception)
#ifndef CONFIG_PREEMPT
local_irq_disable # preempt stop
#endif b _ret_from_irq FEXPORT(ret_from_irq) LONG_S s0, TI_REGS($28)
FEXPORT(_ret_from_irq)
Apparently your patch add an additional branch in critical path in CONFIG_PREEMPT=y case.
Maybe this would be better?
#ifdef CONFIG_PREEMPTFEXPORT(ret_from_irq)
LONG_S s0, TI_REGS($28) FEXPORT(ret_from_exception) #else FEXPORT(ret_from_exception) local_irq_disable # preempt stop b _ret_from_irq FEXPORT(ret_from_irq) LONG_S s0, TI_REGS($28)
#endifFEXPORT(_ret_from_irq)
---
Atsushi Nemoto
Hi Atsushi,
Quoted 11 lines · Atsushi Nemoto
Maybe this would be better?
#ifdef
CONFIG_PREEMPTFEXPORT(ret_from_irq)LONG_S s0, TI_REGS($28)
FEXPORT(ret_from_exception)
#elseFEXPORT(ret_from_exception)
local_irq_disable# preempt stop
b_ret_from_irqFEXPORT(ret_from_irq)
Quoted 4 lines
LONG_S s0, TI_REGS($28)#endif
FEXPORT(_ret_from_irq)
well maybe this one would be more readable:
-- >8 --
arch/mips/kernel/entry.S +0 -0
@@ -21,23 +21,20 @@
#endif
#ifndef CONFIG_PREEMPT
- .macro preempt_stop
- local_irq_disable
- .endm
#define resume_kernel restore_all
+#else
+#define _ret_from_irq ret_from_exception
#endif
.text .align 5
-FEXPORT(ret_from_irq)
- LONG_S s0, TI_REGS($28)
-#ifdef CONFIG_PREEMPT
+#ifndef CONFIG_PREEMPTFEXPORT(ret_from_exception)
-#else
+ local_irq_disable # preempt stop
b _ret_from_irq
-FEXPORT(ret_from_exception)
- preempt_stop
#endif
+FEXPORT(ret_from_irq)
+ LONG_S s0, TI_REGS($28)FEXPORT(_ret_from_irq)
LONG_L t0, PT_STATUS(sp) # returning to kernel mode? andi t0, t0, KU_USER
Signature · 1 line
Franck
Quoted 9 lines · Franck Bui-Huu
well maybe this one would be more readable:
-- >8 --
arch/mips/kernel/entry.S +0
-0
arch/mips/kernel/entry.S line 27
Quoted 10 lines
arch/mips/kernel/entry.S +2
-3@@ -21,23 +21,20 @@ #endif #ifndef CONFIG_PREEMPT - .macro preempt_stop - local_irq_disable - .endm #define resume_kernel restore_all +#else +#define _ret_from_irq ret_from_exception #endif
_ret_from_irq is used by dec/int-handler.S directly, so you should not remove it (though decstation_defconfig disables CONFIG_PREEMPT).
But looking at dec/int-handler.S again, I can not see why it uses _ret_from_irq, and why it manipulates TI_REGS($28) in handle_it ...
It seems dec/int-handler.S has been broken for a while. I'll send a patch to fix it. If it was ACKed, I ACK your patch.
---
Atsushi Nemoto
Quoted 4 lines · Atsushi Nemoto
_ret_from_irqis used bydec/int-handler.Sdirectly, so you should not remove it (thoughdecstation_defconfigdisablesCONFIG_PREEMPT).
woah, you're right. the name '_ret_from_irq' looks so private to me that I didn't think that some other code could use it...
Quoted 6 lines
But looking at
dec/int-handler.Sagain, I can not see why it uses_ret_from_irq, and why it manipulatesTI_REGS($28)inhandle_it...It seems
dec/int-handler.Shas been broken for a while. I'll send a patch to fix it. If it was ACKed, I ACK your patch.
ok I'm waiting...
Signature · 1 line
Franck
Quoted 8 lines · Atsushi Nemoto
_ret_from_irqis used bydec/int-handler.Sdirectly, so you should not remove it (thoughdecstation_defconfigdisablesCONFIG_PREEMPT).But looking at
dec/int-handler.Sagain, I can not see why it uses_ret_from_irq, and why it manipulatesTI_REGS($28)inhandle_it...It seems
dec/int-handler.Shas been broken for a while. I'll send a patch to fix it. If it was ACKed, I ACK your patch.
It works for me with 2.6.18 -- if it needs an update due to more recent
changes, then I have not got there yet. ;-) I plan to rewrite this bit in C if feasible like other platforms did too.
Maciej
Quoted 6 lines · Maciej W. Rozycki
Quoted 2 lines
It seems
dec/int-handler.Shas been broken for a while. I'll send a patch to fix it. If it was ACKed, I ACK your patch.It works for me with 2.6.18 -- if it needs an update due to more recent
changes, then I have not got there yet. ;-) I plan to rewrite this bit in C if feasible like other platforms did too.
The breakage happened during 2.6.19 development cycle (large pt_regs argument removal).
---
Atsushi Nemoto