Skip to contentSkip to conversation

psi: Only collect online cpu time in collect_percpu_times

PATCH Peter Zijlstra 1 participant 3 messages Dec 4, 2019 – Dec 6, 2019 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 15 lines · Liu Song

From: Liu Song <[email protected]>

Tasks can only run on the online cpu, so only need to collect the time of the online cpu.

---
 kernel/sched/psi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/psi.c +0 -0
index 7acc632c3b82..605f02facb7b 100644

kernel/sched/psi.c static void collect_percpu_times(struct psi_group *group, · line 322

Quoted 8 lines
kernel/sched/psi.c +1 -1
@@ -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?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 27 lines · On Thu, Dec 05, 2019 at 10:05:59AM +0800, [email protected] wrote:
Quoted 11 lines · Liu Song
Quoted 10 lines

From: Liu Song <[email protected]>

Tasks can only run on the online cpu, so only need to collect the time of the online cpu.

---
 kernel/sched/psi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

kernel/sched/psi.c static void collect_percpu_times(struct psi_group *group, · line 322

Quoted 13 lines
kernel/sched/psi.c +1 -1
index 7acc632c3b82..605f02facb7b 100644
@@ -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?

Quoted 2 lines

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.

Quoted 1 line

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.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 6 lines · On Fri, Dec 06, 2019 at 12:29:28PM +0800, [email protected] wrote:
Quoted 1 line

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.

Quoted 1 line

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.

Quoted 2 lines

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.

Quoted 4 lines

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.