Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386172

Re: [PATCH 01/28] mm, page_alloc: Only check PageCompound for high-order pages

From Vlastimil Babka <vbabka@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH 01/28] mm, page_alloc: Only check PageCompound for high-order pages
Date 2016-04-25 11:40 +0200
Message-ID <rrL9L-3t5-9@gated-at.bofh.it> (permalink)
References <ro7LB-hc-17@gated-at.bofh.it> <ro7LB-hc-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 04/15/2016 10:58 AM, Mel Gorman wrote:
> order-0 pages by definition cannot be compound so avoid the check in the
> fast path for those pages.
>
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

Suggestion to improve below:

> ---
>   mm/page_alloc.c | 25 +++++++++++++++++--------
>   1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 59de90d5d3a3..5d205bcfe10d 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1024,24 +1024,33 @@ void __meminit reserve_bootmem_region(unsigned long start, unsigned long end)
>
>   static bool free_pages_prepare(struct page *page, unsigned int order)
>   {
> -	bool compound = PageCompound(page);
> -	int i, bad = 0;
> +	int bad = 0;
>
>   	VM_BUG_ON_PAGE(PageTail(page), page);
> -	VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
>
>   	trace_mm_page_free(page, order);
>   	kmemcheck_free_shadow(page, order);
>   	kasan_free_pages(page, order);
>
> +	/*
> +	 * Check tail pages before head page information is cleared to
> +	 * avoid checking PageCompound for order-0 pages.
> +	 */
> +	if (order) {

Sticking unlikely() here results in:

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-30 (-30)
function                                     old     new   delta
free_pages_prepare                           771     741     -30

And from brief comparison of disassembly it really seems it's moved the 
compound handling towards the end of the function, which should be nicer 
for the instruction cache, branch prediction etc. And since this series 
is about microoptimization, I think the extra step is worth it.

> +		bool compound = PageCompound(page);
> +		int i;
> +
> +		VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
> +
> +		for (i = 1; i < (1 << order); i++) {
> +			if (compound)
> +				bad += free_tail_pages_check(page, page + i);
> +			bad += free_pages_check(page + i);
> +		}
> +	}
>   	if (PageAnon(page))
>   		page->mapping = NULL;
>   	bad += free_pages_check(page);
> -	for (i = 1; i < (1 << order); i++) {
> -		if (compound)
> -			bad += free_tail_pages_check(page, page + i);
> -		bad += free_pages_check(page + i);
> -	}
>   	if (bad)
>   		return false;
>
>

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH 01/28] mm, page_alloc: Only check PageCompound for  high-order pages Vlastimil Babka <vbabka@suse.cz> - 2016-04-25 11:40 +0200
  Re: [PATCH 01/28] mm, page_alloc: Only check PageCompound for  high-order pages Mel Gorman <mgorman@techsingularity.net> - 2016-04-26 12:40 +0200
    Re: [PATCH 01/28] mm, page_alloc: Only check PageCompound for  high-order pages Vlastimil Babka <vbabka@suse.cz> - 2016-04-26 13:30 +0200

csiph-web