mm: page_alloc: Add unlikely for MAX_ORDER check
Subsystems (2)
PATCH 2/2 mm: page_alloc: Add unlikely for MAX_ORDER check
"order >= MAX_ORDER" case is occur rarely.
So I add unlikely for this check.
--- mm/page_alloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
mm/page_alloc.c +1 -1
@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,* be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ; }
Signature · 7 lines
1.7.0.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · SeungHun Lee
"order >=
MAX_ORDER" case is occur rarely.So I add unlikely for this check.
--- mm/page_alloc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)mm/page_alloc.c +0
-0
mm/page_alloc.c __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, · line 2413
Quoted 7 lines
mm/page_alloc.c +1
-1@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,* be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ;
I don't think this improve any performance because here is a slowpath. However I also don't find any issue to have this hint.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · SeungHun Lee
"order >=
MAX_ORDER" case is occur rarely.So I add unlikely for this check.
This needs your signed-off-by line.
When that's done:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
unlikely indeed makes this code more elegant, however, it's difficult to tell how much the performance will be improved.
Quoted 17 lines · David Rientjes
Quoted 3 lines · SeungHun Lee
"order >=
MAX_ORDER" case is occur rarely.So I add unlikely for this check.
This needs your signed-off-by line.
When that's done:
Acked-by David Rientjes <[email protected]>--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 1 line
Sent from my Android device with Gmail Plus. Please excuse my brevity.
mm/page_alloc.c __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, · line 2414
Quoted 13 lines · SeungHun Lee
mm/page_alloc.c +1
-1@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,* be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ; }
What problem is this patch solving? I can see doing this in hot paths, or places where the compiler is known to be generating bad or suboptimal code. but, this costs me 512 bytes of text size:
898384 Jul 29 15:40 mm/page_alloc.o.nothing
898896 Jul 29 15:40 mm/page_alloc.o.unlikely
I really don't think we should be adding these without having _concrete_ reasons for it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 19 lines · Dave Hansen
mm/page_alloc.c __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, · line 2414
Quoted 13 lines · SeungHun Lee
mm/page_alloc.c +1
-1@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,* be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ; }What problem is this patch solving? I can see doing this in hot paths, or places where the compiler is known to be generating bad or suboptimal code. but, this costs me 512 bytes of text size:
Quoted 2 lines
898384 Jul 29 15:40
mm/page_alloc.o.nothing
898896 Jul 29 15:40mm/page_alloc.o.unlikely
I took a look at this on my system.
With gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5):
-rw-rw-r-- 1 cody cody 841160 Jul 29 16:47 unlikely/mm/page_alloc.o -rw-rw-r-- 1 cody cody 840584 Jul 29 16:59 normal/mm/page_alloc.o
text data bss dec hex filename 33799 1414 184 35397 8a45 unlikely/mm/page_alloc.o 33799 1414 184 35397 8a45 normal/mm/page_alloc.o
Well, where are are those extra bytes coming from, then?
Using readelf -S + git diff --no-index --word-diff shows:
.debug_info shrinks from 1e991 to 1e98f
.rela.debug_info shrinks from 33a80 to 33a68
.debug_loc grows from 15e1d to 15ecb .rela.debug_loc grows from 26f40 to 270f0 .debug_line grows from 038eb to 038ed
.debug_str shrinks from 0adb6 to 0adb2
The sizes of all other sections are unchanged.
Also: comparing vmlinux sizes:
-rwxrwxr-x 1 cody cody 94121230 Jul 29 17:00 normal/vmlinux -rwxrwxr-x 1 cody cody 94121294 Jul 29 16:51 unlikely/vmlinux
And the bzImage sizes:
-rw-rw-r-- 1 cody cody 2942240 Jul 29 16:51 unlikely/arch/x86/boot/bzImage -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:00 normal/arch/x86/boot/bzImage
I build this kernel with debug info built in though, what happens when it is removed?
-rwxrwxr-x 1 cody cody 16392454 Jul 29 17:33 normal/vmlinux -rwxrwxr-x 1 cody cody 16392454 Jul 29 17:33 unlikely/vmlinux
-rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 normal/arch/x86/boot/bzImage -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 unlikely/arch/x86/boot/bzImage
So, it looks like the only difference in size due to this patch is in the debug info.
Quoted 2 lines
I really don't think we should be adding these without having _concrete_ reasons for it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 23 lines · Cody P Schafer
Quoted 22 lines · Dave Hansen
Quoted 13 lines · SeungHun Lee
mm/page_alloc.c +1
-1@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsignedint order, * be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ;Quoted 1 line
}What problem is this patch solving? I can see doing this in hot paths, or places where the compiler is known to be generating bad or suboptimal code. but, this costs me 512 bytes of text size:
898384 Jul 29 15:40
mm/page_alloc.o.nothing
898896 Jul 29 15:40mm/page_alloc.o.unlikely
[...]
Review
Quoted 3 lines
(quoted diff) +0
-2-rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 normal/arch/x86/boot/bzImage -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 unlikely/arch/x86/boot/bzImage
So I screwed this last one up and didn't reapply/unapply the patch, so they probably are actually different sizes. I'll run a build and check tomorrow.
Quoted 9 lines
Quoted 2 lines
I really don't think we should be adding these without having _concrete_ reasons for it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 60 lines · Cody P Schafer
Quoted 20 lines · Dave Hansen
Quoted 13 lines · SeungHun Lee
mm/page_alloc.c +1
-1@@ -2408,7 +2408,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsignedint order, * be using allocators in order of preference for an area that is * too large. */ -if (order >=MAX_ORDER ) { +if (unlikely (order >=MAX_ORDER )) {WARN_ON_ONCE (!(gfp_mask & __GFP_NOWARN));return NULL ;Quoted 1 line
}What problem is this patch solving? I can see doing this in hot paths, or places where the compiler is known to be generating bad or suboptimal code. but, this costs me 512 bytes of text size:
Quoted 2 lines
898384 Jul 29 15:40
mm/page_alloc.o.nothing
898896 Jul 29 15:40mm/page_alloc.o.unlikelyI took a look at this on my system.
With gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5):
(quoted diff) +0
-2-rw-rw-r-- 1 cody cody 841160 Jul 29 16:47 unlikely/mm/page_alloc.o -rw-rw-r-- 1 cody cody 840584 Jul 29 16:59 normal/mm/page_alloc.o text data bss dec hex filename 33799 1414 184 35397 8a45
unlikely/mm/page_alloc.o
33799 1414 184 35397 8a45normal/mm/page_alloc.oWell, where are are those extra bytes coming from, then?
Using readelf -S +
git diff --no-index --word-diffshows:
.debug_info shrinks from 1e991 to 1e98f
.rela.debug_info shrinks from 33a80 to 33a68.debug_loc grows from 15e1d to 15ecb .rela.debug_loc grows from 26f40 to 270f0 .debug_line grows from 038eb to 038ed.debug_str shrinks from 0adb6 to 0adb2
The sizes of all other sections are unchanged.
Also: comparing vmlinux sizes:
(quoted diff) +0
-2-rwxrwxr-x 1 cody cody 94121230 Jul 29 17:00 normal/vmlinux -rwxrwxr-x 1 cody cody 94121294 Jul 29 16:51 unlikely/vmlinuxAnd the bzImage sizes:
(quoted diff) +0
-2-rw-rw-r-- 1 cody cody 2942240 Jul 29 16:51 unlikely/arch/x86/boot/bzImage -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:00 normal/arch/x86/boot/bzImageI build this kernel with debug info built in though, what happens when it is removed?
Review
Quoted 5 lines
(quoted diff) +0
-4-rwxrwxr-x 1 cody cody 16392454 Jul 29 17:33 normal/vmlinux -rwxrwxr-x 1 cody cody 16392454 Jul 29 17:33 unlikely/vmlinux -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 normal/arch/x86/boot/bzImage -rw-rw-r-- 1 cody cody 2942208 Jul 29 17:33 unlikely/arch/x86/boot/bzImage
Corrected size for bzImage and vmlinux with patch applied:
-rwxrwxr-x 1 cody cody 16392454 Jul 29 18:15 unlikely/vmlinux -rw-rw-r-- 1 cody cody 2942240 Jul 29 18:15 unlikely/arch/x86/boot/bzImage
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Cody, it's a good point that we shouldn't be looking at something as simplistic as the file sizes. I also used whole vmlinux's and turned off debuginfo:
text data bss dec hex filename
10064322 1980968 3051520 15096810 e65bea vmlinux.nothing
10064451 1980968 3051520 15096939 e65c6b vmlinux.unlikely
So it still cost ~130 bytes of text. Also, perusing the vmlinux objdump, adding the unlikely() does look to take __alloc_pages_direct_compact and move it _closer_ to the page allocation code.
What does this all mean? Hell if I know. It's up to the patch submitter to explain the implications of the patch. ;)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
I submit the patch to make sure "order >= MAX_ORDER" happen unlikely.
But, I couldn't think generated code by compiler.
I think I was wrong.
Thanks your comments.
2013/7/31 Dave Hansen <[email protected]>:
Quoted 8 lines
Cody, it's a good point that we shouldn't be looking at something as simplistic as the file sizes. I also used whole vmlinux's and turned off debuginfo:
text data bss dec hex filename
10064322 1980968 3051520 15096810 e65bea vmlinux.nothing 10064451 1980968 3051520 15096939 e65c6b vmlinux.unlikely
Quoted 9 lines
So it still cost ~130 bytes of text. Also, perusing the vmlinux objdump, adding the
unlikely()does look to take__alloc_pages_direct_compactand move it _closer_ to the page allocation code.What does this all mean? Hell if I know. It's up to the patch submitter to explain the implications of the patch. ;)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>