On Fri, Sep 24, 2021 at 09:09:54PM +0800, Shiyang Ruan wrote: > memory_failure_dev_pagemap code is a bit complex before introduce RMAP > feature for fsdax. So it is needed to factor some helper functions to > simplify these code. > > Signed-off-by: Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> > --- > mm/memory-failure.c | 140 ++++++++++++++++++++++++-------------------- > 1 file changed, 76 insertions(+), 64 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 54879c339024..8ff9b52823c0 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1430,6 +1430,79 @@ static int try_to_split_thp_page(struct page *page, const char *msg) > return 0; > } > > +static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn, > + struct address_space *mapping, pgoff_t index, int flags) > +{ > + struct to_kill *tk; > + unsigned long size = 0; > + > + list_for_each_entry(tk, to_kill, nd) > + if (tk->size_shift) > + size = max(size, 1UL << tk->size_shift); > + if (size) { Nit: an empty line here would be nice for readability. > + if (pgmap->type == MEMORY_DEVICE_PRIVATE) { > + /* > + * TODO: Handle HMM pages which may need coordination > + * with device-side memory. > + */ > + return -EBUSY; We've got rid of the HMM terminology for device private memory, so I'd reword this update the comment to follow that while you're at it. Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@xxxxxx>