Skip to content

Commit 26ceef5

Browse files
NickJackolsonVasily Gorbik
authored andcommitted
s390/smp: Add cpu capacities
Linux scheduler allows architectures to assign capacity values to individual CPUs. This hints scheduler the performance difference between CPUs and allows more efficient task distribution them. Implement helper methods to set and get CPU capacities for s390. This is particularly helpful in vertical polarization configurations of LPARs. On vertical polarization an LPARs CPUs can get different polarization values depending on the CEC configuration. CPUs with different polarization values can perform different from each other, using CPU capacities this can be reflected to linux scheduler. Acked-by: Vasily Gorbik <[email protected]> Signed-off-by: Mete Durlu <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 7e627f8 commit 26ceef5

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

arch/s390/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct pcpu {
4444
unsigned long ec_mask; /* bit mask for ec_xxx functions */
4545
unsigned long ec_clk; /* sigp timestamp for ec_xxx */
4646
unsigned long flags; /* per CPU flags */
47+
unsigned long capacity; /* cpu capacity for scheduler */
4748
signed char state; /* physical cpu state */
4849
signed char polarization; /* physical polarization */
4950
u16 address; /* physical cpu address */

arch/s390/include/asm/smp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/processor.h>
1313

1414
#define raw_smp_processor_id() (get_lowcore()->cpu_nr)
15+
#define arch_scale_cpu_capacity smp_cpu_get_capacity
1516

1617
extern struct mutex smp_cpu_state_mutex;
1718
extern unsigned int smp_cpu_mt_shift;
@@ -34,6 +35,9 @@ extern void smp_save_dump_secondary_cpus(void);
3435
extern void smp_yield_cpu(int cpu);
3536
extern void smp_cpu_set_polarization(int cpu, int val);
3637
extern int smp_cpu_get_polarization(int cpu);
38+
extern void smp_cpu_set_capacity(int cpu, unsigned long val);
39+
extern void smp_set_core_capacity(int cpu, unsigned long val);
40+
extern unsigned long smp_cpu_get_capacity(int cpu);
3741
extern int smp_cpu_get_cpu_address(int cpu);
3842
extern void smp_fill_possible_mask(void);
3943
extern void smp_detect_cpus(void);

arch/s390/include/asm/topology.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ static inline void topology_expect_change(void) { }
6767
#define POLARIZATION_VM (2)
6868
#define POLARIZATION_VH (3)
6969

70+
#define CPU_CAPACITY_HIGH SCHED_CAPACITY_SCALE
71+
#define CPU_CAPACITY_LOW (SCHED_CAPACITY_SCALE >> 3)
72+
7073
#define SD_BOOK_INIT SD_CPU_INIT
7174

7275
#ifdef CONFIG_NUMA

arch/s390/kernel/smp.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,25 @@ int smp_cpu_get_polarization(int cpu)
671671
return per_cpu(pcpu_devices, cpu).polarization;
672672
}
673673

674+
void smp_cpu_set_capacity(int cpu, unsigned long val)
675+
{
676+
per_cpu(pcpu_devices, cpu).capacity = val;
677+
}
678+
679+
unsigned long smp_cpu_get_capacity(int cpu)
680+
{
681+
return per_cpu(pcpu_devices, cpu).capacity;
682+
}
683+
684+
void smp_set_core_capacity(int cpu, unsigned long val)
685+
{
686+
int i;
687+
688+
cpu = smp_get_base_cpu(cpu);
689+
for (i = cpu; (i <= cpu + smp_cpu_mtid) && (i < nr_cpu_ids); i++)
690+
smp_cpu_set_capacity(i, val);
691+
}
692+
674693
int smp_cpu_get_cpu_address(int cpu)
675694
{
676695
return per_cpu(pcpu_devices, cpu).address;
@@ -719,6 +738,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
719738
else
720739
pcpu->state = CPU_STATE_STANDBY;
721740
smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
741+
smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH);
722742
set_cpu_present(cpu, true);
723743
if (!early && arch_register_cpu(cpu))
724744
set_cpu_present(cpu, false);
@@ -961,6 +981,7 @@ void __init smp_prepare_boot_cpu(void)
961981
ipl_pcpu->state = CPU_STATE_CONFIGURED;
962982
lc->pcpu = (unsigned long)ipl_pcpu;
963983
smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN);
984+
smp_cpu_set_capacity(0, CPU_CAPACITY_HIGH);
964985
}
965986

966987
void __init smp_setup_processor_id(void)

0 commit comments

Comments
 (0)