From: Alex Chiang <achiang@hp.com>
To: hpa@zytor.com, mingo@redhat.com, tglx@linutronix.de
Cc: andi@firstfloor.org, x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86: add /proc/cpuinfo/physical id quirks
Date: Fri, 14 Aug 2009 10:36:18 -0600 [thread overview]
Message-ID: <20090814163618.GQ7185@ldl.fc.hp.com> (raw)
As systems become larger and more complex, it is not always possible
to assume that an APIC ID maps directly to a given physical slot.
>From a UI point-of-view, it's nice if the 'physical id' field in
/proc/cpuinfo matches the silk-screening or labelling on the system
chassis.
Add a quirk that allows oddball platforms to ensure that what the kernel
displays in /proc/cpuinfo matches the physical reality.
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Alex Chiang <achiang@hp.com>
---
Makefile | 2 +-
common.c | 5 +++++
cpu.h | 8 ++++++++
physid_quirks.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 1 deletion(-)
---
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 3efcb2b..95d54cf 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -9,7 +9,7 @@ endif
obj-y := intel_cacheinfo.o addon_cpuid_features.o
obj-y += proc.o capflags.o powerflags.o common.o
-obj-y += vmware.o hypervisor.o
+obj-y += vmware.o hypervisor.o physid_quirks.o
obj-$(CONFIG_X86_32) += bugs.o cmpxchg.o
obj-$(CONFIG_X86_64) += bugs_64.o
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 54a3ead..714c56f 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -815,6 +815,11 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
detect_ht(c);
#endif
+ physid_fixup_table = NULL;
+ dmi_check_system(physid_need_fixups_table);
+ if (physid_fixup_table)
+ c->phys_proc_id = physid_fixup_table[c->phys_proc_id];
+
init_hypervisor(c);
/*
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index 6de9a90..5ae221e 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -8,6 +8,8 @@ struct cpu_model_info {
const char *model_names[16];
};
+struct cpuinfo_x86;
+
/* attempt to consolidate cpu attributes */
struct cpu_dev {
const char *c_vendor;
@@ -34,4 +36,10 @@ extern const struct cpu_dev *const __x86_cpu_dev_start[],
extern void display_cacheinfo(struct cpuinfo_x86 *c);
+/* defined in physid_quirks.c */
+#include <linux/dmi.h>
+extern int (*physid_fixup_table);
+extern int hp_check_fixup_physids(const struct dmi_system_id *);
+extern struct dmi_system_id physid_need_fixups_table[];
+
#endif
diff --git a/arch/x86/kernel/cpu/physid_quirks.c b/arch/x86/kernel/cpu/physid_quirks.c
new file mode 100644
index 0000000..40cf429
--- /dev/null
+++ b/arch/x86/kernel/cpu/physid_quirks.c
@@ -0,0 +1,54 @@
+/*
+ * physid_quirks.c - quirks for the 'physical id' field in /proc/cpuinfo
+ *
+ * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ * Alex Chiang <achiang@hp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "cpu.h"
+
+int (*physid_fixup_table);
+
+struct dmi_system_id __initdata physid_need_fixups_table[] = {
+ {
+ .callback = hp_check_fixup_physids,
+ .ident = "HP ProLiant DL785 G5/G6",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL785"),
+ },
+ },
+ {}
+};
+
+/*
+ * The mapping from node to physical socket id is described
+ * in the (HP internal) DL785 system specification.
+ */
+static int hp_dl785_physids_4p[8] = { 8, 2, 7, 1, 0, 0, 0, 0 };
+static int hp_dl785_physids_8p[8] = { 8, 6, 7, 4, 3, 5, 2, 1 };
+int __cpuinit hp_check_fixup_physids(const struct dmi_system_id *d)
+{
+ int present = num_present_cpus();
+
+ /* DL785 only supports 4-socket and 8-socket configs */
+ if (present == 16 || present == 24)
+ physid_fixup_table = hp_dl785_physids_4p;
+ else
+ physid_fixup_table = hp_dl785_physids_8p;
+
+ return 1;
+}
next reply other threads:[~2009-08-14 16:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-14 16:36 Alex Chiang [this message]
2009-08-14 19:07 ` [PATCH] x86: add /proc/cpuinfo/physical id quirks Suresh Siddha
2009-08-14 19:27 ` Alex Chiang
2009-08-14 19:56 ` Suresh Siddha
2009-08-19 21:02 ` Alex Chiang
2009-08-20 18:56 ` Suresh Siddha
2009-08-20 20:54 ` Alex Chiang
2009-08-20 21:03 ` Andi Kleen
2009-08-20 21:20 ` Alex Chiang
2009-08-20 21:26 ` Suresh Siddha
2009-08-20 21:42 ` H. Peter Anvin
2009-08-20 21:59 ` Alex Chiang
2009-08-20 22:04 ` H. Peter Anvin
2009-08-21 0:32 ` Andi Kleen
2009-08-21 1:51 ` H. Peter Anvin
2009-08-21 5:02 ` Alex Chiang
2009-08-20 21:22 ` Suresh Siddha
2009-08-21 0:38 ` Andi Kleen
2009-08-20 21:11 ` Suresh Siddha
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=20090814163618.GQ7185@ldl.fc.hp.com \
--to=achiang@hp.com \
--cc=andi@firstfloor.org \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox