From: Vlastimil Babka <vbabka@suse.cz>
To: Michal Hocko <mhocko@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@suse.de>,
Zhang Yanfei <zhangyanfei@cn.fujitsu.com>,
Minchan Kim <minchan@kernel.org>,
David Rientjes <rientjes@google.com>,
Rik van Riel <riel@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH V4 1/4] mm: set page->pfmemalloc in prep_new_page()
Date: Tue, 06 Jan 2015 22:10:55 +0100 [thread overview]
Message-ID: <54AC4F5F.90306@suse.cz> (raw)
In-Reply-To: <20150106143008.GA20860@dhcp22.suse.cz>
On 01/06/2015 03:30 PM, Michal Hocko wrote:
> On Mon 05-01-15 18:17:40, Vlastimil Babka wrote:
>> The function prep_new_page() sets almost everything in the struct page of the
>> page being allocated, except page->pfmemalloc. This is not obvious and has at
>> least once led to a bug where page->pfmemalloc was forgotten to be set
>> correctly, see commit 8fb74b9fb2b1 ("mm: compaction: partially revert capture
>> of suitable high-order page").
>>
>> This patch moves the pfmemalloc setting to prep_new_page(), which means it
>> needs to gain alloc_flags parameter. The call to prep_new_page is moved from
>> buffered_rmqueue() to get_page_from_freelist(), which also leads to simpler
>> code. An obsolete comment for buffered_rmqueue() is replaced.
>>
>> In addition to better maintainability there is a small reduction of code and
>> stack usage for get_page_from_freelist(), which inlines the other functions
>> involved.
>>
>> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-145 (-145)
>> function old new delta
>> get_page_from_freelist 2670 2525 -145
>>
>> Stack usage is reduced from 184 to 168 bytes.
>>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> Cc: Mel Gorman <mgorman@suse.de>
>> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>> Cc: Minchan Kim <minchan@kernel.org>
>> Cc: David Rientjes <rientjes@google.com>
>> Cc: Rik van Riel <riel@redhat.com>
>> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>> Cc: Johannes Weiner <hannes@cmpxchg.org>
>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> Cc: Michal Hocko <mhocko@suse.cz>
>
> get_page_from_freelist has grown too hairy. I agree that it is tiny less
> confusing now because we are not breaking out of the loop in the
> successful case.
Well, we are returning instead. So there's no more code to follow by anyone
reading the function.
> Acked-by: Michal Hocko <mhocko@suse.cz>
>
> [...]
>> @@ -2177,25 +2181,16 @@ zonelist_scan:
>> try_this_zone:
>> page = buffered_rmqueue(preferred_zone, zone, order,
>> gfp_mask, migratetype);
>> - if (page)
>> - break;
>> + if (page) {
>> + if (prep_new_page(page, order, gfp_mask, alloc_flags))
>> + goto try_this_zone;
>> + return page;
>> + }
>
> I would probably liked `do {} while ()' more because it wouldn't use the
> goto, but this is up to you:
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1bb65e6f48dd..1682d766cb8e 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2175,10 +2175,11 @@ zonelist_scan:
> }
>
> try_this_zone:
> - page = buffered_rmqueue(preferred_zone, zone, order,
> + do {
> + page = buffered_rmqueue(preferred_zone, zone, order,
> gfp_mask, migratetype);
> - if (page)
> - break;
> + } while (page && prep_new_page(page, order, gfp_mask,
> + alloc_flags));
Hm but here we wouldn't return page on success. I wonder if you overlooked the
return, hence your "not breaking out of the loop" remark?
> this_zone_full:
> if (IS_ENABLED(CONFIG_NUMA) && zlc_active)
> zlc_mark_zone_full(zonelist, z);
>
> [...]
>
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Vlastimil Babka <vbabka@suse.cz>
To: Michal Hocko <mhocko@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@suse.de>,
Zhang Yanfei <zhangyanfei@cn.fujitsu.com>,
Minchan Kim <minchan@kernel.org>,
David Rientjes <rientjes@google.com>,
Rik van Riel <riel@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH V4 1/4] mm: set page->pfmemalloc in prep_new_page()
Date: Tue, 06 Jan 2015 22:10:55 +0100 [thread overview]
Message-ID: <54AC4F5F.90306@suse.cz> (raw)
In-Reply-To: <20150106143008.GA20860@dhcp22.suse.cz>
On 01/06/2015 03:30 PM, Michal Hocko wrote:
> On Mon 05-01-15 18:17:40, Vlastimil Babka wrote:
>> The function prep_new_page() sets almost everything in the struct page of the
>> page being allocated, except page->pfmemalloc. This is not obvious and has at
>> least once led to a bug where page->pfmemalloc was forgotten to be set
>> correctly, see commit 8fb74b9fb2b1 ("mm: compaction: partially revert capture
>> of suitable high-order page").
>>
>> This patch moves the pfmemalloc setting to prep_new_page(), which means it
>> needs to gain alloc_flags parameter. The call to prep_new_page is moved from
>> buffered_rmqueue() to get_page_from_freelist(), which also leads to simpler
>> code. An obsolete comment for buffered_rmqueue() is replaced.
>>
>> In addition to better maintainability there is a small reduction of code and
>> stack usage for get_page_from_freelist(), which inlines the other functions
>> involved.
>>
>> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-145 (-145)
>> function old new delta
>> get_page_from_freelist 2670 2525 -145
>>
>> Stack usage is reduced from 184 to 168 bytes.
>>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> Cc: Mel Gorman <mgorman@suse.de>
>> Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
>> Cc: Minchan Kim <minchan@kernel.org>
>> Cc: David Rientjes <rientjes@google.com>
>> Cc: Rik van Riel <riel@redhat.com>
>> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>> Cc: Johannes Weiner <hannes@cmpxchg.org>
>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> Cc: Michal Hocko <mhocko@suse.cz>
>
> get_page_from_freelist has grown too hairy. I agree that it is tiny less
> confusing now because we are not breaking out of the loop in the
> successful case.
Well, we are returning instead. So there's no more code to follow by anyone
reading the function.
> Acked-by: Michal Hocko <mhocko@suse.cz>
>
> [...]
>> @@ -2177,25 +2181,16 @@ zonelist_scan:
>> try_this_zone:
>> page = buffered_rmqueue(preferred_zone, zone, order,
>> gfp_mask, migratetype);
>> - if (page)
>> - break;
>> + if (page) {
>> + if (prep_new_page(page, order, gfp_mask, alloc_flags))
>> + goto try_this_zone;
>> + return page;
>> + }
>
> I would probably liked `do {} while ()' more because it wouldn't use the
> goto, but this is up to you:
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1bb65e6f48dd..1682d766cb8e 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2175,10 +2175,11 @@ zonelist_scan:
> }
>
> try_this_zone:
> - page = buffered_rmqueue(preferred_zone, zone, order,
> + do {
> + page = buffered_rmqueue(preferred_zone, zone, order,
> gfp_mask, migratetype);
> - if (page)
> - break;
> + } while (page && prep_new_page(page, order, gfp_mask,
> + alloc_flags));
Hm but here we wouldn't return page on success. I wonder if you overlooked the
return, hence your "not breaking out of the loop" remark?
> this_zone_full:
> if (IS_ENABLED(CONFIG_NUMA) && zlc_active)
> zlc_mark_zone_full(zonelist, z);
>
> [...]
>
next prev parent reply other threads:[~2015-01-06 21:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 17:17 [PATCH V4 0/4] Reducing parameters of alloc_pages* family of functions Vlastimil Babka
2015-01-05 17:17 ` Vlastimil Babka
2015-01-05 17:17 ` [PATCH V4 1/4] mm: set page->pfmemalloc in prep_new_page() Vlastimil Babka
2015-01-05 17:17 ` Vlastimil Babka
2015-01-06 14:30 ` Michal Hocko
2015-01-06 14:30 ` Michal Hocko
2015-01-06 21:10 ` Vlastimil Babka [this message]
2015-01-06 21:10 ` Vlastimil Babka
2015-01-06 21:44 ` Michal Hocko
2015-01-06 21:44 ` Michal Hocko
2015-01-07 9:36 ` Vlastimil Babka
2015-01-07 9:36 ` Vlastimil Babka
2015-01-07 10:54 ` Michal Hocko
2015-01-07 10:54 ` Michal Hocko
2015-01-05 17:17 ` [PATCH V4 2/4] mm, page_alloc: reduce number of alloc_pages* functions' parameters Vlastimil Babka
2015-01-05 17:17 ` Vlastimil Babka
2015-01-06 14:45 ` Michal Hocko
2015-01-06 14:45 ` Michal Hocko
2015-01-05 17:17 ` [PATCH V4 3/4] mm: reduce try_to_compact_pages parameters Vlastimil Babka
2015-01-05 17:17 ` Vlastimil Babka
2015-01-06 14:53 ` Michal Hocko
2015-01-06 14:53 ` Michal Hocko
2015-01-06 14:57 ` Michal Hocko
2015-01-06 14:57 ` Michal Hocko
2015-01-07 9:11 ` Vlastimil Babka
2015-01-07 9:11 ` Vlastimil Babka
2015-01-07 9:18 ` Michal Hocko
2015-01-07 9:18 ` Michal Hocko
2015-01-07 9:21 ` Vlastimil Babka
2015-01-07 9:21 ` Vlastimil Babka
2015-01-05 17:17 ` [PATCH V4 4/4] mm: microoptimize zonelist operations Vlastimil Babka
2015-01-05 17:17 ` Vlastimil Babka
2015-01-06 15:09 ` Michal Hocko
2015-01-06 15:09 ` Michal Hocko
2015-01-07 9:15 ` Vlastimil Babka
2015-01-07 9:15 ` Vlastimil Babka
2015-01-07 10:57 ` Michal Hocko
2015-01-07 10:57 ` Michal Hocko
2015-01-07 11:17 ` Mel Gorman
2015-01-07 11:17 ` Mel Gorman
2015-01-07 14:47 ` Michal Hocko
2015-01-07 14:47 ` Michal Hocko
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=54AC4F5F.90306@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
--cc=zhangyanfei@cn.fujitsu.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.