On Fri, May 10, 2024 at 12:26:01AM -0600, Jane Chu wrote: > Move hwpoison_filter() higher up as there is no need to spend a lot > cycles only to find out later that the page is supposed to be skipped > for hwpoison handling. > > Signed-off-by: Jane Chu <jane.chu@xxxxxxxxxx> > --- > mm/memory-failure.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 62133c10fb51..2fa884d8b5a3 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -2236,6 +2236,13 @@ int memory_failure(unsigned long pfn, int flags) > goto unlock_mutex; > } > > + if (hwpoison_filter(p)) { > + if (flags & MF_COUNT_INCREASED) > + put_page(p); > + res = -EOPNOTSUPP; > + goto unlock_mutex; > + } Now, it is true that doing this might not be optimal for the reasons explained by Miaohe, but the whole hwpoison_filter() thing is only used by the hwpoison-inject code AFAICS, which is just for testing purposes, so I do not think there is any harm in lifting the check. But no real strong opinion here. -- Oscar Salvador SUSE Labs