Skip to contentSkip to conversation

Question: goal of twice disabling of preemption in exception handlers

DISCUSSION Alexnader Kuleshov 2 participants 3 messages Nov 20, 2016 – Nov 27, 2016

lore
Share & tools
lore
#0 lore raw

Hello everyone,

Exception handlers which may run on IST stack disable and enable preemption twice. For example do_int3() [1]. This one calls ist_enter() which disables preemption with preempt_disable() every time without any conditions. And later do_int3() calls preempt_disable() again [2] before do_trap().

Of course we decrement preemption counter in the end of such exception handlers twice too. But what's actual purpose of doing this two times?

[1] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n530
[2] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n566

Thank you.

#1 lore raw
Quoted 7 lines · Alexnader Kuleshov

Hello everyone,

Exception handlers which may run on IST stack disable and enable preemption twice. For example do_int3() [1]. This one calls ist_enter() which disables preemption with preempt_disable() every time without any conditions. And later do_int3() calls preempt_disable() again [2] before do_trap().

Quoted 7 lines

Of course we decrement preemption counter in the end of such exception handlers twice too. But what's actual purpose of doing this two times?

[1] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n530
[2] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n566

Thank you.

You could submit a patch to get rid of the extra one if you like.

#2 lore raw
Quoted 12 lines · Andy Lutomirski
Quoted 10 lines · Alexnader Kuleshov

Hello everyone,

Exception handlers which may run on IST stack disable and enable preemption twice. For example do_int3() [1]. This one calls ist_enter() which disables preemption with preempt_disable() every time without any conditions. And later do_int3() calls preempt_disable() again [2] before do_trap().

Of course we decrement preemption counter in the end of such exception handlers twice too. But what's actual purpose of doing this two times?

Quoted 6 lines
Quoted 4 lines

[1] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n530
[2] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/x86/kernel/traps.c?id=refs/tags/next-20161117#n566

Thank you.

You could submit a patch to get rid of the extra one if you like.

Thanks for reply. Will send a patch.