psi: update psi irqtime when the irq delta is nozero

Message ID 20230810131514.910401-1-lujialin4@huawei.com
State New
Headers
Series psi: update psi irqtime when the irq delta is nozero |

Commit Message

Lu Jialin Aug. 10, 2023, 1:15 p.m. UTC
  If update psi irqtime whether the irq delta is zero or not, the performance
will be degradation when update_rq_clock_task works frequently.
Therefore, just update psi irqtime whether the irq delta is nozero.
performace test of times(libmicro):
1) without psi_account_irqtime in update_rq_clock_task
[root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
             prc thr   usecs/call      samples   errors cnt/samp
times          1   1      0.45210          188        0      500

2) psi_account_irqtime in update_rq_clock_task
[root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
             prc thr   usecs/call      samples   errors cnt/samp
times          1   1      0.49408          196        0      500

3) psi_account_irqtime in update_rq_clock_task when irq delta is nozero
[root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
             prc thr   usecs/call      samples   errors cnt/samp
times          1   1      0.45158          195        0      500

Signed-off-by: Lu Jialin <lujialin4@huawei.com>
---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Chengming Zhou Aug. 11, 2023, 6:43 a.m. UTC | #1
On 2023/8/10 21:15, Lu Jialin wrote:
> If update psi irqtime whether the irq delta is zero or not, the performance
> will be degradation when update_rq_clock_task works frequently.
> Therefore, just update psi irqtime whether the irq delta is nozero.
> performace test of times(libmicro):
> 1) without psi_account_irqtime in update_rq_clock_task
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.45210          188        0      500
> 
> 2) psi_account_irqtime in update_rq_clock_task
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.49408          196        0      500
> 
> 3) psi_account_irqtime in update_rq_clock_task when irq delta is nozero
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.45158          195        0      500
> 
> Signed-off-by: Lu Jialin <lujialin4@huawei.com>
> ---
>  kernel/sched/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index c52c2eba7c73..69c4f229d6d1 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -722,7 +722,8 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
>  
>  	rq->prev_irq_time += irq_delta;
>  	delta -= irq_delta;
> -	psi_account_irqtime(rq->curr, irq_delta);
> +	if (irq_delta)
> +		psi_account_irqtime(rq->curr, irq_delta);
>  	delayacct_irq(rq->curr, irq_delta);
>  #endif
>  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING

LGTM, thanks.

Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
  
Ingo Molnar Sept. 28, 2023, 9:26 p.m. UTC | #2
* Lu Jialin <lujialin4@huawei.com> wrote:

> If update psi irqtime whether the irq delta is zero or not, the performance
> will be degradation when update_rq_clock_task works frequently.
> Therefore, just update psi irqtime whether the irq delta is nozero.
> performace test of times(libmicro):
> 1) without psi_account_irqtime in update_rq_clock_task
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.45210          188        0      500
> 
> 2) psi_account_irqtime in update_rq_clock_task
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.49408          196        0      500
> 
> 3) psi_account_irqtime in update_rq_clock_task when irq delta is nozero
> [root@arm64_perf]# ./times  -E -C 200 -L -S -W -N "times" -I 200
> Running: times# ./../bin-arm64/times -E -C 200 -L -S -W -N times -I 200
>              prc thr   usecs/call      samples   errors cnt/samp
> times          1   1      0.45158          195        0      500
> 
> Signed-off-by: Lu Jialin <lujialin4@huawei.com>
> ---
>  kernel/sched/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index c52c2eba7c73..69c4f229d6d1 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -722,7 +722,8 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
>  
>  	rq->prev_irq_time += irq_delta;
>  	delta -= irq_delta;
> -	psi_account_irqtime(rq->curr, irq_delta);
> +	if (irq_delta)
> +		psi_account_irqtime(rq->curr, irq_delta);
>  	delayacct_irq(rq->curr, irq_delta);

Erm, if irq_delta is zero, then a whole bunch of code around the place you
modified becomes NOP as well, right?

Thanks,

	Ingo
  

Patch

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c52c2eba7c73..69c4f229d6d1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -722,7 +722,8 @@  static void update_rq_clock_task(struct rq *rq, s64 delta)
 
 	rq->prev_irq_time += irq_delta;
 	delta -= irq_delta;
-	psi_account_irqtime(rq->curr, irq_delta);
+	if (irq_delta)
+		psi_account_irqtime(rq->curr, irq_delta);
 	delayacct_irq(rq->curr, irq_delta);
 #endif
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING