* Re: [PATCH] psi: Only collect online cpu time in collect_percpu_times
[not found] <20191202130928.2971-1-fishland@aliyun.com>
@ 2019-12-04 12:35 ` Peter Zijlstra
[not found] ` <201912051005599522735@zte.com.cn>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2019-12-04 12:35 UTC (permalink / raw)
To: Liu Song; +Cc: mingo, linux-kernel, liu.song11
On Mon, Dec 02, 2019 at 09:09:28PM +0800, Liu Song wrote:
> From: Liu Song <liu.song11@zte.com.cn>
>
> 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@zte.com.cn>
> ---
> 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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] psi: Only collect online cpu time in collect_percpu_times
[not found] ` <201912051005599522735@zte.com.cn>
@ 2019-12-05 10:33 ` Peter Zijlstra
[not found] ` <201912061229281310714@zte.com.cn>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2019-12-05 10:33 UTC (permalink / raw)
To: liu.song11; +Cc: fishland, mingo, linux-kernel, jiang.xuexin
On Thu, Dec 05, 2019 at 10:05:59AM +0800, liu.song11@zte.com.cn wrote:
> >On Mon, Dec 02, 2019 at 09:09:28PM +0800, Liu Song wrote:
> >> From: Liu Song <liu.song11@zte.com.cn>
> >>
> >> 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@zte.com.cn>
> >> ---
> >> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] psi: Only collect online cpu time in collect_percpu_times
[not found] ` <201912061229281310714@zte.com.cn>
@ 2019-12-06 12:01 ` Peter Zijlstra
0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2019-12-06 12:01 UTC (permalink / raw)
To: liu.song11; +Cc: fishland, mingo, linux-kernel, jiang.xuexin
On Fri, Dec 06, 2019 at 12:29:28PM +0800, liu.song11@zte.com.cn wrote:
> >No, the value will not change, but it need not be 0.
>
> Hi,
>
> Suppose there are 4 cpu online, then we take cpu 3 offline. In "collect_percpu_times",
> because "for_each_possible_cpu", will still collect the time of cpu 3 which is offline.
Correct, someone needs to collect the last deltas.
> However, it is clear that "nonidle" will remain at 0 until cpu 3 comes online again.
How does it become 0?
Consider
CPU2 CPU3
// runs crap, nonidle increases
// offline CPU3
// goes offline, nonidle is still >0
At this point someone needs to collect the delta from CPU3 to make it 0.
But if you only iterate online CPUs, that will not happen.
> And the value of "deltas[s]" will not change after collecting CPU 2. In "get_recent_times",
> the value of "groupc->times_prev[aggregator][s]" corresponding to cpu 3 will not change.
They will not change after the first collection after hot-un-plug. You
need at least one collection after it stops running crap.
> This is only a case where one CPU goes offline. If there are multiple CPUs offline,
> it will correspond to more meaningless operations. So here should be changed to
> "for_each_online_cpu", the effect is exactly the same as "for_each_possible_cpu",
> and the possible meaningless processes are excluded.
It is not. Or if it is, you failed to explain who collects on hotplug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-06 12:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20191202130928.2971-1-fishland@aliyun.com>
2019-12-04 12:35 ` [PATCH] psi: Only collect online cpu time in collect_percpu_times Peter Zijlstra
[not found] ` <201912051005599522735@zte.com.cn>
2019-12-05 10:33 ` Peter Zijlstra
[not found] ` <201912061229281310714@zte.com.cn>
2019-12-06 12:01 ` Peter Zijlstra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.