Re: [PATCH] mm,hwpoison: return -EBUSY when page already poisoned

From: Aili Yao
Date: Wed Mar 10 2021 - 01:11:49 EST


On Fri, 5 Mar 2021 15:55:25 +0000
"Luck, Tony" <tony.luck@xxxxxxxxx> wrote:

> > From the walk, it seems we have got the virtual address, can we just send a SIGBUS with it?
>
> If the walk wins the race and the pte for the poisoned page is still valid, then yes.
>
> But we could have:
>
> CPU1 CPU2
> memory_failure sets poison
> bit for struct page
>
>
> rmap finds page in task
> on CPU2 and sets PTE
> to not-valid-poison
>
> memory_failure returns
> early because struct page
> already marked as poison
>
> walk page tables looking
> for mapping - don't find it
>
> -Tony

While I don't think there is a race condition, and if you really think the pfn with SIGBUS is not
proper, I think following patch maybe one way.
I copy your abandon code, and make a little modification, and just now it pass
my simple test.

And also this is a RFC version, only valid if you think the pfn with SIGBUS is not right.

Thanks!