浏览代码

x86: make early_per_cpu() a lvalue and use it

Make early_per_cpu() a lvalue as per_cpu() is and use it where
applicable.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Tejun Heo 16 年之前
父节点
当前提交
f10fcd4712
共有 3 个文件被更改,包括 6 次插入18 次删除
  1. 3 3
      arch/x86/include/asm/percpu.h
  2. 1 4
      arch/x86/include/asm/topology.h
  3. 2 11
      arch/x86/kernel/apic.c

+ 3 - 3
arch/x86/include/asm/percpu.h

@@ -195,9 +195,9 @@ do {							\
 #define	early_per_cpu_ptr(_name) (_name##_early_ptr)
 #define	early_per_cpu_ptr(_name) (_name##_early_ptr)
 #define	early_per_cpu_map(_name, _idx) (_name##_early_map[_idx])
 #define	early_per_cpu_map(_name, _idx) (_name##_early_map[_idx])
 #define	early_per_cpu(_name, _cpu) 				\
 #define	early_per_cpu(_name, _cpu) 				\
-	(early_per_cpu_ptr(_name) ?				\
-		early_per_cpu_ptr(_name)[_cpu] :		\
-		per_cpu(_name, _cpu))
+	*(early_per_cpu_ptr(_name) ?				\
+		&early_per_cpu_ptr(_name)[_cpu] :		\
+		&per_cpu(_name, _cpu))
 
 
 #else	/* !CONFIG_SMP */
 #else	/* !CONFIG_SMP */
 #define	DEFINE_EARLY_PER_CPU(_type, _name, _initvalue)		\
 #define	DEFINE_EARLY_PER_CPU(_type, _name, _initvalue)		\

+ 1 - 4
arch/x86/include/asm/topology.h

@@ -102,10 +102,7 @@ static inline int cpu_to_node(int cpu)
 /* Same function but used if called before per_cpu areas are setup */
 /* Same function but used if called before per_cpu areas are setup */
 static inline int early_cpu_to_node(int cpu)
 static inline int early_cpu_to_node(int cpu)
 {
 {
-	if (early_per_cpu_ptr(x86_cpu_to_node_map))
-		return early_per_cpu_ptr(x86_cpu_to_node_map)[cpu];
-
-	return per_cpu(x86_cpu_to_node_map, cpu);
+	return early_per_cpu(x86_cpu_to_node_map, cpu);
 }
 }
 
 
 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */

+ 2 - 11
arch/x86/kernel/apic.c

@@ -1877,17 +1877,8 @@ void __cpuinit generic_processor_info(int apicid, int version)
 #endif
 #endif
 
 
 #if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64)
 #if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64)
-	/* are we being called early in kernel startup? */
-	if (early_per_cpu_ptr(x86_cpu_to_apicid)) {
-		u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
-		u16 *bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
-
-		cpu_to_apicid[cpu] = apicid;
-		bios_cpu_apicid[cpu] = apicid;
-	} else {
-		per_cpu(x86_cpu_to_apicid, cpu) = apicid;
-		per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
-	}
+	early_per_cpu(x86_cpu_to_apicid, cpu) = apicid;
+	early_per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
 #endif
 #endif
 
 
 	set_cpu_possible(cpu, true);
 	set_cpu_possible(cpu, true);