Re: [RFC PATCH] mm: silence soft lockups from unlock_page
From: Matthew Wilcox
Date: Thu Aug 06 2020 - 14:00:38 EST
On Thu, Aug 06, 2020 at 10:07:07AM -0700, Linus Torvalds wrote:
> On Wed, Aug 5, 2020 at 10:21 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote:
> > Something I was interested to realize in looking at this: trylock_page()
> > on a contended lock is now much less likely to jump the queue and
> > succeed than before, since your lock holder hands off the page lock to
> > the next holder: much smaller window than waiting for the next to wake
> > to take it. Nothing wrong with that, but effect might be seen somewhere.
> Yeah, the window is smaller, but it's not gone.
> It *might* be interesting to actually do the handover directly from
> "unlock_page()", and avoid clearing (and then setting) the bit
> Something like the attached TOTALLY UNTESTED patch.
> NOTE! Sometimes when I say something is untested, I think the patch is
> fine because it's simple and straightforward, I just didn't test it.
> This time it's both untested and very very subtle indeed. Did I get
> the hand-over case SMP memory barriers right? Did I screw something
> else up?
> So this might be complete garbage. I really don't know. But it might
> close the window for an unfair trylock (or lucky page_lock())
It wasn't clear to me whether Hugh thought it was an improvement or
not that trylock was now less likely to jump the queue. There're
the usual "fair is the opposite of throughput" kind of arguments.