mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: yhlu <yhlu.kernel@gmail.com>
To: Andi Kleen <ak@suse.de>
Cc: discuss@x86-64.org, linux-kernel@vger.kernel.org, linuxbios@openbios.org
Subject: x86_64: apic id lift patch
Date: Mon, 21 Nov 2005 13:49:09 -0800	[thread overview]
Message-ID: <86802c440511211349t6a0a9d30i60e15fa23b86c49d@mail.gmail.com> (raw)

Andi,

Please check the patch regarding apicid lifting.

For some reason, we need to lift AP apicid but keep the BSP apicid to 0....

Also it solve the E0 later single but have apic id reorder problem...

YH


diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -786,13 +786,24 @@ static void __init amd_detect_cmp(struct
 #ifdef CONFIG_SMP
 	int cpu = smp_processor_id();
 	unsigned bits;
+	int cores_vir;
 #ifdef CONFIG_NUMA
 	int node = 0;
-	unsigned apicid = phys_proc_id[cpu];
+	unsigned initial_apicid = phys_proc_id[cpu];
+	unsigned apicid = hard_smp_processor_id();
 #endif
+	
+	cores_vir = c->x86_max_cores;
+	if(cores_vir == 1) {
+		unsigned level = cpuid_eax(1);
+		/* double check if it is E0 later, only E0 later can reorder apicid
for single core */
+        	if ((level & 0xf0f00) >= 0x20f00) {
+			cores_vir = 2;
+		}
+	}

 	bits = 0;
-	while ((1 << bits) < c->x86_max_cores)
+	while ((1 << bits) < cores_vir)
 		bits++;

 	/* Low order bits define the core id (index of core in socket) */
@@ -802,32 +813,23 @@ static void __init amd_detect_cmp(struct

 #ifdef CONFIG_NUMA
   	node = phys_proc_id[cpu];
- 	if (apicid_to_node[apicid] != NUMA_NO_NODE)
- 		node = apicid_to_node[apicid];
+
+ 	if (apicid_to_node[apicid] == NUMA_NO_NODE)
+ 		apicid_to_node[apicid] = node;
+	
  	if (!node_online(node)) {
- 		/* Two possibilities here:
+ 		/* One possibilities here:
  		   - The CPU is missing memory and no node was created.
- 		   In that case try picking one from a nearby CPU
- 		   - The APIC IDs differ from the HyperTransport node IDs
- 		   which the K8 northbridge parsing fills in.
- 		   Assume they are all increased by a constant offset,
- 		   but in the same order as the HT nodeids.
- 		   If that doesn't result in a usable node fall back to the
- 		   path for the previous case.  */
- 		int ht_nodeid = apicid - (phys_proc_id[0] << bits);
- 		if (ht_nodeid >= 0 &&
- 		    apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
- 			node = apicid_to_node[ht_nodeid];
- 		/* Pick a nearby node */
- 		if (!node_online(node))
- 			node = nearby_node(apicid);
+ 		   In that case try picking one from a nearby CPU */
+ 		node = nearby_node(apicid);
  	}
+
 	numa_set_node(cpu, node);
+#endif

   	printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
   			cpu, c->x86_max_cores, node, cpu_core_id[cpu]);
 #endif
-#endif
 }

 static int __init init_amd(struct cpuinfo_x86 *c)

             reply	other threads:[~2005-11-21 21:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-21 21:49 yhlu [this message]
2005-11-21 22:06 ` Andi Kleen
2005-11-21 22:17   ` yhlu
2005-11-21 22:24     ` Andi Kleen
2005-11-21 22:31       ` yhlu
2005-11-22  9:44         ` Andi Kleen
2005-11-23 16:58   ` [LinuxBIOS] " Ronald G Minnich
2005-11-23 17:35     ` Andi Kleen
     [not found]       ` <2ea3fae10511230943y5f697eb8sdbf891497fa8b88f@mail.gmail.com>
2005-11-23 17:50         ` Andi Kleen
2005-11-23 18:01           ` yhlu
2005-11-23 20:29             ` [discuss] " Andi Kleen
2005-11-23 20:29               ` Ronald G Minnich
2005-11-23 18:28       ` Stefan Reinauer
2005-11-23 20:26       ` Ronald G Minnich
     [not found]     ` <2ea3fae10511230919l4d9829d8j3ce5d820b74074d1@mail.gmail.com>
2005-11-23 17:36       ` Andi Kleen
2005-11-23 17:40         ` yhlu
2005-11-23 18:18           ` Stefan Reinauer
2005-11-23 18:22             ` yhlu
2005-11-23 18:35               ` yhlu
2005-11-23 20:28                 ` [discuss] " Andi Kleen
2005-11-23 18:17         ` Stefan Reinauer
2005-11-23 20:23       ` Ronald G Minnich
2005-11-23 20:34         ` [discuss] " Andi Kleen

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=86802c440511211349t6a0a9d30i60e15fa23b86c49d@mail.gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxbios@openbios.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

all inboxes | Powered by JetHome®