On 2022/4/12 17:30, Oscar Salvador wrote: > On Tue, Apr 12, 2022 at 05:25:52PM +0800, Miaohe Lin wrote: >> On 2022/4/12 16:31, Oscar Salvador wrote: >>> On Sun, Apr 10, 2022 at 11:22:34PM +0800, Xu Yu wrote: >>>> Kernel panic when injecting memory_failure for the global huge_zero_page, >>>> when CONFIG_DEBUG_VM is enabled, as follows. >>> ... >>>> In fact, huge_zero_page is unhandlable currently in either soft offline >>>> or memory failure injection. With CONFIG_DEBUG_VM disabled, >>>> huge_zero_page is bailed out when checking HWPoisonHandlable() in >>>> get_any_page(), or checking page mapping in split_huge_page_to_list(). >>>> >>>> This makes huge_zero_page bail out early in madvise_inject_error(), and >>>> panic above won't happen again. >>> >>> I would not special case this in madvise_inject_error() but rather >>> handle it in memory-failure code. >>> We do already have HWPoisonHandlable(), which tells us whether the page >>> is of a type we can really do something about, so why not add another >>> check in HWPoisonHandlable() for huge_zero_page(), and have that checked >>> in memory_failure(). >> >> IIUC, this does not work. Because HWPoisonHandlable is only called in !MF_COUNT_INCREASED case. >> But MF_COUNT_INCREASED is always set when called from madvise_inject_error, so HWPoisonHandlable >> is not even called in this scene. Or am I miss something? > > But nothing stops you from calling it in memory_failure(), right? > > if (MF_COUNT_INCREASED not set) { > .... > ... > } else if(!HWPoisonHandable(p)) { > action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); > res = -EBUSY; > goto unlock_mutex; > } Yes, I somewhat misread the proposed code. Thanks for clarifying. :) > >> BTW: IIRC, LRU isn't set on huge_zero_page. So the origin HWPoisonHandlable can already filter out this page. > > I would rather have it as a explicit check than buried in that kind of > assumption. > > But after all, Naoya's suggestion might just be better and more focused. > >