From: Michal Hocko <mhocko@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>,
linux-mm@kvack.org, Mike Kravetz <mike.kravetz@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
David Rientjes <rientjes@google.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Mel Gorman <mgorman@techsingularity.net>,
Mike Rapoport <rppt@linux.ibm.com>,
Dan Williams <dan.j.williams@intel.com>,
Pavel Tatashin <pavel.tatashin@microsoft.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/page_alloc: Make alloc_gigantic_page() available for general use
Date: Wed, 16 Oct 2019 13:08:31 +0200 [thread overview]
Message-ID: <20191016110831.GV317@dhcp22.suse.cz> (raw)
In-Reply-To: <679b5c66-8f1b-ec4d-64dd-13fbc440917d@redhat.com>
On Wed 16-10-19 10:56:16, David Hildenbrand wrote:
> On 16.10.19 10:51, Michal Hocko wrote:
> > On Wed 16-10-19 10:08:21, David Hildenbrand wrote:
> > > On 16.10.19 09:34, Anshuman Khandual wrote:
> > [...]
> > > > +static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn,
> > > > + unsigned long nr_pages)
> > > > +{
> > > > + unsigned long i, end_pfn = start_pfn + nr_pages;
> > > > + struct page *page;
> > > > +
> > > > + for (i = start_pfn; i < end_pfn; i++) {
> > > > + page = pfn_to_online_page(i);
> > > > + if (!page)
> > > > + return false;
> > > > +
> > > > + if (page_zone(page) != z)
> > > > + return false;
> > > > +
> > > > + if (PageReserved(page))
> > > > + return false;
> > > > +
> > > > + if (page_count(page) > 0)
> > > > + return false;
> > > > +
> > > > + if (PageHuge(page))
> > > > + return false;
> > > > + }
> > >
> > > We might still try to allocate a lot of ranges that contain unmovable data
> > > (we could avoid isolating a lot of page blocks in the first place). I'd love
> > > to see something like pfn_range_movable() (similar, but different to
> > > is_mem_section_removable(), which uses has_unmovable_pages()).
> >
> > Just to make sure I understand. Do you want has_unmovable_pages to be
> > called inside pfn_range_valid_contig?
>
> I think this requires more thought, as has_unmovable_pages() works on
> pageblocks only AFAIK. If you try to allocate < MAX_ORDER - 1, you could get
> a lot of false positives.
>
> E.g., if a free "MAX_ORDER - 1" page spans two pageblocks and you only test
> the second pageblock, you might detect "unmovable" if not taking proper care
> of the "bigger" free page. (alloc_contig_range() properly works around that
> issue)
OK, I see your point. You are right that false positives are possible. I
would deal with those in a separate patch though.
> > [...]
> > > > +struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask,
> > > > + int nid, nodemask_t *nodemask)
> > > > +{
> > > > + unsigned long ret, pfn, flags;
> > > > + struct zonelist *zonelist;
> > > > + struct zone *zone;
> > > > + struct zoneref *z;
> > > > +
> > > > + zonelist = node_zonelist(nid, gfp_mask);
> > > > + for_each_zone_zonelist_nodemask(zone, z, zonelist,
> > > > + gfp_zone(gfp_mask), nodemask) {
> > >
> > > One important part is to never use the MOVABLE zone here (otherwise
> > > unmovable data would end up on the movable zone). But I guess the caller is
> > > responsible for that (not pass GFP_MOVABLE) like gigantic pages do.
> >
> > Well, if the caller uses GFP_MOVABLE then the movability should be
> > implemented in some form. If that is not the case then it is a bug on
> > the caller behalf.
> >
> > > > + spin_lock_irqsave(&zone->lock, flags);
> > > > +
> > > > + pfn = ALIGN(zone->zone_start_pfn, nr_pages);
> > >
> > > This alignment does not make too much sense when allowing passing in !power
> > > of two orders. Maybe the caller should specify the requested alignment
> > > instead? Or should we enforce this to be aligned to make our life easier for
> > > now?
> >
> > Are there any usecases that would require than the page alignment?
>
> Gigantic pages have to be aligned AFAIK.
Aligned to what? I do not see any guarantee like that in the existing
code.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-10-16 11:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:34 Anshuman Khandual
2019-10-16 8:08 ` David Hildenbrand
2019-10-16 8:40 ` David Hildenbrand
2019-10-16 8:51 ` Michal Hocko
2019-10-16 8:56 ` David Hildenbrand
2019-10-16 11:08 ` Michal Hocko [this message]
2019-10-16 11:10 ` David Hildenbrand
2019-10-16 11:49 ` Michal Hocko
2019-10-16 8:58 ` Michal Hocko
2019-10-16 10:28 ` Anshuman Khandual
2019-10-16 10:33 ` Michal Hocko
2019-10-16 10:41 ` 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=20191016110831.GV317@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=dan.j.williams@intel.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mike.kravetz@oracle.com \
--cc=osalvador@suse.de \
--cc=pavel.tatashin@microsoft.com \
--cc=rientjes@google.com \
--cc=rppt@linux.ibm.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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