* [PATCH] sched/pelt: use shift operation instead of division operation
@ 2020-02-24 3:30 qiwuchen55
2020-02-24 9:32 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: qiwuchen55 @ 2020-02-24 3:30 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman
Cc: linux-kernel, chenqiwu
From: chenqiwu <chenqiwu@xiaomi.com>
Use shift operation to calculate the periods instead of division,
since shift operation is more efficient than division operation.
Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
kernel/sched/pelt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index bd006b7..ac79f8e 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -114,7 +114,7 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)
u64 periods;
delta += sa->period_contrib;
- periods = delta / 1024; /* A period is 1024us (~1ms) */
+ periods = delta >> 10; /* A period is 1024us (~1ms) */
/*
* Step 1: decay old *_sum if we crossed period boundaries.
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched/pelt: use shift operation instead of division operation
2020-02-24 3:30 [PATCH] sched/pelt: use shift operation instead of division operation qiwuchen55
@ 2020-02-24 9:32 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2020-02-24 9:32 UTC (permalink / raw)
To: qiwuchen55
Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
bsegall, mgorman, linux-kernel, chenqiwu
On Mon, Feb 24, 2020 at 11:30:55AM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
>
> Use shift operation to calculate the periods instead of division,
> since shift operation is more efficient than division operation.
>
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
> kernel/sched/pelt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
> index bd006b7..ac79f8e 100644
> --- a/kernel/sched/pelt.c
> +++ b/kernel/sched/pelt.c
> @@ -114,7 +114,7 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)
> u64 periods;
>
> delta += sa->period_contrib;
> - periods = delta / 1024; /* A period is 1024us (~1ms) */
> + periods = delta >> 10; /* A period is 1024us (~1ms) */
Find me a compiler that stupid.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-24 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 3:30 [PATCH] sched/pelt: use shift operation instead of division operation qiwuchen55
2020-02-24 9:32 ` Peter Zijlstra
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).