+ psi-pressure-stall-information-for-cpu-memory-and-io-fix-2.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: psi-pressure-stall-information-for-cpu-memory-and-io-fix-2
has been added to the -mm tree.  Its filename is
     psi-pressure-stall-information-for-cpu-memory-and-io-fix-2.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/psi-pressure-stall-information-for-cpu-memory-and-io-fix-2.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/psi-pressure-stall-information-for-cpu-memory-and-io-fix-2.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Johannes Weiner <hannes@xxxxxxxxxxx>
Subject: psi-pressure-stall-information-for-cpu-memory-and-io-fix-2

Code optimization.

Still pretty readable, and generates compact code inside the now single
retry section:

ffffffff81ed464f:       44 89 ff                mov    %r15d,%edi
ffffffff81ed4652:       e8 00 00 00 00          callq  ffffffff81ed4657 <update_stats+0xca>
                        ffffffff81ed4653: R_X86_64_PLT32        sched_clock_cpu-0x4
                memcpy(times, groupc->times, sizeof(groupc->times));
ffffffff81ed4657:       49 8b 14 24             mov    (%r12),%rdx
                state_start = groupc->state_start;
ffffffff81ed465b:       48 8b 4b 50             mov    0x50(%rbx),%rcx
                memcpy(times, groupc->times, sizeof(groupc->times));
ffffffff81ed465f:       48 89 54 24 30          mov    %rdx,0x30(%rsp)
ffffffff81ed4664:       49 8b 54 24 08          mov    0x8(%r12),%rdx
ffffffff81ed4669:       48 89 54 24 38          mov    %rdx,0x38(%rsp)
ffffffff81ed466e:       49 8b 54 24 10          mov    0x10(%r12),%rdx
ffffffff81ed4673:       48 89 54 24 40          mov    %rdx,0x40(%rsp)
                memcpy(tasks, groupc->tasks, sizeof(groupc->tasks));
ffffffff81ed4678:       49 8b 55 00             mov    0x0(%r13),%rdx
ffffffff81ed467c:       48 89 54 24 24          mov    %rdx,0x24(%rsp)
ffffffff81ed4681:       41 8b 55 08             mov    0x8(%r13),%edx
ffffffff81ed4685:       89 54 24 2c             mov    %edx,0x2c(%rsp)

Link: http://lkml.kernel.org/r/20180907175015.GA8479@xxxxxxxxxxx
Cc: Christopher Lameter <cl@xxxxxxxxx>
Cc: Daniel Drake <drake@xxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Johannes Weiner <jweiner@xxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Peter Enderborg <peter.enderborg@xxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Cc: Shakeel Butt <shakeelb@xxxxxxxxxx>
Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Vinayak Menon <vinmenon@xxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 kernel/sched/psi.c |   43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

--- a/kernel/sched/psi.c~psi-pressure-stall-information-for-cpu-memory-and-io-fix-2
+++ a/kernel/sched/psi.c
@@ -197,17 +197,26 @@ static bool test_state(unsigned int *tas
 	}
 }
 
-static u32 get_recent_time(struct psi_group *group, int cpu,
-			   enum psi_states state)
+static void get_recent_times(struct psi_group *group, int cpu, u32 *times)
 {
 	struct psi_group_cpu *groupc = per_cpu_ptr(group->pcpu, cpu);
+	unsigned int tasks[NR_PSI_TASK_COUNTS];
+	u64 now, state_start;
 	unsigned int seq;
-	u32 time, delta;
+	int s;
 
+	/* Snapshot a coherent view of the CPU state */
 	do {
 		seq = read_seqcount_begin(&groupc->seq);
+		now = cpu_clock(cpu);
+		memcpy(times, groupc->times, sizeof(groupc->times));
+		memcpy(tasks, groupc->tasks, sizeof(groupc->tasks));
+		state_start = groupc->state_start;
+	} while (read_seqcount_retry(&groupc->seq, seq));
 
-		time = groupc->times[state];
+	/* Calculate state time deltas against the previous snapshot */
+	for (s = 0; s < NR_PSI_STATES; s++) {
+		u32 delta;
 		/*
 		 * In addition to already concluded states, we also
 		 * incorporate currently active states on the CPU,
@@ -217,14 +226,14 @@ static u32 get_recent_time(struct psi_gr
 		 * (u32) and our reported pressure close to what's
 		 * actually happening.
 		 */
-		if (test_state(groupc->tasks, state))
-			time += cpu_clock(cpu) - groupc->state_start;
-	} while (read_seqcount_retry(&groupc->seq, seq));
+		if (test_state(tasks, s))
+			times[s] += now - state_start;
 
-	delta = time - groupc->times_prev[state];
-	groupc->times_prev[state] = time;
+		delta = times[s] - groupc->times_prev[s];
+		groupc->times_prev[s] = times[s];
 
-	return delta;
+		times[s] = delta;
+	}
 }
 
 static void calc_avgs(unsigned long avg[3], int missed_periods,
@@ -267,18 +276,16 @@ static bool update_stats(struct psi_grou
 	 * loading, or even entirely idle CPUs.
 	 */
 	for_each_possible_cpu(cpu) {
+		u32 times[NR_PSI_STATES];
 		u32 nonidle;
 
-		nonidle = get_recent_time(group, cpu, PSI_NONIDLE);
-		nonidle = nsecs_to_jiffies(nonidle);
-		nonidle_total += nonidle;
+		get_recent_times(group, cpu, times);
 
-		for (s = 0; s < PSI_NONIDLE; s++) {
-			u32 delta;
+		nonidle = nsecs_to_jiffies(times[PSI_NONIDLE]);
+		nonidle_total += nonidle;
 
-			delta = get_recent_time(group, cpu, s);
-			deltas[s] += (u64)delta * nonidle;
-		}
+		for (s = 0; s < PSI_NONIDLE; s++)
+			deltas[s] += (u64)times[s] * nonidle;
 	}
 
 	/*
_

Patches currently in -mm which might be from hannes@xxxxxxxxxxx are

mm-workingset-tell-cache-transitions-from-workingset-thrashing.patch
delayacct-track-delays-from-thrashing-cache-pages.patch
sched-loadavg-consolidate-load_int-load_frac-calc_load.patch
sched-loadavg-make-calc_load_n-public.patch
sched-schedh-make-rq-locking-and-clock-functions-available-in-statsh.patch
sched-introduce-this_rq_lock_irq.patch
psi-pressure-stall-information-for-cpu-memory-and-io.patch
psi-pressure-stall-information-for-cpu-memory-and-io-fix.patch
psi-pressure-stall-information-for-cpu-memory-and-io-fix-2.patch
psi-pressure-stall-information-for-cpu-memory-and-io-fix-3.patch
psi-cgroup-support.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux