Re: [PATCH] psi: Only collect online cpu time in collect_percpu_times

From: Peter Zijlstra
Date: Thu Dec 05 2019 - 05:33:40 EST


On Thu, Dec 05, 2019 at 10:05:59AM +0800, liu.song11@xxxxxxxxxx wrote:
> >On Mon, Dec 02, 2019 at 09:09:28PM +0800, Liu Song wrote:
> >> From: Liu Song <liu.song11@xxxxxxxxxx>
> >>
> >> Tasks can only run on the online cpu, so only need to
> >> collect the time of the online cpu.
> >>
> >> Signed-off-by: Liu Song <liu.song11@xxxxxxxxxx>
> >> ---
> >> kernel/sched/psi.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> >> index 7acc632c3b82..605f02facb7b 100644
> >> --- a/kernel/sched/psi.c
> >> +++ b/kernel/sched/psi.c
> >> @@ -316,7 +316,7 @@ static void collect_percpu_times(struct psi_group *group,
> >> * the sampling period. This eliminates artifacts from uneven
> >> * loading, or even entirely idle CPUs.
> >> */
> >> - for_each_possible_cpu(cpu) {
> >> + for_each_online_cpu(cpu) {
> >> u32 times[NR_PSI_STATES];
> >> u32 nonidle;
> >> u32 cpu_changed_states;
> >
> >And who collects the deltas that remain after offline?
>
> Hi,
> After the cpu goes offline, there is no activity on the cpu and no time will be updated.

But there might have been activitiy before it went offline.

> So the value of deltas is 0 and it will not contribute to the total time.

No, the value will not change, but it need not be 0.