2009-03-28 01:25:45

by Rakib Mullick

[permalink] [raw]
Subject: [PATCH] x86,apic: Checking kernel option before detect_init_APIC()

Impact: cleanup

Before calling detect_init_APIC(), check whether apic is disabled from
kernel option or not.

Thanks.

Signed-off-by: Rakib Mullick <[email protected]>

--- linus/arch/x86/kernel/apic.c 2009-03-26 06:26:31.000000000 +0600
+++ rakib/arch/x86/kernel/apic.c 2009-03-26 20:47:50.116376200 +0600
@@ -1429,10 +1429,6 @@ static int __init detect_init_APIC(void)
{
u32 h, l, features;

- /* Disabled by kernel option? */
- if (disable_apic)
- return -1;
-
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_AMD:
if ((boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model > 1) ||
@@ -1543,8 +1539,9 @@ void __init init_apic_mappings(void)
* If no local APIC can be found then set up a fake all
* zeroes page to simulate the local APIC and another
* one for the IO-APIC.
+ * Check apic is disabled from kernel option or not.
*/
- if (!smp_found_config && detect_init_APIC()) {
+ if (!smp_found_config && (disable_apic || detect_init_APIC())) {
apic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
apic_phys = __pa(apic_phys);
} else


2009-04-08 14:51:20

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86,apic: Checking kernel option before detect_init_APIC()


* Rakib Mullick <[email protected]> wrote:

> Impact: cleanup
>
> Before calling detect_init_APIC(), check whether apic is disabled
> from kernel option or not.
>
> Thanks.
>
> Signed-off-by: Rakib Mullick <[email protected]>
>
> --- linus/arch/x86/kernel/apic.c 2009-03-26 06:26:31.000000000 +0600
> +++ rakib/arch/x86/kernel/apic.c 2009-03-26 20:47:50.116376200 +0600
> @@ -1429,10 +1429,6 @@ static int __init detect_init_APIC(void)
> {
> u32 h, l, features;
>
> - /* Disabled by kernel option? */
> - if (disable_apic)
> - return -1;
> -
> switch (boot_cpu_data.x86_vendor) {
> case X86_VENDOR_AMD:
> if ((boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model > 1) ||
> @@ -1543,8 +1539,9 @@ void __init init_apic_mappings(void)
> * If no local APIC can be found then set up a fake all
> * zeroes page to simulate the local APIC and another
> * one for the IO-APIC.
> + * Check apic is disabled from kernel option or not.
> */
> - if (!smp_found_config && detect_init_APIC()) {
> + if (!smp_found_config && (disable_apic || detect_init_APIC())) {
> apic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
> apic_phys = __pa(apic_phys);
> } else

Hm, are you sure this is a cleanup only? (i.e. no side-effects)

Also, even if it's a pure cleanup, wouldnt it be even cleaner to
propagate this check into detect_init_APIC() - and thus get rid of
the open-coded disable_apic check altogether?

Ingo

2009-04-09 05:08:55

by Rakib Mullick

[permalink] [raw]
Subject: Re: [PATCH] x86,apic: Checking kernel option before detect_init_APIC()

On Wed, Apr 8, 2009 at 8:50 PM, Ingo Molnar <[email protected]> wrote:
>
> * Rakib Mullick <[email protected]> wrote:
>
> Hm, are you sure this is a cleanup only? (i.e. no side-effects)
My quick review over code, i don't think there's any.Unless I'm not
missing anything. Kernel option has been passed when before kernel
starts, so I think it's safe.
>
> Also, even if it's a pure cleanup, wouldnt it be even cleaner to
> propagate this check into detect_init_APIC() - and thus get rid of
> the open-coded disable_apic check altogether?
Yes, could be. How we'll understand that whether apic has been
disabled from kernel option or not (if we requires later on)?

Rakib
>
> ? ? ? ?Ingo
>

2009-04-09 20:00:31

by Cyrill Gorcunov

[permalink] [raw]
Subject: Re: [PATCH] x86,apic: Checking kernel option before detect_init_APIC()

[Rakib Mullick - Thu, Apr 09, 2009 at 11:08:43AM +0600]
| On Wed, Apr 8, 2009 at 8:50 PM, Ingo Molnar <[email protected]> wrote:
| >
| > * Rakib Mullick <[email protected]> wrote:
| >
| > Hm, are you sure this is a cleanup only? (i.e. no side-effects)
| My quick review over code, i don't think there's any.Unless I'm not
| missing anything. Kernel option has been passed when before kernel
| starts, so I think it's safe.

Hi Rakib,

yes, disable_apic early parameter handled earlier then
init_apic_mappings is being called but we could reach
disable_apic=1 with not only as kernel option but as
result of acpi_mps_check for example (which
is called earlier then init_apic_mappings though).
So this snippet is safe I believe.

| >
| > Also, even if it's a pure cleanup, wouldnt it be even cleaner to
| > propagate this check into detect_init_APIC() - and thus get rid of
| > the open-coded disable_apic check altogether?

In point! We do same fasion check in APIC_init_uniprocessor

| Yes, could be. How we'll understand that whether apic has been
| disabled from kernel option or not (if we requires later on)?

AFAIS, as only we set disable_apic=1 from kernel option (or other
ways) we clear X86_FEATURE_APIC likewise. So I don't see easy way
to distinguish the reason why apic is disabled. But to be precise
APIC_init_uniprocessor print us some info.

So I'm for Ingo's idea!

|
| Rakib
| >
| > ? ? ? ?Ingo
| >
|
Cyrill