Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Naveen N. Rao and committed by
Michael Ellerman
1c85a2a1 5b3306f0

+54 -50
+3
arch/powerpc/include/asm/lppaca.h
··· 175 175 */ 176 176 extern void (*dtl_consumer)(struct dtl_entry *entry, u64 index); 177 177 178 + extern void register_dtl_buffer(int cpu); 179 + extern void alloc_dtl_buffers(void); 180 + 178 181 #endif /* CONFIG_PPC_BOOK3S */ 179 182 #endif /* __KERNEL__ */ 180 183 #endif /* _ASM_POWERPC_LPPACA_H */
+49 -18
arch/powerpc/platforms/pseries/lpar.c
··· 65 65 EXPORT_SYMBOL(plpar_hcall9); 66 66 EXPORT_SYMBOL(plpar_hcall_norets); 67 67 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 + 68 116 void vpa_init(int cpu) 69 117 { 70 118 int hwcpu = get_hard_smp_processor_id(cpu); 71 119 unsigned long addr; 72 120 long ret; 73 - struct paca_struct *pp; 74 - struct dtl_entry *dtl; 75 121 76 122 /* 77 123 * The spec says it "may be problematic" if CPU x registers the VPA of ··· 158 112 /* 159 113 * Register dispatch trace log, if one has been allocated. 160 114 */ 161 - pp = paca_ptrs[cpu]; 162 - dtl = pp->dispatch_log; 163 - if (dtl) { 164 - pp->dtl_ridx = 0; 165 - pp->dtl_curr = dtl; 166 - lppaca_of(cpu).dtl_idx = 0; 167 - 168 - /* hypervisor reads buffer length from this field */ 169 - dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES); 170 - ret = register_dtl(hwcpu, __pa(dtl)); 171 - if (ret) 172 - pr_err("WARNING: DTL registration of cpu %d (hw %d) " 173 - "failed with %ld\n", smp_processor_id(), 174 - hwcpu, ret); 175 - lppaca_of(cpu).dtl_enable_mask = DTL_LOG_PREEMPT; 176 - } 115 + register_dtl_buffer(cpu); 177 116 } 178 117 179 118 #ifdef CONFIG_PPC_BOOK3S_64
+2 -32
arch/powerpc/platforms/pseries/setup.c
··· 279 279 */ 280 280 static int alloc_dispatch_logs(void) 281 281 { 282 - int cpu, ret; 283 - struct paca_struct *pp; 284 - struct dtl_entry *dtl; 285 - 286 282 if (!firmware_has_feature(FW_FEATURE_SPLPAR)) 287 283 return 0; 288 284 289 285 if (!dtl_cache) 290 286 return 0; 291 287 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(); 307 289 308 290 /* 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()); 322 292 323 293 return 0; 324 294 }