On Tue, Apr 12, 2022 at 06:00:09PM +0800, Yu Xu wrote: > On 4/12/22 5:45 PM, Yu Xu wrote: ... > > > > > @@ -1087,12 +1087,21 @@ static int madvise_inject_error(int behavior, > > > > > return ret; > > > > > pfn = page_to_pfn(page); > > > > > + head = compound_head(page); > > > > > + if (unlikely(is_huge_zero_page(head))) { > > > > > + pr_warn("Unhandlable attempt to %s pfn %#lx at > > > > > process virtual address %#lx\n", > > > > > + behavior == MADV_SOFT_OFFLINE ? "soft offline" : > > > > > + "inject memory failure for", > > > > > + pfn, start); > > > > > + return -EINVAL; > > > > > + } > > > > > > This check is about the detail of error handling, so I feel it > > > desirable to > > > do this in memory_failure(). And memory errors on huge zero page is the > > > real scenario, so it seems to me better to make this case injectable > > > rather > > > than EINVAL. > > > > > > How about checking is_huge_zero_page() before try_to_split_thp_page()? > > > The result should be consistent with the results when called by other > > > memory_failure()'s callers like MCE handler and > > > hard_offline_page_store(). > > > > Agree. thanks! > > > > > > > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > > > index 9b76222ee237..771fb4fc626c 100644 > > > --- a/mm/memory-failure.c > > > +++ b/mm/memory-failure.c > > > @@ -1852,6 +1852,12 @@ int memory_failure(unsigned long pfn, int flags) > > > } > > > if (PageTransHuge(hpage)) { > > > + if (is_huge_zero_page(hpage)) { > > > + action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); > > > > Should we use MF_MSG_UNSPLIT_THP instead of MF_MSG_KERNEL_HIGH_ORDER? > > > > And should we SetPageHasHWPoisoned(hpage) for huge zero page, since > > TestSetPageHWPoison(p) is done in the early part of memory_failure(). Yeah, these could be possible. I suggested them to get the same result regardless of calling interfaces of memory_failure(). How huge_zero pages should be handled is separate from the reported issue on VM_BUG_ON_PAGE(), so it would require a separate patch (which updates MF_COUNT_INCREASED=true case too). Thanks, Naoya Horiguchi > > If so, we just need to add a one-line condition in > try_to_split_thp_page().