On Wed, 5 Mar 2025 12:25:51 -0800 Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote: > On Wed, Mar 05, 2025 at 10:15:56AM -0800, SeongJae Park wrote: > > To reduce redundant open-coded checks of CONFIG_MEMORY_FAILURE and > > MADV_{HWPOISON,SOFT_OFFLINE} in madvise_[un]lock(), is_memory_failure() > > has introduced. madvise_do_behavior() is still doing the same > > open-coded check, though. Use is_memory_failure() instead. > > > > Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> > > --- > > mm/madvise.c | 4 +--- > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > diff --git a/mm/madvise.c b/mm/madvise.c > > index 388dc289b5d1..dbc8fec05cc6 100644 > > --- a/mm/madvise.c > > +++ b/mm/madvise.c > > @@ -1640,10 +1640,8 @@ static int madvise_do_behavior(struct mm_struct *mm, > > unsigned long end; > > int error; > > > > -#ifdef CONFIG_MEMORY_FAILURE > > - if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE) > > + if (is_memory_failure(behavior)) > > return madvise_inject_error(behavior, start, start + len_in); > > You might want to either define empty madvise_inject_error() for > !CONFIG_MEMORY_FAILURE or keep CONFIG_MEMORY_FAILURE here. Good catch. I confirmed build fails when !CONFIG_MEMORY_FAILURE. I will define empty madvise_inject_error(). > > > -#endif > > start = untagged_addr_remote(mm, start); > > end = start + len; > > > > -- > > 2.39.5