Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1310945 > unrolled thread
| Started by | Alexander Kuleshov <kuleshovmail@gmail.com> |
|---|---|
| First post | 2016-01-16 14:10 +0100 |
| Last post | 2016-01-16 23:50 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] x86/traps: use conditional_{cli,sti} in preempt_conditinal_{cli_sti} Alexander Kuleshov <kuleshovmail@gmail.com> - 2016-01-16 14:10 +0100
Re: [PATCH] x86/traps: use conditional_{cli,sti} in preempt_conditinal_{cli_sti} Borislav Petkov <bp@suse.de> - 2016-01-16 20:10 +0100
Re: [PATCH] x86/traps: use conditional_{cli,sti} in preempt_conditinal_{cli_sti} Andy Lutomirski <luto@amacapital.net> - 2016-01-16 23:50 +0100
| From | Alexander Kuleshov <kuleshovmail@gmail.com> |
|---|---|
| Date | 2016-01-16 14:10 +0100 |
| Subject | [PATCH] x86/traps: use conditional_{cli,sti} in preempt_conditinal_{cli_sti} |
| Message-ID | <qRyMa-4L7-5@gated-at.bofh.it> |
The 3d2a71a596bd9 commit (x86, traps: converge do_debug handlers by
Alexander van Heukelum <heukelum@fastmail.fm>) introduces two functions:
preempt_conditional_sti/cli() which are enables/disables interrupts
depends on state of the interrupt enable flag and increments/decrements
the preempt counter.
In the same time arch/x86/kernel/traps.c defines two similar inline
functions: conditional_{sti,cli} which are do the same, but without
touch of the preempt counter. Let's use these functions in the
preempt_conditional_{sti,cli} instead of duplication of 'if' statemets.
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
arch/x86/kernel/traps.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index ade185a..30ec8fa 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -92,8 +92,7 @@ static inline void conditional_sti(struct pt_regs *regs)
static inline void preempt_conditional_sti(struct pt_regs *regs)
{
preempt_count_inc();
- if (regs->flags & X86_EFLAGS_IF)
- local_irq_enable();
+ conditional_sti(regs);
}
static inline void conditional_cli(struct pt_regs *regs)
@@ -104,8 +103,7 @@ static inline void conditional_cli(struct pt_regs *regs)
static inline void preempt_conditional_cli(struct pt_regs *regs)
{
- if (regs->flags & X86_EFLAGS_IF)
- local_irq_disable();
+ conditional_cli(regs);
preempt_count_dec();
}
--
2.7.0.25.gfc10eb5
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@suse.de> |
|---|---|
| Date | 2016-01-16 20:10 +0100 |
| Subject | Re: [PATCH] x86/traps: use conditional_{cli,sti} in preempt_conditinal_{cli_sti} |
| Message-ID | <qREoy-ag-7@gated-at.bofh.it> |
| In reply to | #1310945 |
On Sat, Jan 16, 2016 at 06:58:07PM +0600, Alexander Kuleshov wrote:
> The 3d2a71a596bd9 commit (x86, traps: converge do_debug handlers by
> Alexander van Heukelum <heukelum@fastmail.fm>) introduces two functions:
> preempt_conditional_sti/cli() which are enables/disables interrupts
> depends on state of the interrupt enable flag and increments/decrements
> the preempt counter.
>
> In the same time arch/x86/kernel/traps.c defines two similar inline
> functions: conditional_{sti,cli} which are do the same, but without
> touch of the preempt counter. Let's use these functions in the
> preempt_conditional_{sti,cli} instead of duplication of 'if' statemets.
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
> arch/x86/kernel/traps.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index ade185a..30ec8fa 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -92,8 +92,7 @@ static inline void conditional_sti(struct pt_regs *regs)
> static inline void preempt_conditional_sti(struct pt_regs *regs)
> {
> preempt_count_inc();
> - if (regs->flags & X86_EFLAGS_IF)
> - local_irq_enable();
> + conditional_sti(regs);
What I would do is kill both preempt_conditional_sti() and
preempt_conditional_cli() instead. Why?
Because call sites become more readable:
preempt_disable();
if (regs->flags & X86_EFLAGS_IF)
local_irq_enable();
and
if (regs->flags & X86_EFLAGS_IF)
local_irq_disable();
preempt_enable_no_resched();
Those preempt_* variants are just silly.
Yes, I'd delete conditional_cli() because nothing uses it. And since I'm
deleting crap, I'd delete conditional_sti() too because it's naming is
ugly. You have to know that "STI" means Set Interrupt Flag. Now, if it
were called
cond_local_irq_enable()
that would be better.
So yeah, IMO, the most understandable variant would be:
preempt_disable();
cond_local_irq_enable();
and the opposing pair:
cond_local_irq_disable();
preempt_enable_no_resched();
And *that* is actually understandable at a quick glance.
But that's just me.
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-01-16 23:50 +0100 |
| Message-ID | <qRHPs-2hu-9@gated-at.bofh.it> |
| In reply to | #1311011 |
On Sat, Jan 16, 2016 at 11:06 AM, Borislav Petkov <bp@suse.de> wrote:
> On Sat, Jan 16, 2016 at 06:58:07PM +0600, Alexander Kuleshov wrote:
>> The 3d2a71a596bd9 commit (x86, traps: converge do_debug handlers by
>> Alexander van Heukelum <heukelum@fastmail.fm>) introduces two functions:
>> preempt_conditional_sti/cli() which are enables/disables interrupts
>> depends on state of the interrupt enable flag and increments/decrements
>> the preempt counter.
>>
>> In the same time arch/x86/kernel/traps.c defines two similar inline
>> functions: conditional_{sti,cli} which are do the same, but without
>> touch of the preempt counter. Let's use these functions in the
>> preempt_conditional_{sti,cli} instead of duplication of 'if' statemets.
>>
>> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
>> ---
>> arch/x86/kernel/traps.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
>> index ade185a..30ec8fa 100644
>> --- a/arch/x86/kernel/traps.c
>> +++ b/arch/x86/kernel/traps.c
>> @@ -92,8 +92,7 @@ static inline void conditional_sti(struct pt_regs *regs)
>> static inline void preempt_conditional_sti(struct pt_regs *regs)
>> {
>> preempt_count_inc();
>> - if (regs->flags & X86_EFLAGS_IF)
>> - local_irq_enable();
>> + conditional_sti(regs);
>
> What I would do is kill both preempt_conditional_sti() and
> preempt_conditional_cli() instead. Why?
>
> Because call sites become more readable:
>
> preempt_disable();
>
> if (regs->flags & X86_EFLAGS_IF)
> local_irq_enable();
>
> and
>
> if (regs->flags & X86_EFLAGS_IF)
> local_irq_disable();
>
> preempt_enable_no_resched();
>
> Those preempt_* variants are just silly.
>
> Yes, I'd delete conditional_cli() because nothing uses it. And since I'm
> deleting crap, I'd delete conditional_sti() too because it's naming is
> ugly. You have to know that "STI" means Set Interrupt Flag. Now, if it
> were called
>
> cond_local_irq_enable()
>
> that would be better.
>
> So yeah, IMO, the most understandable variant would be:
>
> preempt_disable();
> cond_local_irq_enable();
>
> and the opposing pair:
>
> cond_local_irq_disable();
> preempt_enable_no_resched();
>
> And *that* is actually understandable at a quick glance.
>
> But that's just me.
>
I agree. Every time I look at those helpers I wonder what the condition is.
Also, "preempt_conditional_sti" meaning "enable interrupts if they
were enabled but *don't* enable preemption" just seems backwards.
--Andy
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web