linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/zsmalloc: strength reduce zspage_size calculation
@ 2018-02-26 12:21 Joey Pabalinas
  2018-02-28  0:03 ` Minchan Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Joey Pabalinas @ 2018-02-26 12:21 UTC (permalink / raw)
  To: linux-mm; +Cc: Minchan Kim, Nitin Gupta, linux-kernel, Joey Pabalinas

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

Replace the repeated multiplication in the main loop
body calculation of zspage_size with an equivalent
(and cheaper) addition operation.

Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>

 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index c3013505c30527dc42..647a1a2728634b5194 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -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;
 
-- 
2.16.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/zsmalloc: strength reduce zspage_size calculation
  2018-02-26 12:21 [PATCH] mm/zsmalloc: strength reduce zspage_size calculation Joey Pabalinas
@ 2018-02-28  0:03 ` Minchan Kim
  2018-02-28  1:26   ` Joey Pabalinas
  0 siblings, 1 reply; 3+ messages in thread
From: Minchan Kim @ 2018-02-28  0:03 UTC (permalink / raw)
  To: Joey Pabalinas; +Cc: linux-mm, Nitin Gupta, linux-kernel

Hi Joey,

On Mon, Feb 26, 2018 at 02:21:26AM -1000, Joey Pabalinas wrote:
> Replace the repeated multiplication in the main loop
> body calculation of zspage_size with an equivalent
> (and cheaper) addition operation.
> 
> Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
> 
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index c3013505c30527dc42..647a1a2728634b5194 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -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;
>  

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.

--
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/zsmalloc: strength reduce zspage_size calculation
  2018-02-28  0:03 ` Minchan Kim
@ 2018-02-28  1:26   ` Joey Pabalinas
  0 siblings, 0 replies; 3+ messages in thread
From: Joey Pabalinas @ 2018-02-28  1:26 UTC (permalink / raw)
  To: Minchan Kim; +Cc: linux-mm, Nitin Gupta, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

On Wed, Feb 28, 2018 at 09:03:19AM +0900, Minchan Kim wrote:
> 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.

Very true; in retrospect this this definitely isn't a very hot path at
all, haha. Cheers :)

-- 
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-28  1:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26 12:21 [PATCH] mm/zsmalloc: strength reduce zspage_size calculation Joey Pabalinas
2018-02-28  0:03 ` Minchan Kim
2018-02-28  1:26   ` Joey Pabalinas

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).