From: Peter Zijlstra <firstname.lastname@example.org> To: Johannes Weiner <email@example.com> Cc: firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, email@example.com, Ingo Molnar <firstname.lastname@example.org>, Andrew Morton <email@example.com>, Tejun Heo <firstname.lastname@example.org>, Balbir Singh <email@example.com>, Mike Galbraith <firstname.lastname@example.org>, Oliver Yang <email@example.com>, Shakeel Butt <firstname.lastname@example.org>, xxx xxx <email@example.com>, Taras Kondratiuk <firstname.lastname@example.org>, Daniel Walker <email@example.com>, Vinayak Menon <firstname.lastname@example.org>, Ruslan Ruslichenko <email@example.com>, firstname.lastname@example.org Subject: Re: [PATCH 6/7] psi: pressure stall information for CPU, memory, and IO Date: Mon, 14 May 2018 10:33:53 +0200 [thread overview] Message-ID: <20180514083353.GN12217@hirez.programming.kicks-ass.net> (raw) In-Reply-To: <20180510134132.GA19348@cmpxchg.org> On Thu, May 10, 2018 at 09:41:32AM -0400, Johannes Weiner wrote: > So there is a reason I'm tracking productivity states per-cpu and not > globally. Consider the following example periods on two CPUs: > > CPU 0 > Task 1: | EXECUTING | memstalled | > Task 2: | runqueued | EXECUTING | > > CPU 1 > Task 3: | memstalled | EXECUTING | > > If we tracked only the global number of stalled tasks, similarly to > nr_uninterruptible, the number would be elevated throughout the whole > sampling period, giving a pressure value of 100% for "some stalled". > And, since there is always something executing, a "full stall" of 0%. But if you read the comment about SMP IO-wait; see commit: e33a9bba85a8 ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler") you'll see that per-cpu accounting has issues too. Also, note that in your example above you have 1 memstalled task (at any one time), but _2_ CPUs. So at most you should end up with a 50% value. There is no way 1 task could consume 2 CPUs worth of time. Furthermore, associating a blocked task to any particular CPU is fundamentally broken and I'll hard NAK anything that relies on it. > Now consider what happens when the Task 3 sequence is the other way > around: > > CPU 0 > Task 1: | EXECUTING | memstalled | > Task 2: | runqueued | EXECUTING | > > CPU 1 > Task 3: | EXECUTING | memstalled | > > Here the number of stalled tasks is elevated only during half of the > sampling period, this time giving a pressure reading of 50% for "some" > (and again 0% for "full"). That entirely depends on your averaging; an exponentially decaying average would not typically result in 50% for the above case. But I think we can agree that this results in one 0% and one 100% sample -- we have two stalled tasks and two CPUs. > That's a different measurement, but in terms of workload progress, the > sequences are functionally equivalent. In both scenarios the same > amount of productive CPU cycles is spent advancing tasks 1, 2 and 3, > and the same amount of potentially productive CPU time is lost due to > the contention of memory. We really ought to read the same pressure. And you do -- subject to the averaging used, as per the above. The first gives two 50% samples, the second gives 0%, 100%. > So what I'm doing is calculating the productivity loss on each CPU in > a sampling period as if they were independent time slices. It doesn't > matter how you slice and dice the sequences within each one - if used > CPU time and lost CPU time have the same proportion, we have the same > pressure. I'm still thinking you can do basically the same without the stong CPU relation. > To illustrate: > > CPU X > 1 2 3 4 > Task 1: | EXECUTING | memstalled | sleeping | sleeping | > Task 2: | runqueued | EXECUTING | sleeping | sleeping | > Task 3: | sleeping | sleeping | EXECUTING | memstalled | > > You can clearly see the 50% of walltime in which *somebody* isn't > advancing (2 and 4), and the 25% of walltime in which *no* tasks are > (3). Same amount of work, same memory stalls, same pressure numbers. > > Globalized state tracking would produce those numbers on the single > CPU (obviously), but once concurrency gets into the mix, it's > questionable what its results mean. It certainly isn't able to > reliably detect equivalent slowdowns of individual tasks ("some" is > all over the place), and in this example wasn't able to capture the > impact of contention on overall work completion ("full" is 0%). > > * CPU 0: some = 50%, full = 0% > CPU 1: some = 50%, full = 50% > avg: some = 50%, full = 25% I'm not entirely sure I get your point here; but note that a task doesn't sleep on a CPU. When it sleeps it is not strictly associated with a CPU, only when it runs does it have an association. What is the value of accounting a sleep state to a particular CPU if the task when wakes up on another? Where did the sleep take place? All we really can say is that a task slept, and if we can reduce the reason for its sleeping (IO, reclaim, whatever) then it could've ran sooner. And then you can make predictions based on the number of CPUs and global idle time, how much that could improve things.
next prev parent reply other threads:[~2018-05-14 8:34 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-07 21:01 [PATCH 0/7] " Johannes Weiner 2018-05-07 21:01 ` [PATCH 1/7] mm: workingset: don't drop refault information prematurely Johannes Weiner 2018-05-07 21:01 ` [PATCH 2/7] mm: workingset: tell cache transitions from workingset thrashing Johannes Weiner 2018-05-07 21:01 ` [PATCH 3/7] delayacct: track delays from thrashing cache pages Johannes Weiner 2018-05-07 21:01 ` [PATCH 4/7] sched: loadavg: consolidate LOAD_INT, LOAD_FRAC, CALC_LOAD Johannes Weiner 2018-05-07 21:01 ` [PATCH 5/7] sched: loadavg: make calc_load_n() public Johannes Weiner 2018-05-09 9:49 ` Peter Zijlstra 2018-05-10 13:46 ` Johannes Weiner 2018-05-07 21:01 ` [PATCH 6/7] psi: pressure stall information for CPU, memory, and IO Johannes Weiner 2018-05-08 0:42 ` Randy Dunlap 2018-05-08 14:06 ` Johannes Weiner 2018-05-08 1:35 ` kbuild test robot 2018-05-08 3:04 ` kbuild test robot 2018-05-08 14:05 ` Johannes Weiner 2018-05-09 9:59 ` Peter Zijlstra 2018-05-10 13:49 ` Johannes Weiner 2018-05-09 10:04 ` Peter Zijlstra 2018-05-10 14:10 ` Johannes Weiner 2018-05-09 10:05 ` Peter Zijlstra 2018-05-10 14:13 ` Johannes Weiner 2018-05-09 10:14 ` Peter Zijlstra 2018-05-10 14:18 ` Johannes Weiner 2018-05-09 10:21 ` Peter Zijlstra 2018-05-10 14:24 ` Johannes Weiner 2018-05-09 10:26 ` Peter Zijlstra 2018-05-09 10:46 ` Peter Zijlstra 2018-05-09 11:38 ` Peter Zijlstra 2018-05-10 13:41 ` Johannes Weiner 2018-05-14 8:33 ` Peter Zijlstra [this message] 2018-05-09 10:55 ` Peter Zijlstra 2018-05-09 11:03 ` Vinayak Menon 2018-05-23 13:17 ` Johannes Weiner 2018-05-23 13:19 ` Vinayak Menon 2018-06-07 0:46 ` Suren Baghdasaryan 2018-05-07 21:01 ` [PATCH 7/7] psi: cgroup support Johannes Weiner 2018-05-09 11:07 ` Peter Zijlstra 2018-05-10 14:49 ` Johannes Weiner 2018-05-14 15:39 ` [PATCH 0/7] psi: pressure stall information for CPU, memory, and IO Christopher Lameter 2018-05-14 17:35 ` Bart Van Assche 2018-05-14 18:55 ` Johannes Weiner 2018-05-14 20:15 ` Christopher Lameter 2018-05-26 0:29 ` Suren Baghdasaryan 2018-05-29 18:16 ` Johannes Weiner 2018-05-30 23:32 ` Suren Baghdasaryan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180514083353.GN12217@hirez.programming.kicks-ass.net \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: [PATCH 6/7] psi: pressure stall information for CPU, memory, and IO' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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.