Re: [PATCH 08/10] psi: pressure stall information for CPU, memory, and IO

From: Peter Zijlstra
Date: Thu Jul 19 2018 - 09:18:49 EST


On Thu, Jul 19, 2018 at 08:50:38AM -0400, Johannes Weiner wrote:
> On Thu, Jul 19, 2018 at 11:26:14AM +0200, Peter Zijlstra wrote:
> > On Wed, Jul 18, 2018 at 02:03:18PM +0200, Peter Zijlstra wrote:
> >
> > > Leaving us just 5 bytes short of needing a single cacheline :/
> > >
> > > struct ponies {
> > > unsigned int tasks[3]; /* 0 12 */
> > > unsigned int cpu_state:2; /* 12:30 4 */
> > > unsigned int io_state:2; /* 12:28 4 */
> > > unsigned int mem_state:2; /* 12:26 4 */
> > >
> > > /* XXX 26 bits hole, try to pack */
> > >
> > > /* typedef u64 */ long long unsigned int last_time; /* 16 8 */
> > > /* typedef u64 */ long long unsigned int some_time[3]; /* 24 24 */
> > > /* typedef u64 */ long long unsigned int full_time[2]; /* 48 16 */
> > > /* --- cacheline 1 boundary (64 bytes) --- */
> > > /* typedef u64 */ long long unsigned int nonidle_time; /* 64 8 */
> > >
> > > /* size: 72, cachelines: 2, members: 8 */
> > > /* bit holes: 1, sum bit holes: 26 bits */
> > > /* last cacheline: 8 bytes */
> > > };
> > >
> > > ARGGH!
> >
> > It _might_ be possible to use curr->se.exec_start for last_time if you
> > very carefully audit and place the hooks. I've not gone through it in
> > detail, but it might just work.
>
> Hnngg, and chop off an entire cacheline...

Yes.. a worthy goal :-)

> But don't we flush that delta out and update the timestamp on every
> tick?

Indeed.

> entity_tick() does update_curr(). That might be too expensive :(

Well, since you already do all this accounting on every enqueue/dequeue,
this can run many thousands of times per tick already, so once per tick
doesn't sound bad.

However, I just realized this might not in fact work, because
curr->se.exec_start is per task, and you really want something per-cpu
for this.

Bah, if only perf had a useful tool to report on data layout instead of
this c2c crap.. :-( The thinking being that we could maybe find a
usage-hole (a data member that is not in fact used) near something we
already touch for writing.