Re: [RFC PATCH] mm: silence soft lockups from unlock_page

From: Michal Hocko
Date: Thu Jul 23 2020 - 04:04:01 EST


On Wed 22-07-20 11:29:20, Linus Torvalds wrote:
> On Tue, Jul 21, 2020 at 8:33 AM Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > More likely, it's actually *caused* by that commit 11a19c7b099f, and
> > what might be happening is that other CPU's are just adding new
> > waiters to the list *while* we're waking things up, because somebody
> > else already got the page lock again.
> >
> > Humor me.. Does something like this work instead?
>
> I went back and looked at this, because it bothered me.

Thanks for pursuing this. I have learned that the affected system is in
fact a production machine which doesn't seem to have any downtime window
planned soon. Moreover the issue is not always reproducible. So I cannot
guarantee I can have this or other patches tested soon which is really
unfortunate.

> And I'm no longer convinced it can possibly make a difference.
>
> Why?
>
> Because __wake_up_locked_key_bookmark() just calls __wake_up_common(),
> and that one checks the return value of the wakeup function:
>
> ret = curr->func(curr, mode, wake_flags, key);
> if (ret < 0)
> break;
>
> and will not add the bookmark back to the list if this triggers.
>
> And the wakeup function does that same "stop walking" thing:
>
> if (test_bit(key->bit_nr, &key->page->flags))
> return -1;
>
> So if somebody else took the page lock, I think we should already have
> stopped walking the list.

Right! I didn't bother to look at the wakeup callback so have missed
this. For completeness this behavior is there since 3510ca20ece01 which
we have in our 4.12 based kernel as well.
--
Michal Hocko
SUSE Labs