linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Joonsoo Kim <js1304@gmail.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Rientjes <rientjes@google.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	kernel@pengutronix.de, patchwork-lst@pengutronix.de
Subject: Re: [PATCH] mm/page_isolation: let caller take the zone lock for test_pages_isolated
Date: Thu, 17 Mar 2016 18:33:40 +0100	[thread overview]
Message-ID: <1458236020.18134.17.camel@pengutronix.de> (raw)
In-Reply-To: <CAAmzW4PnnDSDGdMHY98GgkL7LuXvk=6=_MQGnWy6HJr_qax8RA@mail.gmail.com>

Am Freitag, den 18.03.2016, 02:18 +0900 schrieb Joonsoo Kim:
> 2016-03-17 1:49 GMT+09:00 Lucas Stach <l.stach@pengutronix.de>:
> > This fixes an annoying race in the CMA code leading to lots of "PFNs busy"
> > messages when CMA is used concurrently. This is harmless normally as CMA
> > will just retry the allocation at a different place, but it might lead to
> > increased fragmentation of the CMA area as well as failing allocations
> > when CMA is under memory pressure.
> >
> > The issue is that test_pages_isolated checks if the range is free by
> > checking that all pages in the range are buddy pages. For this to work
> > the start pfn needs to be aligned to the higher order buddy page
> > including the start pfn if there is any.
> >
> > This is not a problem for the memory hotplug code, as it always offlines
> > whole pageblocks, but CMA may want to isolate a smaller range. So for
> > the check to work correctly it down-aligns the start pfn to the higher
> > order buddy page. As the zone is not yet locked at that point a
> > concurrent page free might coalesce the pages to be checked into an
> > even bigger buddy page, causing the check to fail, while all pages are
> > in fact buddy pages.
> >
> > By moving the zone locking to the caller of the test function, it's
> > possible to do it before CMA tries to find the proper start page and stop
> > any concurrent page coalescing to happen until the check is finished.
> 
> I think that this patch cannot prevent the same race on
> isolate_freepages_range(). If buddy merging happens after we
> passed test_pages_isolated(), isolate_freepages_range() cannot see
> buddy page and will fail.
> 
Your analysis seems correct. I'll fix this patch to hold the zone lock
across isolate_freepages_range.

Thanks,
Lucas


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2016-03-17 17:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 16:49 [PATCH] mm/page_isolation: let caller take the zone lock for test_pages_isolated Lucas Stach
2016-03-17 17:18 ` Joonsoo Kim
2016-03-17 17:33   ` Lucas Stach [this message]

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=1458236020.18134.17.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=js1304@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=patchwork-lst@pengutronix.de \
    --cc=rientjes@google.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).