Re: [PATCH 1/2] mm, memory_hotplug: do not fail offlining too early

From: Michal Hocko
Date: Tue Sep 05 2017 - 03:15:39 EST


On Tue 05-09-17 11:59:36, Anshuman Khandual wrote:
[...]
> > @@ -1634,43 +1634,25 @@ static int __ref __offline_pages(unsigned long start_pfn,
> >
> > pfn = start_pfn;
> > expire = jiffies + timeout;
> > - drain = 0;
> > - retry_max = 5;
> > repeat:
> > /* start memory hot removal */
> > - ret = -EAGAIN;
> > + ret = -EBUSY;
> > if (time_after(jiffies, expire))
> > goto failed_removal;
> > ret = -EINTR;
> > if (signal_pending(current))
> > goto failed_removal;
> > - ret = 0;
> > - if (drain) {
> > - lru_add_drain_all_cpuslocked();
> > - cond_resched();
> > - drain_all_pages(zone);
> > - }
>
> Why we had this condition before that only when we fail in migration
> later in do_migrate_range function, drain the lru lists in the next
> attempt. Why not from the first attempt itself ? Just being curious.

I can only guess but draining used to invoke IPIs and that is really
costly so an optimistic attempt could try without draining and do that
only if the migration fails. Now that we have it all done in WQ context
there shouldn't be any reason to optimize for draining.
--
Michal Hocko
SUSE Labs