Re: [PATCH] mm/memory-failure: Use a mutex to avoid memory_failure() races

Aili Yao
2021-03-09T06:39:03Z

On Tue, 9 Mar 2021 06:04:41 +0000
HORIGUCHI NAOYA(堀口　直也) <naoya.horiguchi@nec.com> wrote:

> ...
> >
> > If others are OK with this method, then I am OK too.
> > But I have two concerns, May you take into account:
> >
> > 1. The memory_failure with 0 return code for race condition, then the kill_me_maybe() goes into branch:
> > if (!memory_failure(p->mce_addr >> PAGE_SHIFT, flags) &&
> > !(p->mce_kflags & MCE_IN_KERNEL_COPYIN)) {
> > set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page);
> > sync_core();
> > return;
> > }
> >
> > while we place set_mce_nospec() here is for a reason, please see commit fd0e786d9d09024f67b.
> >
> > 2. When memory_failure return 0 and maybe return to user process, and it may re-execute the instruction triggering previous fault, this behavior
> > assume an implicit dependence that the related pte has been correctly set. or if not correctlily set, it will lead to infinite loop again.
>
> These seem to be separate issues from memory_failure()'s concurrency issue,
> so I'm still expecting that your patch is to be merged. Maybe do you want
> to update it based on the discussion (if it's concluded)?
>
> Thanks,
> Naoya Horiguchi

I have submitted a v2 patch, and please help review.

Thanks!

--
Thanks!
Aili Yao