diff options
Diffstat (limited to 'arch/s390/kernel/topology.c')
-rw-r--r-- | arch/s390/kernel/topology.c | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index b93bed76ea94..24ee33f1af24 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c | |||
@@ -59,32 +59,50 @@ static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu) | |||
59 | return mask; | 59 | return mask; |
60 | } | 60 | } |
61 | 61 | ||
62 | static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu, | 62 | static cpumask_t cpu_thread_map(unsigned int cpu) |
63 | { | ||
64 | cpumask_t mask; | ||
65 | int i; | ||
66 | |||
67 | cpumask_copy(&mask, cpumask_of(cpu)); | ||
68 | if (!topology_enabled || !MACHINE_HAS_TOPOLOGY) | ||
69 | return mask; | ||
70 | cpu -= cpu % (smp_cpu_mtid + 1); | ||
71 | for (i = 0; i <= smp_cpu_mtid; i++) | ||
72 | if (cpu_present(cpu + i)) | ||
73 | cpumask_set_cpu(cpu + i, &mask); | ||
74 | return mask; | ||
75 | } | ||
76 | |||
77 | static struct mask_info *add_cpus_to_mask(struct topology_core *tl_core, | ||
63 | struct mask_info *book, | 78 | struct mask_info *book, |
64 | struct mask_info *socket, | 79 | struct mask_info *socket, |
65 | int one_socket_per_cpu) | 80 | int one_socket_per_cpu) |
66 | { | 81 | { |
67 | unsigned int cpu; | 82 | unsigned int core; |
68 | 83 | ||
69 | for_each_set_bit(cpu, &tl_cpu->mask[0], TOPOLOGY_CPU_BITS) { | 84 | for_each_set_bit(core, &tl_core->mask[0], TOPOLOGY_CORE_BITS) { |
70 | unsigned int rcpu; | 85 | unsigned int rcore; |
71 | int lcpu; | 86 | int lcpu, i; |
72 | 87 | ||
73 | rcpu = TOPOLOGY_CPU_BITS - 1 - cpu + tl_cpu->origin; | 88 | rcore = TOPOLOGY_CORE_BITS - 1 - core + tl_core->origin; |
74 | lcpu = smp_find_processor_id(rcpu); | 89 | lcpu = smp_find_processor_id(rcore << smp_cpu_mt_shift); |
75 | if (lcpu < 0) | 90 | if (lcpu < 0) |
76 | continue; | 91 | continue; |
77 | cpumask_set_cpu(lcpu, &book->mask); | 92 | for (i = 0; i <= smp_cpu_mtid; i++) { |
78 | cpu_topology[lcpu].book_id = book->id; | 93 | cpu_topology[lcpu + i].book_id = book->id; |
79 | cpumask_set_cpu(lcpu, &socket->mask); | 94 | cpu_topology[lcpu + i].core_id = rcore; |
80 | cpu_topology[lcpu].core_id = rcpu; | 95 | cpu_topology[lcpu + i].thread_id = lcpu + i; |
81 | if (one_socket_per_cpu) { | 96 | cpumask_set_cpu(lcpu + i, &book->mask); |
82 | cpu_topology[lcpu].socket_id = rcpu; | 97 | cpumask_set_cpu(lcpu + i, &socket->mask); |
83 | socket = socket->next; | 98 | if (one_socket_per_cpu) |
84 | } else { | 99 | cpu_topology[lcpu + i].socket_id = rcore; |
85 | cpu_topology[lcpu].socket_id = socket->id; | 100 | else |
101 | cpu_topology[lcpu + i].socket_id = socket->id; | ||
102 | smp_cpu_set_polarization(lcpu + i, tl_core->pp); | ||
86 | } | 103 | } |
87 | smp_cpu_set_polarization(lcpu, tl_cpu->pp); | 104 | if (one_socket_per_cpu) |
105 | socket = socket->next; | ||
88 | } | 106 | } |
89 | return socket; | 107 | return socket; |
90 | } | 108 | } |
@@ -108,7 +126,7 @@ static void clear_masks(void) | |||
108 | static union topology_entry *next_tle(union topology_entry *tle) | 126 | static union topology_entry *next_tle(union topology_entry *tle) |
109 | { | 127 | { |
110 | if (!tle->nl) | 128 | if (!tle->nl) |
111 | return (union topology_entry *)((struct topology_cpu *)tle + 1); | 129 | return (union topology_entry *)((struct topology_core *)tle + 1); |
112 | return (union topology_entry *)((struct topology_container *)tle + 1); | 130 | return (union topology_entry *)((struct topology_container *)tle + 1); |
113 | } | 131 | } |
114 | 132 | ||
@@ -231,9 +249,11 @@ static void update_cpu_masks(void) | |||
231 | 249 | ||
232 | spin_lock_irqsave(&topology_lock, flags); | 250 | spin_lock_irqsave(&topology_lock, flags); |
233 | for_each_possible_cpu(cpu) { | 251 | for_each_possible_cpu(cpu) { |
252 | cpu_topology[cpu].thread_mask = cpu_thread_map(cpu); | ||
234 | cpu_topology[cpu].core_mask = cpu_group_map(&socket_info, cpu); | 253 | cpu_topology[cpu].core_mask = cpu_group_map(&socket_info, cpu); |
235 | cpu_topology[cpu].book_mask = cpu_group_map(&book_info, cpu); | 254 | cpu_topology[cpu].book_mask = cpu_group_map(&book_info, cpu); |
236 | if (!MACHINE_HAS_TOPOLOGY) { | 255 | if (!MACHINE_HAS_TOPOLOGY) { |
256 | cpu_topology[cpu].thread_id = cpu; | ||
237 | cpu_topology[cpu].core_id = cpu; | 257 | cpu_topology[cpu].core_id = cpu; |
238 | cpu_topology[cpu].socket_id = cpu; | 258 | cpu_topology[cpu].socket_id = cpu; |
239 | cpu_topology[cpu].book_id = cpu; | 259 | cpu_topology[cpu].book_id = cpu; |
@@ -445,6 +465,12 @@ int topology_cpu_init(struct cpu *cpu) | |||
445 | return sysfs_create_group(&cpu->dev.kobj, &topology_cpu_attr_group); | 465 | return sysfs_create_group(&cpu->dev.kobj, &topology_cpu_attr_group); |
446 | } | 466 | } |
447 | 467 | ||
468 | const struct cpumask *cpu_thread_mask(int cpu) | ||
469 | { | ||
470 | return &cpu_topology[cpu].thread_mask; | ||
471 | } | ||
472 | |||
473 | |||
448 | const struct cpumask *cpu_coregroup_mask(int cpu) | 474 | const struct cpumask *cpu_coregroup_mask(int cpu) |
449 | { | 475 | { |
450 | return &cpu_topology[cpu].core_mask; | 476 | return &cpu_topology[cpu].core_mask; |
@@ -456,6 +482,7 @@ static const struct cpumask *cpu_book_mask(int cpu) | |||
456 | } | 482 | } |
457 | 483 | ||
458 | static struct sched_domain_topology_level s390_topology[] = { | 484 | static struct sched_domain_topology_level s390_topology[] = { |
485 | { cpu_thread_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, | ||
459 | { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, | 486 | { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) }, |
460 | { cpu_book_mask, SD_INIT_NAME(BOOK) }, | 487 | { cpu_book_mask, SD_INIT_NAME(BOOK) }, |
461 | { cpu_cpu_mask, SD_INIT_NAME(DIE) }, | 488 | { cpu_cpu_mask, SD_INIT_NAME(DIE) }, |