linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Vlastimil Babka <vbabka@suse.cz>, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, Michal Hocko <mhocko@kernel.org>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Oscar Salvador <osalvador@suse.de>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH 7/9] mm, page_alloc: move draining pcplists to page isolation users
Date: Fri, 25 Sep 2020 12:39:47 +0200	[thread overview]
Message-ID: <678262d6-cb82-d78c-9738-db70ab01f6de@redhat.com> (raw)
In-Reply-To: <20200922143712.12048-8-vbabka@suse.cz>

On 22.09.20 16:37, Vlastimil Babka wrote:
> Currently, pcplists are drained during set_migratetype_isolate() which means
> once per pageblock processed start_isolate_page_range(). This is somewhat
> wasteful. Moreover, the callers might need different guarantees, and the
> draining is currently prone to races and does not guarantee that no page
> from isolated pageblock will end up on the pcplist after the drain.
> 
> Better guarantees are added by later patches and require explicit actions
> by page isolation users that need them. Thus it makes sense to move the
> current imperfect draining to the callers also as a preparation step.
> 
> Suggested-by: Pavel Tatashin <pasha.tatashin@soleen.com>

I would have guessed I suggested that one first as well :)

https://lkml.kernel.org/r/6ec66eb9-eeba-5076-af97-cef59ed5cbaa@redhat.com

(But honestly, I don't care :), just stumbled over it)

> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  mm/memory_hotplug.c | 11 ++++++-----
>  mm/page_alloc.c     |  2 ++
>  mm/page_isolation.c | 10 +++++-----
>  3 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 9db80ee29caa..08f729922e18 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1524,6 +1524,8 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
>  		goto failed_removal;
>  	}
>  
> +	drain_all_pages(zone);
> +
>  	arg.start_pfn = start_pfn;
>  	arg.nr_pages = nr_pages;
>  	node_states_check_changes_offline(nr_pages, zone, &arg);
> @@ -1574,11 +1576,10 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
>  		}
>  
>  		/*
> -		 * per-cpu pages are drained in start_isolate_page_range, but if
> -		 * there are still pages that are not free, make sure that we
> -		 * drain again, because when we isolated range we might
> -		 * have raced with another thread that was adding pages to pcp
> -		 * list.
> +		 * per-cpu pages are drained after start_isolate_page_range, but
> +		 * if there are still pages that are not free, make sure that we
> +		 * drain again, because when we isolated range we might have
> +		 * raced with another thread that was adding pages to pcp list.
>  		 *
>  		 * Forward progress should be still guaranteed because
>  		 * pages on the pcp list can only belong to MOVABLE_ZONE
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 901907799bdc..4e37bc3f6077 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8432,6 +8432,8 @@ int alloc_contig_range(unsigned long start, unsigned long end,
>  	if (ret)
>  		return ret;
>  
> +	drain_all_pages(cc.zone);
> +
>  	/*
>  	 * In case of -EBUSY, we'd like to know which page causes problem.
>  	 * So, just fall through. test_pages_isolated() has a tracepoint
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index abfe26ad59fd..57d8bc1e7760 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -49,7 +49,6 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_
>  
>  		__mod_zone_freepage_state(zone, -nr_pages, mt);
>  		spin_unlock_irqrestore(&zone->lock, flags);
> -		drain_all_pages(zone);
>  		return 0;
>  	}
>  
> @@ -167,11 +166,12 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages)
>   *
>   * Please note that there is no strong synchronization with the page allocator
>   * either. Pages might be freed while their page blocks are marked ISOLATED.
> - * In some cases pages might still end up on pcp lists and that would allow
> + * A call to drain_all_pages() after isolation can flush most of them. However
> + * in some cases pages might still end up on pcp lists and that would allow
>   * for their allocation even when they are in fact isolated already. Depending
> - * on how strong of a guarantee the caller needs drain_all_pages might be needed
> - * (e.g. __offline_pages will need to call it after check for isolated range for
> - * a next retry).
> + * on how strong of a guarantee the caller needs, further drain_all_pages()
> + * might be needed (e.g. __offline_pages will need to call it after check for
> + * isolated range for a next retry).
>   *
>   * Return: 0 on success and -EBUSY if any part of range cannot be isolated.
>   */
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2020-09-25 10:39 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 14:37 [PATCH 0/9] disable pcplists during memory offline Vlastimil Babka
2020-09-22 14:37 ` [PATCH 1/9] mm, page_alloc: clean up pageset high and batch update Vlastimil Babka
2020-09-25 10:18   ` David Hildenbrand
2020-10-05 12:03   ` Michal Hocko
2020-09-22 14:37 ` [PATCH 2/9] mm, page_alloc: calculate pageset high and batch once per zone Vlastimil Babka
2020-10-05 12:52   ` Michal Hocko
2020-10-06 22:04     ` Vlastimil Babka
2020-09-22 14:37 ` [PATCH 3/9] mm, page_alloc: remove setup_pageset() Vlastimil Babka
2020-09-25 10:19   ` David Hildenbrand
2020-10-05 12:59   ` Michal Hocko
2020-10-06 22:11     ` Vlastimil Babka
2020-09-22 14:37 ` [PATCH 4/9] mm, page_alloc: simplify pageset_update() Vlastimil Babka
2020-09-25 10:23   ` David Hildenbrand
2020-10-05 13:20   ` Michal Hocko
2020-09-22 14:37 ` [PATCH 5/9] mm, page_alloc: make per_cpu_pageset accessible only after init Vlastimil Babka
2020-09-25 10:25   ` David Hildenbrand
2020-10-05 13:24   ` Michal Hocko
2020-10-06 22:28     ` Vlastimil Babka
2020-09-22 14:37 ` [PATCH 6/9] mm, page_alloc: cache pageset high and batch in struct zone Vlastimil Babka
2020-09-25 10:34   ` David Hildenbrand
2020-10-06 22:31     ` Vlastimil Babka
2020-10-05 13:28   ` Michal Hocko
2020-10-06 22:34     ` Vlastimil Babka
2020-09-22 14:37 ` [PATCH 7/9] mm, page_alloc: move draining pcplists to page isolation users Vlastimil Babka
2020-09-25 10:39   ` David Hildenbrand [this message]
2020-10-05 13:57   ` Michal Hocko
2020-09-22 14:37 ` [PATCH 8/9] mm, page_alloc: drain all pcplists during memory offline Vlastimil Babka
2020-09-25 10:46   ` David Hildenbrand
2020-10-05 14:03     ` Michal Hocko
2020-09-22 14:37 ` [PATCH 9/9] mm, page_alloc: optionally disable pcplists during page isolation Vlastimil Babka
2020-09-25 10:53   ` David Hildenbrand
2020-09-25 10:54     ` David Hildenbrand
2020-09-25 11:10       ` Vlastimil Babka
2020-10-01  8:47         ` David Hildenbrand
2020-10-05 14:05         ` Michal Hocko
2020-10-05 14:22           ` Vlastimil Babka
2020-10-05 16:56             ` Michal Hocko
2020-10-06  8:34   ` Michal Hocko
2020-10-06  8:40     ` David Hildenbrand
2020-10-06 10:05       ` Michal Hocko
2020-09-22 17:15 ` [PATCH 0/9] disable pcplists during memory offline David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=678262d6-cb82-d78c-9738-db70ab01f6de@redhat.com \
    --to=david@redhat.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@soleen.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).