linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Winchester <kjwinchester@gmail.com>
To: hpa@zytor.com, Ingo Molnar <mingo@elte.hu>
Cc: Kevin Winchester <kjwinchester@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Nick Bowler <nbowler@elliptictech.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v6 5/5] x86: Remove #ifdef CONFIG_SMP sections by moving smp_num_siblings into common.c
Date: Sun, 29 Apr 2012 20:33:30 -0300	[thread overview]
Message-ID: <1335742410-11569-6-git-send-email-kjwinchester@gmail.com> (raw)
In-Reply-To: <1335742410-11569-1-git-send-email-kjwinchester@gmail.com>

smp_num_siblings was defined in arch/x86/kernel/smpboot.c, making it
necessary to wrap any UP relevant code referencing it with #ifdef
CONFIG_SMP.

Instead, move the definition to arch/x86/kernel/cpu/common.c, thus
making it available always.

Signed-off-by: Kevin Winchester <kjwinchester@gmail.com>
---
 arch/x86/include/asm/perf_event_p4.h |   14 +++-----------
 arch/x86/include/asm/smp.h           |    6 +-----
 arch/x86/include/asm/topology.h      |    4 +---
 arch/x86/kernel/cpu/amd.c            |    5 +----
 arch/x86/kernel/cpu/common.c         |    4 ++++
 arch/x86/kernel/cpu/perf_event_p4.c  |    4 ++--
 arch/x86/kernel/cpu/proc.c           |    5 ++---
 arch/x86/kernel/process.c            |    5 ++---
 arch/x86/kernel/smpboot.c            |    4 ----
 arch/x86/oprofile/nmi_int.c          |    6 ------
 arch/x86/oprofile/op_model_p4.c      |    6 ------
 11 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/arch/x86/include/asm/perf_event_p4.h b/arch/x86/include/asm/perf_event_p4.h
index 29a65c2..cfe41dc 100644
--- a/arch/x86/include/asm/perf_event_p4.h
+++ b/arch/x86/include/asm/perf_event_p4.h
@@ -8,6 +8,8 @@
 #include <linux/cpu.h>
 #include <linux/bitops.h>
 
+#include <asm/smp.h>
+
 /*
  * NetBurst has performance MSRs shared between
  * threads if HT is turned on, ie for both logical
@@ -177,20 +179,10 @@ static inline u64 p4_clear_ht_bit(u64 config)
 	return config & ~P4_CONFIG_HT;
 }
 
-static inline int p4_ht_active(void)
-{
-#ifdef CONFIG_SMP
-	return smp_num_siblings > 1;
-#endif
-	return 0;
-}
-
 static inline int p4_ht_thread(int cpu)
 {
-#ifdef CONFIG_SMP
 	if (smp_num_siblings == 2)
-		return cpu != cpumask_first(&cpu_data(cpu).sibling_map));
-#endif
+		return cpu != cpumask_first(&cpu_data(cpu).sibling_map);
 	return 0;
 }
 
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 408152e..8202cda 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -24,11 +24,7 @@ extern unsigned int num_processors;
 
 static inline bool cpu_has_ht_siblings(void)
 {
-	bool has_siblings = false;
-#ifdef CONFIG_SMP
-	has_siblings = cpu_has_ht && smp_num_siblings > 1;
-#endif
-	return has_siblings;
+	return cpu_has_ht && smp_num_siblings > 1;
 }
 
 DECLARE_PER_CPU(int, cpu_number);
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 5ffa396..1590480 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -174,11 +174,9 @@ static inline void arch_fix_phys_package_id(int num, u32 slot)
 struct pci_bus;
 void x86_pci_root_bus_resources(int bus, struct list_head *resources);
 
-#ifdef CONFIG_SMP
 #define mc_capable()	((boot_cpu_data.x86_max_cores > 1) && \
 			(cpumask_weight(cpu_core_mask(0)) != nr_cpu_ids))
-#define smt_capable()			(smp_num_siblings > 1)
-#endif
+#define smt_capable()	(smp_num_siblings > 1)
 
 #ifdef CONFIG_NUMA
 extern int get_mp_bus_to_node(int busnum);
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index d4c5ff4..2c92761 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -9,6 +9,7 @@
 #include <asm/processor.h>
 #include <asm/apic.h>
 #include <asm/cpu.h>
+#include <asm/smp.h>
 #include <asm/pci-direct.h>
 
 #ifdef CONFIG_X86_64
@@ -263,7 +264,6 @@ static int __cpuinit nearby_node(int apicid)
  *     Assumption: Number of cores in each internal node is the same.
  * (2) AMD processors supporting compute units
  */
-#ifdef CONFIG_X86_HT
 static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
 {
 	u32 nodes, cores_per_cu = 1;
@@ -307,7 +307,6 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
 		c->compute_unit_id %= cus_per_node;
 	}
 }
-#endif
 
 /*
  * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
@@ -315,7 +314,6 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
  */
 static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
 {
-#ifdef CONFIG_X86_HT
 	unsigned bits;
 
 	bits = c->x86_coreid_bits;
@@ -326,7 +324,6 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
 	/* use socket ID also for last level cache */
 	c->llc_id = c->phys_proc_id;
 	amd_get_topology(c);
-#endif
 }
 
 int amd_get_nb_id(int cpu)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4448984..f7a6589 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -49,6 +49,10 @@ cpumask_var_t cpu_initialized_mask;
 cpumask_var_t cpu_callout_mask;
 cpumask_var_t cpu_callin_mask;
 
+/* Number of siblings per CPU package */
+int smp_num_siblings = 1;
+EXPORT_SYMBOL(smp_num_siblings);
+
 /* representing cpus for which sibling maps can be computed */
 cpumask_var_t cpu_sibling_setup_mask;
 
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index a2dfacf..8bc2be2 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -775,7 +775,7 @@ static int p4_validate_raw_event(struct perf_event *event)
 	 * if an event is shared across the logical threads
 	 * the user needs special permissions to be able to use it
 	 */
-	if (p4_ht_active() && p4_event_bind_map[v].shared) {
+	if (smt_capable() && p4_event_bind_map[v].shared) {
 		if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
 			return -EACCES;
 	}
@@ -816,7 +816,7 @@ static int p4_hw_config(struct perf_event *event)
 	event->hw.config = p4_config_pack_escr(escr) |
 			   p4_config_pack_cccr(cccr);
 
-	if (p4_ht_active() && p4_ht_thread(cpu))
+	if (smt_capable() && p4_ht_thread(cpu))
 		event->hw.config = p4_set_ht_bit(event->hw.config);
 
 	if (event->attr.type == PERF_TYPE_RAW) {
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 8022c66..4fbaacb 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -1,16 +1,16 @@
-#include <linux/smp.h>
 #include <linux/timex.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
 #include <linux/cpufreq.h>
 
+#include <asm/smp.h>
+
 /*
  *	Get CPU information for use by the procfs.
  */
 static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
 			      unsigned int cpu)
 {
-#ifdef CONFIG_SMP
 	if (c->x86_max_cores * smp_num_siblings > 1) {
 		seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
 		seq_printf(m, "siblings\t: %d\n",
@@ -20,7 +20,6 @@ static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
 		seq_printf(m, "apicid\t\t: %d\n", c->apicid);
 		seq_printf(m, "initial apicid\t: %d\n", c->initial_apicid);
 	}
-#endif
 }
 
 #ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 1d92a5a..267535e 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -1,7 +1,6 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
-#include <linux/smp.h>
 #include <linux/prctl.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
@@ -19,6 +18,7 @@
 #include <linux/hw_breakpoint.h>
 #include <asm/cpu.h>
 #include <asm/apic.h>
+#include <asm/smp.h>
 #include <asm/syscalls.h>
 #include <asm/idle.h>
 #include <asm/uaccess.h>
@@ -676,12 +676,11 @@ static void amd_e400_idle(void)
 
 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
 {
-#ifdef CONFIG_SMP
 	if (pm_idle == poll_idle && smp_num_siblings > 1) {
 		printk_once(KERN_WARNING "WARNING: polling idle and HT enabled,"
 			" performance may degrade.\n");
 	}
-#endif
+
 	if (pm_idle)
 		return;
 
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 60729f4..ca85d4f 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -113,10 +113,6 @@ static struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
 #define set_idle_for_cpu(x, p)   (idle_thread_array[(x)] = (p))
 #endif
 
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
-EXPORT_SYMBOL(smp_num_siblings);
-
 /* Per CPU bogomips and other parameters */
 DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 26b8a85..346e7ac 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -572,11 +572,6 @@ static int __init p4_init(char **cpu_type)
 	if (cpu_model > 6 || cpu_model == 5)
 		return 0;
 
-#ifndef CONFIG_SMP
-	*cpu_type = "i386/p4";
-	model = &op_p4_spec;
-	return 1;
-#else
 	switch (smp_num_siblings) {
 	case 1:
 		*cpu_type = "i386/p4";
@@ -588,7 +583,6 @@ static int __init p4_init(char **cpu_type)
 		model = &op_p4_ht2_spec;
 		return 1;
 	}
-#endif
 
 	printk(KERN_INFO "oprofile: P4 HyperThreading detected with > 2 threads\n");
 	printk(KERN_INFO "oprofile: Reverting to timer mode.\n");
diff --git a/arch/x86/oprofile/op_model_p4.c b/arch/x86/oprofile/op_model_p4.c
index ae3503e..c6bcb22 100644
--- a/arch/x86/oprofile/op_model_p4.c
+++ b/arch/x86/oprofile/op_model_p4.c
@@ -42,21 +42,15 @@ static unsigned int num_controls = NUM_CONTROLS_NON_HT;
    kernel boot-time. */
 static inline void setup_num_counters(void)
 {
-#ifdef CONFIG_SMP
 	if (smp_num_siblings == 2) {
 		num_counters = NUM_COUNTERS_HT2;
 		num_controls = NUM_CONTROLS_HT2;
 	}
-#endif
 }
 
 static inline int addr_increment(void)
 {
-#ifdef CONFIG_SMP
 	return smp_num_siblings == 2 ? 2 : 1;
-#else
-	return 1;
-#endif
 }
 
 
-- 
1.7.10


      parent reply	other threads:[~2012-04-29 23:34 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23 23:57 [PATCH v4 0/5] x86: Cleanup and simplify cpu-specific data Kevin Winchester
2012-02-23 23:57 ` [PATCH v4 1/5] x86: Move per cpu cpu_llc_shared_map to a field in struct cpuinfo_x86 Kevin Winchester
2012-02-23 23:57 ` [PATCH v4 2/5] x86: Move per cpu cpu_llc_id " Kevin Winchester
2012-02-23 23:57 ` [PATCH v4 3/5] x86: Move per cpu cpu_sibling_map " Kevin Winchester
2012-02-23 23:57 ` [PATCH v4 4/5] x86: Move per cpu cpu_core_map " Kevin Winchester
2012-02-23 23:57 ` [PATCH v4 5/5] x86: Remove #ifdef CONFIG_SMP sections by moving smp_num_siblings into common.c Kevin Winchester
2012-02-24 11:47 ` [PATCH v4 0/5] x86: Cleanup and simplify cpu-specific data Borislav Petkov
2012-02-24 12:22   ` Kevin Winchester
2012-02-24 12:30     ` Borislav Petkov
2012-02-27 11:59 ` Ingo Molnar
2012-02-28  0:52   ` Kevin Winchester
2012-02-28  3:43     ` H. Peter Anvin
2012-02-28  8:24       ` Ingo Molnar
2012-02-28  8:31         ` H. Peter Anvin
2012-03-01 13:06           ` Kevin Winchester
2012-03-01 13:45             ` Ingo Molnar
2012-03-28 22:43   ` [PATCH v5 " Kevin Winchester
2012-03-28 22:43     ` [PATCH v5 1/5] x86: Move per cpu cpu_llc_shared_map to a field in struct cpuinfo_x86 Kevin Winchester
2012-03-28 22:43     ` [PATCH v5 2/5] x86: Move per cpu cpu_llc_id " Kevin Winchester
2012-03-28 22:43     ` [PATCH v5 3/5] x86: Move per cpu cpu_sibling_map " Kevin Winchester
2012-03-28 22:43     ` [PATCH v5 4/5] x86: Move per cpu cpu_core_map " Kevin Winchester
2012-03-28 22:43     ` [PATCH v5 5/5] x86: Remove #ifdef CONFIG_SMP sections by moving smp_num_siblings into common.c Kevin Winchester
2012-04-26 18:09     ` [PATCH v5 0/5] x86: Cleanup and simplify cpu-specific data Kevin Winchester
2012-04-26 19:48     ` H. Peter Anvin
     [not found]       ` <CAELBVzAi_yndZbDc0TkXhbqzn2wULpnsFMA_dop=Uvaii8tkqg@mail.gmail.com>
2012-04-26 21:21         ` H. Peter Anvin
2012-04-27 23:37           ` Kevin Winchester
2012-04-29 12:47             ` Borislav Petkov
2012-04-29 22:55               ` Kevin Winchester
2012-04-29 23:33           ` [PATCH v6 " Kevin Winchester
2012-04-29 23:33             ` [PATCH v6 1/5] x86: Move per cpu cpu_llc_shared_map to a field in struct cpuinfo_x86 Kevin Winchester
2012-04-29 23:37               ` H. Peter Anvin
2012-04-30 15:05                 ` Kevin Winchester
2012-05-07  8:32                   ` Ingo Molnar
2012-04-29 23:33             ` [PATCH v6 2/5] x86: Move per cpu cpu_llc_id " Kevin Winchester
2012-04-29 23:33             ` [PATCH v6 3/5] x86: Move per cpu cpu_sibling_map " Kevin Winchester
2012-04-29 23:33             ` [PATCH v6 4/5] x86: Move per cpu cpu_core_map " Kevin Winchester
2012-04-29 23:33             ` Kevin Winchester [this message]

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=1335742410-11569-6-git-send-email-kjwinchester@gmail.com \
    --to=kjwinchester@gmail.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nbowler@elliptictech.com \
    --cc=rdunlap@xenotime.net \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).