2007-05-01 21:25:52

by Glauber Costa

[permalink] [raw]
Subject: [PATCH] Remove unnecessary irq disabling

diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 124b2d2..7eacd5f 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -875,9 +875,7 @@ void __init setup_boot_APIC_clock (void)

void __cpuinit setup_secondary_APIC_clock(void)
{
- local_irq_disable(); /* FIXME: Do we need this? --RR */
setup_APIC_timer(calibration_result);
- local_irq_enable();
}

void disable_APIC_timer(void)


Attachments:
(No filename) (316.00 B)
irq_disable.patch (432.00 B)
Download all attachments

2007-05-01 23:59:25

by Mark Lord

[permalink] [raw]
Subject: Re: [PATCH] Remove unnecessary irq disabling

Glauber de Oliveira Costa wrote:
> RR asks us if it is really necessary to disable interrupts in
> setup_secondary_APIC_clock(). The answer is no, since setup_APIC_timer()
> starts by saving irq flags, which also disables them.
>
> Signed-off-by: Glauber de Oliveira Costa <[email protected]>
>
> --- a/arch/x86_64/kernel/apic.c
> +++ b/arch/x86_64/kernel/apic.c
> @@ -875,9 +875,7 @@ void __init setup_boot_APIC_clock (void)
>
> void __cpuinit setup_secondary_APIC_clock(void)
> {
> - local_irq_disable(); /* FIXME: Do we need this? --RR */
> setup_APIC_timer(calibration_result);
> - local_irq_enable();
> }
>
> void disable_APIC_timer(void)

Okay, I'll bite: before the patch, this code would exit
with interrupts *enabled*, always. Now it does not.

What does that break, or was it already broken and this fixes it?

Cheers

2007-05-02 04:39:32

by Glauber Costa

[permalink] [raw]
Subject: Re: [PATCH] Remove unnecessary irq disabling

On Tue, May 01, 2007 at 07:59:21PM -0400, Mark Lord wrote:
> Glauber de Oliveira Costa wrote:
> >RR asks us if it is really necessary to disable interrupts in
> >setup_secondary_APIC_clock(). The answer is no, since setup_APIC_timer()
> >starts by saving irq flags, which also disables them.
> >
> >Signed-off-by: Glauber de Oliveira Costa <[email protected]>
> >
> >--- a/arch/x86_64/kernel/apic.c
> >+++ b/arch/x86_64/kernel/apic.c
> >@@ -875,9 +875,7 @@ void __init setup_boot_APIC_clock (void)
> >
> > void __cpuinit setup_secondary_APIC_clock(void)
> > {
> >- local_irq_disable(); /* FIXME: Do we need this? --RR */
> > setup_APIC_timer(calibration_result);
> >- local_irq_enable();
> > }
> >
> > void disable_APIC_timer(void)
>
> Okay, I'll bite: before the patch, this code would exit
> with interrupts *enabled*, always. Now it does not.
>
yeah, you have a point. The disable is unnecessary, but maybe
the enable is not. However,

> What does that break, or was it already broken and this fixes it?
I think neither. This function is only called at early bootup,
(start_secondary() ), and most of its callees have interrupts off anyway.
But maybe we do lose something. Andi, do you have a word on this?

--
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"

2007-05-02 09:58:32

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] Remove unnecessary irq disabling


> > What does that break, or was it already broken and this fixes it?
> I think neither. This function is only called at early bootup,
> (start_secondary() ), and most of its callees have interrupts off anyway.
> But maybe we do lose something. Andi, do you have a word on this?

We need to enable them somewhere, but cpu_idle will do it in the end.
So it should be safe to drop it. I guess keeping them disabled the whole
time will be a little safer against potential races.

I added the patch, but might want some cooking in -mm first because this
is always fragile code.

-Andi

2007-05-02 12:27:25

by Mark Lord

[permalink] [raw]
Subject: Re: [PATCH] Remove unnecessary irq disabling

Andi Kleen wrote:
>>> What does that break, or was it already broken and this fixes it?
>> I think neither. This function is only called at early bootup,
>> (start_secondary() ), and most of its callees have interrupts off anyway.
>> But maybe we do lose something. Andi, do you have a word on this?
>
> We need to enable them somewhere, but cpu_idle will do it in the end.
> So it should be safe to drop it. I guess keeping them disabled the whole
> time will be a little safer against potential races.
>
> I added the patch, but might want some cooking in -mm first because this
> is always fragile code.

Okay, that would have it now match how i386 does it.

-ml

2007-05-02 18:33:12

by Glauber Costa

[permalink] [raw]
Subject: Re: [PATCH] Remove unnecessary irq disabling

On Wed, May 02, 2007 at 11:58:17AM +0200, Andi Kleen wrote:
>
> > > What does that break, or was it already broken and this fixes it?
> > I think neither. This function is only called at early bootup,
> > (start_secondary() ), and most of its callees have interrupts off anyway.
> > But maybe we do lose something. Andi, do you have a word on this?
>
> We need to enable them somewhere, but cpu_idle will do it in the end.
> So it should be safe to drop it. I guess keeping them disabled the whole
> time will be a little safer against potential races.
yeah, that's exactly what I've thought. We enable interrupts (to disable
them afterwards) in smp_callin(), to avoid waking up Mr. Watchdog. I
guess it won't be a problem after that, will it?

--
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"