From: Vlastimil Babka <vbabka@suse.cz>
To: Mel Gorman <mgorman@techsingularity.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Michal Hocko <mhocko@kernel.org>,
Jesper Dangaard Brouer <brouer@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH 2/2] mm/page_alloc: Allow high-order pages to be stored on the per-cpu lists
Date: Thu, 3 Jun 2021 15:04:50 +0200 [thread overview]
Message-ID: <7657abef-cc50-b6a1-3b6a-697d97a3d4e2@suse.cz> (raw)
In-Reply-To: <20210603123437.GW30378@techsingularity.net>
On 6/3/21 2:34 PM, Mel Gorman wrote:
>
>> > @@ -687,10 +687,53 @@ static void bad_page(struct page *page, const char *reason)
>> > add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
>> > }
>> >
>> > +static inline unsigned int order_to_pindex(int migratetype, int order)
>> > +{
>> > + int base = order;
>> > +
>> > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> > + if (order > PAGE_ALLOC_COSTLY_ORDER) {
>> > + VM_BUG_ON(order != pageblock_order);
>> > + base = PAGE_ALLOC_COSTLY_ORDER + 1;
>> > + }
>> > +#else
>> > + VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
>> > +#endif
>> > +
>> > + return (MIGRATE_PCPTYPES * base) + migratetype;
>> > +}
>> > +
>> > +static inline int pindex_to_order(unsigned int pindex)
>> > +{
>> > + int order = pindex / PAGE_ALLOC_COSTLY_ORDER;
>>
>> This seems wrong, shouldn't we divide by MIGRATE_PCPTYPES?
>> It just happens to be the same number, so testing won't flag this.
>>
>
> Whoops, yes, basic algebra says you're right so well spotted. If
> PAGE_ALLOC_COSTLY_ORDER ever changed for some reason, this would blow up.
>
> So this?
Yeah, great!
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index bbe05289b121..f1bed5b847ec 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -345,11 +345,11 @@ enum zone_watermarks {
> #define NR_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1 + NR_PCP_THP))
>
> /*
> - * Shift to encode migratetype in order in the least significant bits and
> - * migratetype in the higher bits.
> + * Shift to encode migratetype and order in the same integer, with order
> + * in the least significant bits.
> */
> -#define NR_PCP_ORDER_SHIFT 8
> -#define NR_PCP_ORDER_MASK ((1<<NR_PCP_ORDER_SHIFT) - 1)
> +#define NR_PCP_ORDER_WIDTH 8
> +#define NR_PCP_ORDER_MASK ((1<<NR_PCP_ORDER_WIDTH) - 1)
>
> #define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost)
> #define low_wmark_pages(z) (z->_watermark[WMARK_LOW] + z->watermark_boost)
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 49f3c7dcdfca..7be71f9ad9f0 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -694,7 +694,7 @@ static inline unsigned int order_to_pindex(int migratetype, int order)
>
> static inline int pindex_to_order(unsigned int pindex)
> {
> - int order = pindex / PAGE_ALLOC_COSTLY_ORDER;
> + int order = pindex / MIGRATE_PCPTYPES;
>
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> if (order > PAGE_ALLOC_COSTLY_ORDER) {
> @@ -1487,7 +1487,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,
> batch_free = count;
>
> order = pindex_to_order(pindex);
> - BUILD_BUG_ON(MAX_ORDER >= (1<<NR_PCP_ORDER_SHIFT));
> + BUILD_BUG_ON(MAX_ORDER >= (1<<NR_PCP_ORDER_WIDTH));
> do {
> page = list_last_entry(list, struct page, lru);
> /* must delete to avoid corrupting pcp list */
> @@ -1499,7 +1499,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,
> continue;
>
> /* Encode order with the migratetype */
> - page->index <<= NR_PCP_ORDER_SHIFT;
> + page->index <<= NR_PCP_ORDER_WIDTH;
> page->index |= order;
>
> list_add_tail(&page->lru, &head);
> @@ -1537,7 +1537,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,
>
> /* mt has been encoded with the order (see above) */
> order = mt & NR_PCP_ORDER_MASK;
> - mt >>= NR_PCP_ORDER_SHIFT;
> + mt >>= NR_PCP_ORDER_WIDTH;
>
> /* MIGRATE_ISOLATE page should not go to pcplists */
> VM_BUG_ON_PAGE(is_migrate_isolate(mt), page);
>
>
>
next prev parent reply other threads:[~2021-06-03 13:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 8:46 [PATCH 0/2] Allow high order pages to be stored on PCP Mel Gorman
2021-06-03 8:46 ` [PATCH 1/2] mm/page_alloc: Move free_the_page Mel Gorman
2021-06-03 11:12 ` Vlastimil Babka
2021-06-03 8:46 ` [PATCH 2/2] mm/page_alloc: Allow high-order pages to be stored on the per-cpu lists Mel Gorman
2021-06-03 11:12 ` Vlastimil Babka
2021-06-03 12:34 ` Mel Gorman
2021-06-03 13:04 ` Vlastimil Babka [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-06-03 14:22 [PATCH 0/2] Allow high order pages to be stored on PCP v2 Mel Gorman
2021-06-03 14:22 ` [PATCH 2/2] mm/page_alloc: Allow high-order pages to be stored on the per-cpu lists Mel Gorman
2021-06-09 18:30 ` Zi Yan
2021-06-10 11:18 ` Mel Gorman
2021-06-10 11:40 ` Zi Yan
2021-06-10 22:59 ` Andrew Morton
2021-06-11 0:38 ` Stephen Rothwell
2021-06-11 8:10 ` Mel Gorman
2021-06-11 8:34 ` Mel Gorman
2021-06-11 12:17 ` Zi Yan
2021-06-11 13:58 ` Mel Gorman
2021-05-31 12:04 [RFC PATCH 0/2] Allow high order pages to be stored on PCP Mel Gorman
2021-05-31 12:04 ` [PATCH 2/2] mm/page_alloc: Allow high-order pages to be stored on the per-cpu lists Mel Gorman
2021-05-31 15:23 ` Jesper Dangaard Brouer
2021-06-01 12:45 ` Mel Gorman
2021-06-02 13:53 ` Jesper Dangaard Brouer
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=7657abef-cc50-b6a1-3b6a-697d97a3d4e2@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=brouer@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.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;
as well as URLs for NNTP newsgroup(s).