Skip to content

Commit 90d5ce8

Browse files
npigginmpe
authored andcommitted
powerpc/pseries: Fix CONFIG_DTL=n build
The recently moved dtl code must be compiled-in if CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y even if CONFIG_DTL=n. Fixes: 6ba5aa5 ("powerpc/pseries: Move dtl scanning and steal time accounting to pseries platform") Reported-by: Guenter Roeck <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a4cb365 commit 90d5ce8

File tree

2 files changed

+80
-74
lines changed

2 files changed

+80
-74
lines changed

arch/powerpc/platforms/pseries/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ obj-y := lpar.o hvCall.o nvram.o reconfig.o \
77
setup.o iommu.o event_sources.o ras.o \
88
firmware.o power.o dlpar.o mobility.o rng.o \
99
pci.o pci_dlpar.o eeh_pseries.o msi.o \
10-
papr_platform_attributes.o
10+
papr_platform_attributes.o dtl.o
1111
obj-$(CONFIG_SMP) += smp.o
1212
obj-$(CONFIG_KEXEC_CORE) += kexec.o
1313
obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o
@@ -19,7 +19,6 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
1919
obj-$(CONFIG_HVCS) += hvcserver.o
2020
obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
2121
obj-$(CONFIG_CMM) += cmm.o
22-
obj-$(CONFIG_DTL) += dtl.o
2322
obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o
2423
obj-$(CONFIG_LPARCFG) += lparcfg.o
2524
obj-$(CONFIG_IBMVIO) += vio.o

arch/powerpc/platforms/pseries/dtl.c

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <asm/plpar_wrappers.h>
1919
#include <asm/machdep.h>
2020

21+
#ifdef CONFIG_DTL
2122
struct dtl {
2223
struct dtl_entry *buf;
2324
int cpu;
@@ -57,78 +58,6 @@ static DEFINE_PER_CPU(struct dtl_ring, dtl_rings);
5758

5859
static atomic_t dtl_count;
5960

60-
/*
61-
* Scan the dispatch trace log and count up the stolen time.
62-
* Should be called with interrupts disabled.
63-
*/
64-
static notrace u64 scan_dispatch_log(u64 stop_tb)
65-
{
66-
u64 i = local_paca->dtl_ridx;
67-
struct dtl_entry *dtl = local_paca->dtl_curr;
68-
struct dtl_entry *dtl_end = local_paca->dispatch_log_end;
69-
struct lppaca *vpa = local_paca->lppaca_ptr;
70-
u64 tb_delta;
71-
u64 stolen = 0;
72-
u64 dtb;
73-
74-
if (!dtl)
75-
return 0;
76-
77-
if (i == be64_to_cpu(vpa->dtl_idx))
78-
return 0;
79-
while (i < be64_to_cpu(vpa->dtl_idx)) {
80-
dtb = be64_to_cpu(dtl->timebase);
81-
tb_delta = be32_to_cpu(dtl->enqueue_to_dispatch_time) +
82-
be32_to_cpu(dtl->ready_to_enqueue_time);
83-
barrier();
84-
if (i + N_DISPATCH_LOG < be64_to_cpu(vpa->dtl_idx)) {
85-
/* buffer has overflowed */
86-
i = be64_to_cpu(vpa->dtl_idx) - N_DISPATCH_LOG;
87-
dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG);
88-
continue;
89-
}
90-
if (dtb > stop_tb)
91-
break;
92-
if (dtl_consumer)
93-
dtl_consumer(dtl, i);
94-
stolen += tb_delta;
95-
++i;
96-
++dtl;
97-
if (dtl == dtl_end)
98-
dtl = local_paca->dispatch_log;
99-
}
100-
local_paca->dtl_ridx = i;
101-
local_paca->dtl_curr = dtl;
102-
return stolen;
103-
}
104-
105-
/*
106-
* Accumulate stolen time by scanning the dispatch trace log.
107-
* Called on entry from user mode.
108-
*/
109-
void notrace pseries_accumulate_stolen_time(void)
110-
{
111-
u64 sst, ust;
112-
struct cpu_accounting_data *acct = &local_paca->accounting;
113-
114-
sst = scan_dispatch_log(acct->starttime_user);
115-
ust = scan_dispatch_log(acct->starttime);
116-
acct->stime -= sst;
117-
acct->utime -= ust;
118-
acct->steal_time += ust + sst;
119-
}
120-
121-
u64 pseries_calculate_stolen_time(u64 stop_tb)
122-
{
123-
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
124-
return 0;
125-
126-
if (get_paca()->dtl_ridx != be64_to_cpu(get_lppaca()->dtl_idx))
127-
return scan_dispatch_log(stop_tb);
128-
129-
return 0;
130-
}
131-
13261
/*
13362
* The cpu accounting code controls the DTL ring buffer, and we get
13463
* given entries as they are processed.
@@ -436,3 +365,81 @@ static int dtl_init(void)
436365
return 0;
437366
}
438367
machine_arch_initcall(pseries, dtl_init);
368+
#endif /* CONFIG_DTL */
369+
370+
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
371+
/*
372+
* Scan the dispatch trace log and count up the stolen time.
373+
* Should be called with interrupts disabled.
374+
*/
375+
static notrace u64 scan_dispatch_log(u64 stop_tb)
376+
{
377+
u64 i = local_paca->dtl_ridx;
378+
struct dtl_entry *dtl = local_paca->dtl_curr;
379+
struct dtl_entry *dtl_end = local_paca->dispatch_log_end;
380+
struct lppaca *vpa = local_paca->lppaca_ptr;
381+
u64 tb_delta;
382+
u64 stolen = 0;
383+
u64 dtb;
384+
385+
if (!dtl)
386+
return 0;
387+
388+
if (i == be64_to_cpu(vpa->dtl_idx))
389+
return 0;
390+
while (i < be64_to_cpu(vpa->dtl_idx)) {
391+
dtb = be64_to_cpu(dtl->timebase);
392+
tb_delta = be32_to_cpu(dtl->enqueue_to_dispatch_time) +
393+
be32_to_cpu(dtl->ready_to_enqueue_time);
394+
barrier();
395+
if (i + N_DISPATCH_LOG < be64_to_cpu(vpa->dtl_idx)) {
396+
/* buffer has overflowed */
397+
i = be64_to_cpu(vpa->dtl_idx) - N_DISPATCH_LOG;
398+
dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG);
399+
continue;
400+
}
401+
if (dtb > stop_tb)
402+
break;
403+
#ifdef CONFIG_DTL
404+
if (dtl_consumer)
405+
dtl_consumer(dtl, i);
406+
#endif
407+
stolen += tb_delta;
408+
++i;
409+
++dtl;
410+
if (dtl == dtl_end)
411+
dtl = local_paca->dispatch_log;
412+
}
413+
local_paca->dtl_ridx = i;
414+
local_paca->dtl_curr = dtl;
415+
return stolen;
416+
}
417+
418+
/*
419+
* Accumulate stolen time by scanning the dispatch trace log.
420+
* Called on entry from user mode.
421+
*/
422+
void notrace pseries_accumulate_stolen_time(void)
423+
{
424+
u64 sst, ust;
425+
struct cpu_accounting_data *acct = &local_paca->accounting;
426+
427+
sst = scan_dispatch_log(acct->starttime_user);
428+
ust = scan_dispatch_log(acct->starttime);
429+
acct->stime -= sst;
430+
acct->utime -= ust;
431+
acct->steal_time += ust + sst;
432+
}
433+
434+
u64 pseries_calculate_stolen_time(u64 stop_tb)
435+
{
436+
if (!firmware_has_feature(FW_FEATURE_SPLPAR))
437+
return 0;
438+
439+
if (get_paca()->dtl_ridx != be64_to_cpu(get_lppaca()->dtl_idx))
440+
return scan_dispatch_log(stop_tb);
441+
442+
return 0;
443+
}
444+
445+
#endif

0 commit comments

Comments
 (0)