mm/zsmalloc: strength reduce zspage_size calculation
Subsystems (2)
PATCH 1/1 mm/zsmalloc: strength reduce zspage_size calculation
Replace the repeated multiplication in the main loop body calculation of zspage_size with an equivalent (and cheaper) addition operation.
1 file changed, 2 insertions(+), 2 deletions(-)
mm/zsmalloc.c +2 -2
@@ -821,15 +821,15 @@ static enum fullness_group fix_fullness_group(struct size_class *class,*/ static int get_pages_per_zspage (int class_size) { +int zspage_size =0 ;int i, max_usedpc =0 ;/* zspage order which gives maximum used size per KB */ int max_usedpc_order =1 ;for (i =1 ; i <=ZS_MAX_PAGES_PER_ZSPAGE ; i++) { -int zspage_size;int waste, usedpc; - zspage_size = i *PAGE_SIZE ; + zspage_size +=PAGE_SIZE ; waste = zspage_size % class_size; usedpc = (zspage_size - waste) *100 / zspage_size;
Signature · 1 line
2.16.2
Minchan Kim
maintainerHi Joey,
Quoted 20 lines · Joey Pabalinas
Replace the repeated multiplication in the main loop body calculation of
zspage_sizewith an equivalent (and cheaper) addition operation.Signed-off-by Joey Pabalinas <[email protected]>1 file changed, 2 insertions(+), 2 deletions(-)mm/zsmalloc.c +1
-0@@ -821,15 +821,15 @@ static enum fullness_group fix_fullness_group(struct size_class *class,*/ static int get_pages_per_zspage (int class_size) { +int zspage_size =0 ;int i, max_usedpc =0 ;/* zspage order which gives maximum used size per KB */ int max_usedpc_order =1 ;
mm/zsmalloc.c static enum fullness_group fix_fullness_group(struct size_class *class, · line 835
Quoted 10 lines
mm/zsmalloc.c +1
-2for (i =1 ; i <=ZS_MAX_PAGES_PER_ZSPAGE ; i++) { -int zspage_size;int waste, usedpc; - zspage_size = i *PAGE_SIZE ; + zspage_size +=PAGE_SIZE ; waste = zspage_size % class_size; usedpc = (zspage_size - waste) *100 / zspage_size;
Thanks for the patch! However, it's used only zs_create_pool which is really cold path so I don't feel it would improve for real practice.
Thanks.
Quoted 2 lines · Minchan Kim
Thanks for the patch! However, it's used only
zs_create_poolwhich is really cold path so I don't feel it would improve for real practice.
Very true; in retrospect this this definitely isn't a very hot path at all, haha. Cheers :)
Signature · 1 line
Joey Pabalinas