linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] lib/flex_proportions.c: cleanup __fprop_inc_percpu_max
@ 2020-05-09  6:12 Tan Hu
  2020-05-11 11:23 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Tan Hu @ 2020-05-09  6:12 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, jack, xue.zhihong, wang.yi59, wang.liang82, Tan Hu

If the given type has fraction smaller than max_frac/FPROP_FRAC_BASE,
the code could be modified to call __fprop_inc_percpu() directly and
easier to understand. After this patch, fprop_reflect_period_percpu()
will be called twice, and quicky return on pl->period == p->period
test, so it would not result to significant downside of performance.

Thanks for Jan's guidance.

Signed-off-by: Tan Hu <tan.hu@zte.com.cn>
---
 lib/flex_proportions.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
index 7852bfff5..451543937 100644
--- a/lib/flex_proportions.c
+++ b/lib/flex_proportions.c
@@ -266,8 +266,7 @@ void __fprop_inc_percpu_max(struct fprop_global *p,
 		if (numerator >
 		    (((u64)denominator) * max_frac) >> FPROP_FRAC_SHIFT)
 			return;
-	} else
-		fprop_reflect_period_percpu(p, pl);
-	percpu_counter_add_batch(&pl->events, 1, PROP_BATCH);
-	percpu_counter_add(&p->events, 1);
+	}
+
+	__fprop_inc_percpu(p, pl);
 }
-- 
2.19.1


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

* Re: [PATCH v2] lib/flex_proportions.c: cleanup __fprop_inc_percpu_max
  2020-05-09  6:12 [PATCH v2] lib/flex_proportions.c: cleanup __fprop_inc_percpu_max Tan Hu
@ 2020-05-11 11:23 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2020-05-11 11:23 UTC (permalink / raw)
  To: Tan Hu; +Cc: akpm, linux-kernel, jack, xue.zhihong, wang.yi59, wang.liang82

On Sat 09-05-20 14:12:33, Tan Hu wrote:
> If the given type has fraction smaller than max_frac/FPROP_FRAC_BASE,
> the code could be modified to call __fprop_inc_percpu() directly and
> easier to understand. After this patch, fprop_reflect_period_percpu()
> will be called twice, and quicky return on pl->period == p->period
> test, so it would not result to significant downside of performance.
> 
> Thanks for Jan's guidance.
> 
> Signed-off-by: Tan Hu <tan.hu@zte.com.cn>

Thanks for the patch. It looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  lib/flex_proportions.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c
> index 7852bfff5..451543937 100644
> --- a/lib/flex_proportions.c
> +++ b/lib/flex_proportions.c
> @@ -266,8 +266,7 @@ void __fprop_inc_percpu_max(struct fprop_global *p,
>  		if (numerator >
>  		    (((u64)denominator) * max_frac) >> FPROP_FRAC_SHIFT)
>  			return;
> -	} else
> -		fprop_reflect_period_percpu(p, pl);
> -	percpu_counter_add_batch(&pl->events, 1, PROP_BATCH);
> -	percpu_counter_add(&p->events, 1);
> +	}
> +
> +	__fprop_inc_percpu(p, pl);
>  }
> -- 
> 2.19.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2020-05-11 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09  6:12 [PATCH v2] lib/flex_proportions.c: cleanup __fprop_inc_percpu_max Tan Hu
2020-05-11 11:23 ` Jan Kara

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