提交 50ab9a9a 编写于 作者: H Heiko Carstens 提交者: Martin Schwidefsky

s390/smp,topology: add polarization member to pcpu struct

The cpu polarization member is the only per cpu state that is not part
of the pcpu structure. So add it there and have everything in one place.
Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 fade4dc4
...@@ -30,6 +30,8 @@ extern int smp_vcpu_scheduled(int cpu); ...@@ -30,6 +30,8 @@ extern int smp_vcpu_scheduled(int cpu);
extern void smp_yield_cpu(int cpu); extern void smp_yield_cpu(int cpu);
extern void smp_yield(void); extern void smp_yield(void);
extern void smp_stop_cpu(void); extern void smp_stop_cpu(void);
extern void smp_cpu_set_polarization(int cpu, int val);
extern int smp_cpu_get_polarization(int cpu);
#else /* CONFIG_SMP */ #else /* CONFIG_SMP */
......
...@@ -51,24 +51,6 @@ static inline void topology_expect_change(void) { } ...@@ -51,24 +51,6 @@ static inline void topology_expect_change(void) { }
#define POLARIZATION_VM (2) #define POLARIZATION_VM (2)
#define POLARIZATION_VH (3) #define POLARIZATION_VH (3)
extern int cpu_polarization[];
static inline void cpu_set_polarization(int cpu, int val)
{
#ifdef CONFIG_SCHED_BOOK
cpu_polarization[cpu] = val;
#endif
}
static inline int cpu_read_polarization(int cpu)
{
#ifdef CONFIG_SCHED_BOOK
return cpu_polarization[cpu];
#else
return POLARIZATION_HRZ;
#endif
}
#ifdef CONFIG_SCHED_BOOK #ifdef CONFIG_SCHED_BOOK
void s390_init_cpu_topology(void); void s390_init_cpu_topology(void);
#else #else
......
...@@ -66,6 +66,7 @@ struct pcpu { ...@@ -66,6 +66,7 @@ struct pcpu {
unsigned long panic_stack; /* panic stack for the cpu */ unsigned long panic_stack; /* panic stack for the cpu */
unsigned long ec_mask; /* bit mask for ec_xxx functions */ unsigned long ec_mask; /* bit mask for ec_xxx functions */
int state; /* physical cpu state */ int state; /* physical cpu state */
int polarization; /* physical polarization */
u16 address; /* physical cpu address */ u16 address; /* physical cpu address */
}; };
...@@ -73,6 +74,10 @@ static u8 boot_cpu_type; ...@@ -73,6 +74,10 @@ static u8 boot_cpu_type;
static u16 boot_cpu_address; static u16 boot_cpu_address;
static struct pcpu pcpu_devices[NR_CPUS]; static struct pcpu pcpu_devices[NR_CPUS];
/*
* The smp_cpu_state_mutex must be held when changing the state or polarization
* member of a pcpu data structure within the pcpu_devices arreay.
*/
DEFINE_MUTEX(smp_cpu_state_mutex); DEFINE_MUTEX(smp_cpu_state_mutex);
/* /*
...@@ -587,6 +592,16 @@ static inline void smp_get_save_area(int cpu, u16 address) { } ...@@ -587,6 +592,16 @@ static inline void smp_get_save_area(int cpu, u16 address) { }
#endif /* CONFIG_ZFCPDUMP || CONFIG_CRASH_DUMP */ #endif /* CONFIG_ZFCPDUMP || CONFIG_CRASH_DUMP */
void smp_cpu_set_polarization(int cpu, int val)
{
pcpu_devices[cpu].polarization = val;
}
int smp_cpu_get_polarization(int cpu)
{
return pcpu_devices[cpu].polarization;
}
static struct sclp_cpu_info *smp_get_cpu_info(void) static struct sclp_cpu_info *smp_get_cpu_info(void)
{ {
static int use_sigp_detection; static int use_sigp_detection;
...@@ -629,7 +644,7 @@ static int __devinit __smp_rescan_cpus(struct sclp_cpu_info *info, ...@@ -629,7 +644,7 @@ static int __devinit __smp_rescan_cpus(struct sclp_cpu_info *info,
pcpu->address = info->cpu[i].address; pcpu->address = info->cpu[i].address;
pcpu->state = (cpu >= info->configured) ? pcpu->state = (cpu >= info->configured) ?
CPU_STATE_STANDBY : CPU_STATE_CONFIGURED; CPU_STATE_STANDBY : CPU_STATE_CONFIGURED;
cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
set_cpu_present(cpu, true); set_cpu_present(cpu, true);
if (sysfs_add && smp_add_present_cpu(cpu) != 0) if (sysfs_add && smp_add_present_cpu(cpu) != 0)
set_cpu_present(cpu, false); set_cpu_present(cpu, false);
...@@ -797,7 +812,7 @@ void __init smp_prepare_boot_cpu(void) ...@@ -797,7 +812,7 @@ void __init smp_prepare_boot_cpu(void)
pcpu->async_stack = S390_lowcore.async_stack - ASYNC_SIZE; pcpu->async_stack = S390_lowcore.async_stack - ASYNC_SIZE;
pcpu->panic_stack = S390_lowcore.panic_stack - PAGE_SIZE; pcpu->panic_stack = S390_lowcore.panic_stack - PAGE_SIZE;
S390_lowcore.percpu_offset = __per_cpu_offset[0]; S390_lowcore.percpu_offset = __per_cpu_offset[0];
cpu_set_polarization(0, POLARIZATION_UNKNOWN); smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN);
set_cpu_present(0, true); set_cpu_present(0, true);
set_cpu_online(0, true); set_cpu_online(0, true);
} }
...@@ -863,7 +878,7 @@ static ssize_t cpu_configure_store(struct device *dev, ...@@ -863,7 +878,7 @@ static ssize_t cpu_configure_store(struct device *dev,
if (rc) if (rc)
break; break;
pcpu->state = CPU_STATE_STANDBY; pcpu->state = CPU_STATE_STANDBY;
cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
topology_expect_change(); topology_expect_change();
break; break;
case 1: case 1:
...@@ -873,7 +888,7 @@ static ssize_t cpu_configure_store(struct device *dev, ...@@ -873,7 +888,7 @@ static ssize_t cpu_configure_store(struct device *dev,
if (rc) if (rc)
break; break;
pcpu->state = CPU_STATE_CONFIGURED; pcpu->state = CPU_STATE_CONFIGURED;
cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
topology_expect_change(); topology_expect_change();
break; break;
default: default:
......
...@@ -45,9 +45,6 @@ static struct mask_info book_info; ...@@ -45,9 +45,6 @@ static struct mask_info book_info;
cpumask_t cpu_book_map[NR_CPUS]; cpumask_t cpu_book_map[NR_CPUS];
unsigned char cpu_book_id[NR_CPUS]; unsigned char cpu_book_id[NR_CPUS];
/* smp_cpu_state_mutex must be held when accessing this array */
int cpu_polarization[NR_CPUS];
static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu) static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
{ {
cpumask_t mask; cpumask_t mask;
...@@ -95,7 +92,7 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu, ...@@ -95,7 +92,7 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
} else { } else {
cpu_core_id[lcpu] = core->id; cpu_core_id[lcpu] = core->id;
} }
cpu_set_polarization(lcpu, tl_cpu->pp); smp_cpu_set_polarization(lcpu, tl_cpu->pp);
} }
} }
return core; return core;
...@@ -202,7 +199,7 @@ static void topology_update_polarization_simple(void) ...@@ -202,7 +199,7 @@ static void topology_update_polarization_simple(void)
mutex_lock(&smp_cpu_state_mutex); mutex_lock(&smp_cpu_state_mutex);
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
cpu_set_polarization(cpu, POLARIZATION_HRZ); smp_cpu_set_polarization(cpu, POLARIZATION_HRZ);
mutex_unlock(&smp_cpu_state_mutex); mutex_unlock(&smp_cpu_state_mutex);
} }
...@@ -232,7 +229,7 @@ int topology_set_cpu_management(int fc) ...@@ -232,7 +229,7 @@ int topology_set_cpu_management(int fc)
if (rc) if (rc)
return -EBUSY; return -EBUSY;
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
return rc; return rc;
} }
...@@ -414,7 +411,7 @@ static ssize_t cpu_polarization_show(struct device *dev, ...@@ -414,7 +411,7 @@ static ssize_t cpu_polarization_show(struct device *dev,
ssize_t count; ssize_t count;
mutex_lock(&smp_cpu_state_mutex); mutex_lock(&smp_cpu_state_mutex);
switch (cpu_read_polarization(cpu)) { switch (smp_cpu_get_polarization(cpu)) {
case POLARIZATION_HRZ: case POLARIZATION_HRZ:
count = sprintf(buf, "horizontal\n"); count = sprintf(buf, "horizontal\n");
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册