Re: CONFIG_VMAP_STACK, on-stack struct, and wake_up_bit

From: Peter Zijlstra
Date: Thu Oct 27 2016 - 11:19:40 EST


On Thu, Oct 27, 2016 at 10:07:42AM +0100, Mel Gorman wrote:
> > Something like so could work I suppose, but then there's a slight
> > regression in the page_unlock() path, where we now do an unconditional
> > spinlock; iow. we loose the unlocked waitqueue_active() test.
> >
>
> I can't convince myself it's worthwhile. At least, I can't see a penalty
> of potentially moving one of the two bits to the high word. It's the
> same cache line and the same op when it matters.

I'm having trouble connecting these here two paragraphs. Or were you
replying to something else?

So the current unlock code does:

wake_up_page()
if (waitqueue_active())
__wake_up() /* takes waitqueue spinlocks here */

While the new one does:

spin_lock(&q->lock);
if (waitqueue_active()) {
__wake_up_common()
}
spin_unlock(&q->lock);

Which is an unconditional atomic op (which go for about ~20 cycles each,
when uncontended).


> > +++ b/include/linux/page-flags.h
> > @@ -73,6 +73,14 @@
> > */
> > enum pageflags {
> > PG_locked, /* Page is locked. Don't touch. */
> > +#ifdef CONFIG_NUMA
> > + /*
> > + * This bit must end up in the same word as PG_locked (or any other bit
> > + * we're waiting on), as per all architectures their bitop
> > + * implementations.
> > + */
> > + PG_waiters, /* The hashed waitqueue has waiters */
> > +#endif
> > PG_error,
> > PG_referenced,
> > PG_uptodate,
>
> I don't see why it should be NUMA-specific even though with Linus'
> patch, NUMA is a concern. Even then, you still need a 64BIT check
> because 32BIT && NUMA is allowed on a number of architectures.

Oh, I thought we killed 32bit NUMA and didn't check. I can make it
CONFIG_64BIT and be done with it. s/CONFIG_NUMA/CONFIG_64BIT/ on the
patch should do :-)

> Otherwise, nothing jumped out at me but glancing through it looked very
> similar to the previous patch.

Right, all the difference was in the bit being conditional and having a
different name.