LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Question about prefill_possible_map
Date: Fri, 27 Mar 2020 14:38:23 +0800
Message-ID: <687566a8-cacd-e0db-6914-d547853c7555@cn.fujitsu.com> (raw)

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



             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27  6:38 Cao jin [this message]
2020-04-08 12:07 ` Cao jin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=687566a8-cacd-e0db-6914-d547853c7555@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lkml.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lkml.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lkml.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lkml.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lkml.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lkml.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lkml.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lkml.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lkml.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lkml.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git