Skip to content

Commit 1c85a2a

Browse files
rnavmpe
authored andcommitted
powerpc/pseries: Factor out DTL buffer allocation and registration routines
Introduce new helpers for DTL buffer allocation and registration and have the existing code use those. Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [mpe: Don't split error messages across lines, for grepability] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 5b3306f commit 1c85a2a

File tree

3 files changed

+54
-50
lines changed

3 files changed

+54
-50
lines changed

arch/powerpc/include/asm/lppaca.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ extern struct kmem_cache *dtl_cache;
175175
*/
176176
extern void (*dtl_consumer)(struct dtl_entry *entry, u64 index);
177177

178+
extern void register_dtl_buffer(int cpu);
179+
extern void alloc_dtl_buffers(void);
180+
178181
#endif /* CONFIG_PPC_BOOK3S */
179182
#endif /* __KERNEL__ */
180183
#endif /* _ASM_POWERPC_LPPACA_H */

arch/powerpc/platforms/pseries/lpar.c

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,59 @@ EXPORT_SYMBOL(plpar_hcall);
6565
EXPORT_SYMBOL(plpar_hcall9);
6666
EXPORT_SYMBOL(plpar_hcall_norets);
6767

68+
void alloc_dtl_buffers(void)
69+
{
70+
int cpu;
71+
struct paca_struct *pp;
72+
struct dtl_entry *dtl;
73+
74+
for_each_possible_cpu(cpu) {
75+
pp = paca_ptrs[cpu];
76+
dtl = kmem_cache_alloc(dtl_cache, GFP_KERNEL);
77+
if (!dtl) {
78+
pr_warn("Failed to allocate dispatch trace log for cpu %d\n",
79+
cpu);
80+
pr_warn("Stolen time statistics will be unreliable\n");
81+
break;
82+
}
83+
84+
pp->dtl_ridx = 0;
85+
pp->dispatch_log = dtl;
86+
pp->dispatch_log_end = dtl + N_DISPATCH_LOG;
87+
pp->dtl_curr = dtl;
88+
}
89+
}
90+
91+
void register_dtl_buffer(int cpu)
92+
{
93+
long ret;
94+
struct paca_struct *pp;
95+
struct dtl_entry *dtl;
96+
int hwcpu = get_hard_smp_processor_id(cpu);
97+
98+
pp = paca_ptrs[cpu];
99+
dtl = pp->dispatch_log;
100+
if (dtl) {
101+
pp->dtl_ridx = 0;
102+
pp->dtl_curr = dtl;
103+
lppaca_of(cpu).dtl_idx = 0;
104+
105+
/* hypervisor reads buffer length from this field */
106+
dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES);
107+
ret = register_dtl(hwcpu, __pa(dtl));
108+
if (ret)
109+
pr_err("WARNING: DTL registration of cpu %d (hw %d) failed with %ld\n",
110+
cpu, hwcpu, ret);
111+
112+
lppaca_of(cpu).dtl_enable_mask = DTL_LOG_PREEMPT;
113+
}
114+
}
115+
68116
void vpa_init(int cpu)
69117
{
70118
int hwcpu = get_hard_smp_processor_id(cpu);
71119
unsigned long addr;
72120
long ret;
73-
struct paca_struct *pp;
74-
struct dtl_entry *dtl;
75121

76122
/*
77123
* The spec says it "may be problematic" if CPU x registers the VPA of
@@ -112,22 +158,7 @@ void vpa_init(int cpu)
112158
/*
113159
* Register dispatch trace log, if one has been allocated.
114160
*/
115-
pp = paca_ptrs[cpu];
116-
dtl = pp->dispatch_log;
117-
if (dtl) {
118-
pp->dtl_ridx = 0;
119-
pp->dtl_curr = dtl;
120-
lppaca_of(cpu).dtl_idx = 0;
121-
122-
/* hypervisor reads buffer length from this field */
123-
dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES);
124-
ret = register_dtl(hwcpu, __pa(dtl));
125-
if (ret)
126-
pr_err("WARNING: DTL registration of cpu %d (hw %d) "
127-
"failed with %ld\n", smp_processor_id(),
128-
hwcpu, ret);
129-
lppaca_of(cpu).dtl_enable_mask = DTL_LOG_PREEMPT;
130-
}
161+
register_dtl_buffer(cpu);
131162
}
132163

133164
#ifdef CONFIG_PPC_BOOK3S_64

arch/powerpc/platforms/pseries/setup.c

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -279,46 +279,16 @@ struct kmem_cache *dtl_cache;
279279
*/
280280
static int alloc_dispatch_logs(void)
281281
{
282-
int cpu, ret;
283-
struct paca_struct *pp;
284-
struct dtl_entry *dtl;
285-
286282
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
287283
return 0;
288284

289285
if (!dtl_cache)
290286
return 0;
291287

292-
for_each_possible_cpu(cpu) {
293-
pp = paca_ptrs[cpu];
294-
dtl = kmem_cache_alloc(dtl_cache, GFP_KERNEL);
295-
if (!dtl) {
296-
pr_warn("Failed to allocate dispatch trace log for cpu %d\n",
297-
cpu);
298-
pr_warn("Stolen time statistics will be unreliable\n");
299-
break;
300-
}
301-
302-
pp->dtl_ridx = 0;
303-
pp->dispatch_log = dtl;
304-
pp->dispatch_log_end = dtl + N_DISPATCH_LOG;
305-
pp->dtl_curr = dtl;
306-
}
288+
alloc_dtl_buffers();
307289

308290
/* Register the DTL for the current (boot) cpu */
309-
dtl = get_paca()->dispatch_log;
310-
get_paca()->dtl_ridx = 0;
311-
get_paca()->dtl_curr = dtl;
312-
get_paca()->lppaca_ptr->dtl_idx = 0;
313-
314-
/* hypervisor reads buffer length from this field */
315-
dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES);
316-
ret = register_dtl(hard_smp_processor_id(), __pa(dtl));
317-
if (ret)
318-
pr_err("WARNING: DTL registration of cpu %d (hw %d) failed "
319-
"with %d\n", smp_processor_id(),
320-
hard_smp_processor_id(), ret);
321-
get_paca()->lppaca_ptr->dtl_enable_mask = DTL_LOG_PREEMPT;
291+
register_dtl_buffer(smp_processor_id());
322292

323293
return 0;
324294
}

0 commit comments

Comments
 (0)