Message ID | 1594107889-32228-11-git-send-email-iamjoonsoo.kim@lge.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | clean-up the migration target allocation functions | expand |
On Tue 07-07-20 16:44:48, Joonsoo Kim wrote: > From: Joonsoo Kim <iamjoonsoo.kim@lge.com> > > There is a well-defined standard migration target callback. Use it > directly. > > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> > --- > mm/memory-failure.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 609d42b6..3b89804 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) > } > EXPORT_SYMBOL(unpoison_memory); > > -static struct page *new_page(struct page *p, unsigned long private) > -{ > - struct migration_target_control mtc = { > - .nid = page_to_nid(p), > - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > - }; > - > - return alloc_migration_target(p, (unsigned long)&mtc); > -} > - > /* > * Safely get reference count of an arbitrary page. > * Returns 0 for a free page, -EIO for a zero refcount page > @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) > const char *msg_page[] = {"page", "hugepage"}; > bool huge = PageHuge(page); > LIST_HEAD(pagelist); > + struct migration_target_control mtc = { > + .nid = NUMA_NO_NODE, > + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > + }; Is NUMA_NO_NODE really intended here? The original code has preferred to stay on the same node. If this is intentional then the changelog should be explicit about that. > > /* > * Check PageHWPoison again inside page lock because PageHWPoison > @@ -1829,8 +1823,8 @@ static int __soft_offline_page(struct page *page) > } > > if (isolate_page(hpage, &pagelist)) { > - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, > - MIGRATE_SYNC, MR_MEMORY_FAILURE); > + ret = migrate_pages(&pagelist, alloc_migration_target, NULL, > + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); > if (!ret) { > bool release = !huge; > > -- > 2.7.4 >
On 7/7/20 9:44 AM, js1304@gmail.com wrote: > From: Joonsoo Kim <iamjoonsoo.kim@lge.com> > > There is a well-defined standard migration target callback. Use it > directly. > > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> > --- > mm/memory-failure.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 609d42b6..3b89804 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) > } > EXPORT_SYMBOL(unpoison_memory); > > -static struct page *new_page(struct page *p, unsigned long private) > -{ > - struct migration_target_control mtc = { > - .nid = page_to_nid(p), > - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > - }; > - > - return alloc_migration_target(p, (unsigned long)&mtc); > -} > - > /* > * Safely get reference count of an arbitrary page. > * Returns 0 for a free page, -EIO for a zero refcount page > @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) > const char *msg_page[] = {"page", "hugepage"}; > bool huge = PageHuge(page); > LIST_HEAD(pagelist); > + struct migration_target_control mtc = { > + .nid = NUMA_NO_NODE, > + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > + }; > > /* > * Check PageHWPoison again inside page lock because PageHWPoison > @@ -1829,8 +1823,8 @@ static int __soft_offline_page(struct page *page) > } > > if (isolate_page(hpage, &pagelist)) { > - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, > - MIGRATE_SYNC, MR_MEMORY_FAILURE); > + ret = migrate_pages(&pagelist, alloc_migration_target, NULL, > + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); > if (!ret) { > bool release = !huge; > >
On 7/7/20 1:48 PM, Michal Hocko wrote: > On Tue 07-07-20 16:44:48, Joonsoo Kim wrote: >> From: Joonsoo Kim <iamjoonsoo.kim@lge.com> >> >> There is a well-defined standard migration target callback. Use it >> directly. >> >> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> >> --- >> mm/memory-failure.c | 18 ++++++------------ >> 1 file changed, 6 insertions(+), 12 deletions(-) >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index 609d42b6..3b89804 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) >> } >> EXPORT_SYMBOL(unpoison_memory); >> >> -static struct page *new_page(struct page *p, unsigned long private) >> -{ >> - struct migration_target_control mtc = { >> - .nid = page_to_nid(p), >> - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, >> - }; >> - >> - return alloc_migration_target(p, (unsigned long)&mtc); >> -} >> - >> /* >> * Safely get reference count of an arbitrary page. >> * Returns 0 for a free page, -EIO for a zero refcount page >> @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) >> const char *msg_page[] = {"page", "hugepage"}; >> bool huge = PageHuge(page); >> LIST_HEAD(pagelist); >> + struct migration_target_control mtc = { >> + .nid = NUMA_NO_NODE, >> + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, >> + }; > > Is NUMA_NO_NODE really intended here? The original code has preferred to > stay on the same node. The alloc_migration_target() interprets NUMA_NO_NODE as a request to call page_to_nid(), so we don't need these thin wrappers that do just that. I have suggested this in v3 review and it's mentioned in 06/11. > If this is intentional then the changelog should > be explicit about that. > >> >> /* >> * Check PageHWPoison again inside page lock because PageHWPoison >> @@ -1829,8 +1823,8 @@ static int __soft_offline_page(struct page *page) >> } >> >> if (isolate_page(hpage, &pagelist)) { >> - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, >> - MIGRATE_SYNC, MR_MEMORY_FAILURE); >> + ret = migrate_pages(&pagelist, alloc_migration_target, NULL, >> + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); >> if (!ret) { >> bool release = !huge; >> >> -- >> 2.7.4 >> >
On Tue 07-07-20 17:03:50, Vlastimil Babka wrote: > On 7/7/20 1:48 PM, Michal Hocko wrote: > > On Tue 07-07-20 16:44:48, Joonsoo Kim wrote: > >> From: Joonsoo Kim <iamjoonsoo.kim@lge.com> > >> > >> There is a well-defined standard migration target callback. Use it > >> directly. > >> > >> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> > >> --- > >> mm/memory-failure.c | 18 ++++++------------ > >> 1 file changed, 6 insertions(+), 12 deletions(-) > >> > >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c > >> index 609d42b6..3b89804 100644 > >> --- a/mm/memory-failure.c > >> +++ b/mm/memory-failure.c > >> @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) > >> } > >> EXPORT_SYMBOL(unpoison_memory); > >> > >> -static struct page *new_page(struct page *p, unsigned long private) > >> -{ > >> - struct migration_target_control mtc = { > >> - .nid = page_to_nid(p), > >> - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > >> - }; > >> - > >> - return alloc_migration_target(p, (unsigned long)&mtc); > >> -} > >> - > >> /* > >> * Safely get reference count of an arbitrary page. > >> * Returns 0 for a free page, -EIO for a zero refcount page > >> @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) > >> const char *msg_page[] = {"page", "hugepage"}; > >> bool huge = PageHuge(page); > >> LIST_HEAD(pagelist); > >> + struct migration_target_control mtc = { > >> + .nid = NUMA_NO_NODE, > >> + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > >> + }; > > > > Is NUMA_NO_NODE really intended here? The original code has preferred to > > stay on the same node. > > The alloc_migration_target() interprets NUMA_NO_NODE as a request to call > page_to_nid(), so we don't need these thin wrappers that do just that. I have > suggested this in v3 review and it's mentioned in 06/11. Ohh, right. I just lost that piece of information on the way. It wouldn't hurt to keep page_to_nid here for readability though.
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 609d42b6..3b89804 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) } EXPORT_SYMBOL(unpoison_memory); -static struct page *new_page(struct page *p, unsigned long private) -{ - struct migration_target_control mtc = { - .nid = page_to_nid(p), - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, - }; - - return alloc_migration_target(p, (unsigned long)&mtc); -} - /* * Safely get reference count of an arbitrary page. * Returns 0 for a free page, -EIO for a zero refcount page @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) const char *msg_page[] = {"page", "hugepage"}; bool huge = PageHuge(page); LIST_HEAD(pagelist); + struct migration_target_control mtc = { + .nid = NUMA_NO_NODE, + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; /* * Check PageHWPoison again inside page lock because PageHWPoison @@ -1829,8 +1823,8 @@ static int __soft_offline_page(struct page *page) } if (isolate_page(hpage, &pagelist)) { - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, - MIGRATE_SYNC, MR_MEMORY_FAILURE); + ret = migrate_pages(&pagelist, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (!ret) { bool release = !huge;