All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about prefill_possible_map
@ 2020-03-27  6:38 Cao jin
  2020-04-08 12:07 ` Cao jin
  0 siblings, 1 reply; 2+ messages in thread
From: Cao jin @ 2020-03-27  6:38 UTC (permalink / raw)
  To: X86 ML, LKML
  Cc: Thomas Gleixner, Borislav Petkov, Ingo Molnar, H. Peter Anvin

Hi,

At the beginning of this function, there is:

    /* No boot processor was found in mptable or ACPI MADT */
    if (!num_processors) {
        if (boot_cpu_has(X86_FEATURE_APIC)) {
            int apicid = boot_cpu_physical_apicid;
            int cpu = hard_smp_processor_id();

            pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu);

            /* Make sure boot cpu is enumerated */
            if (apic->cpu_present_to_apicid(0) == BAD_APICID &&
                apic->apic_id_valid(apicid))
                generic_processor_info(apicid, boot_cpu_apic_version);
        }

        if (!num_processors)
            num_processors = 1;
    }

I see 3 cases will go through this code chunk,

1. UP, has no APCI MADT & MP table, but has APIC
2. 2a51fe083eba7f: kdump kernel running on the hot-plugged CPU
3. normal UP(No table, no APIC)

And "if (boot_cpu_has(X86_FEATURE_APIC))" covers case 1 & 2 to my
understanding.

But both cases 1 & 2 already have boot_cpu_physical_apicid initialized
from APIC ID register:
1. init_apic_mappings --> register_lapic_address
2. early_acpi_boot_init --> early_acpi_process_madt -->...-->
   register_lapic_address

So my question is: is variable "cpu" redundant? Could it be:

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 69881b2d446c..99fc03511568 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1456,9 +1456,9 @@ __init void prefill_possible_map(void)
        if (!num_processors) {
                if (boot_cpu_has(X86_FEATURE_APIC)) {
                        int apicid = boot_cpu_physical_apicid;
-                       int cpu = hard_smp_processor_id();

-                       pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu);
+                       pr_warn("Boot CPU (id %d) not listed by BIOS\n", \
+                                boot_cpu_physical_apicid);

                        /* Make sure boot cpu is enumerated */
                        if (apic->cpu_present_to_apicid(0) == BAD_APICID &&

-- 
Sincerely,
Cao jin



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Question about prefill_possible_map
  2020-03-27  6:38 Question about prefill_possible_map Cao jin
@ 2020-04-08 12:07 ` Cao jin
  0 siblings, 0 replies; 2+ messages in thread
From: Cao jin @ 2020-04-08 12:07 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: X86 ML, LKML, Borislav Petkov, Ingo Molnar, H. Peter Anvin

Hi Thomas,

  Seems you helped improve 2a51fe083eba7f, could you help with this question?

-- 
Sincerely,
Cao jin

On 3/27/20 2:38 PM, Cao jin wrote:
> Hi,
> 
> At the beginning of this function, there is:
> 
>     /* No boot processor was found in mptable or ACPI MADT */
>     if (!num_processors) {
>         if (boot_cpu_has(X86_FEATURE_APIC)) {
>             int apicid = boot_cpu_physical_apicid;
>             int cpu = hard_smp_processor_id();
> 
>             pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu);
> 
>             /* Make sure boot cpu is enumerated */
>             if (apic->cpu_present_to_apicid(0) == BAD_APICID &&
>                 apic->apic_id_valid(apicid))
>                 generic_processor_info(apicid, boot_cpu_apic_version);
>         }
> 
>         if (!num_processors)
>             num_processors = 1;
>     }
> 
> I see 3 cases will go through this code chunk,
> 
> 1. UP, has no APCI MADT & MP table, but has APIC
> 2. 2a51fe083eba7f: kdump kernel running on the hot-plugged CPU
> 3. normal UP(No table, no APIC)
> 
> And "if (boot_cpu_has(X86_FEATURE_APIC))" covers case 1 & 2 to my
> understanding.
> 
> But both cases 1 & 2 already have boot_cpu_physical_apicid initialized
> from APIC ID register:
> 1. init_apic_mappings --> register_lapic_address
> 2. early_acpi_boot_init --> early_acpi_process_madt -->...-->
>    register_lapic_address
> 
> So my question is: is variable "cpu" redundant? Could it be:
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 69881b2d446c..99fc03511568 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -1456,9 +1456,9 @@ __init void prefill_possible_map(void)
>         if (!num_processors) {
>                 if (boot_cpu_has(X86_FEATURE_APIC)) {
>                         int apicid = boot_cpu_physical_apicid;
> -                       int cpu = hard_smp_processor_id();
> 
> -                       pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu);
> +                       pr_warn("Boot CPU (id %d) not listed by BIOS\n", \
> +                                boot_cpu_physical_apicid);
> 
>                         /* Make sure boot cpu is enumerated */
>                         if (apic->cpu_present_to_apicid(0) == BAD_APICID &&
> 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-08 12:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27  6:38 Question about prefill_possible_map Cao jin
2020-04-08 12:07 ` Cao jin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.