]> git.baikalelectronics.ru Git - kernel.git/commitdiff
lib/flex_proportions.c: cleanup __fprop_inc_percpu_max
authorTan Hu <tan.hu@zte.com.cn>
Thu, 4 Jun 2020 23:50:23 +0000 (16:50 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Jun 2020 02:06:25 +0000 (19:06 -0700)
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: <xue.zhihong@zte.com.cn>
Cc: Yi Wang <wang.yi59@zte.com.cn>
Cc: <wang.liang82@zte.com.cn>
Link: http://lkml.kernel.org/r/1589004753-27554-1-git-send-email-tan.hu@zte.com.cn
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/flex_proportions.c

index 7852bfff50b1289005244cd36664dcf185aeccf6..45154393752433bdb4c56e7581e8a575b99cb5ac 100644 (file)
@@ -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);
 }