From 6778948f9de86c3cfaf36725a7c87dcff9ba247f Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 08:20:59 +0000 Subject: [PATCH] kernel_5.10 no rt --- kernel/arch/powerpc/kernel/time.c | 56 ++++++++++++++++---------------------------------------- 1 files changed, 16 insertions(+), 40 deletions(-) diff --git a/kernel/arch/powerpc/kernel/time.c b/kernel/arch/powerpc/kernel/time.c index 7e0a497..1d20f0f 100644 --- a/kernel/arch/powerpc/kernel/time.c +++ b/kernel/arch/powerpc/kernel/time.c @@ -312,11 +312,12 @@ return stime_scaled; } -static unsigned long vtime_delta(struct cpu_accounting_data *acct, +static unsigned long vtime_delta(struct task_struct *tsk, unsigned long *stime_scaled, unsigned long *steal_time) { unsigned long now, stime; + struct cpu_accounting_data *acct = get_accounting(tsk); WARN_ON_ONCE(!irqs_disabled()); @@ -331,30 +332,29 @@ return stime; } -static void vtime_delta_kernel(struct cpu_accounting_data *acct, - unsigned long *stime, unsigned long *stime_scaled) -{ - unsigned long steal_time; - - *stime = vtime_delta(acct, stime_scaled, &steal_time); - *stime -= min(*stime, steal_time); - acct->steal_time += steal_time; -} - void vtime_account_kernel(struct task_struct *tsk) { + unsigned long stime, stime_scaled, steal_time; struct cpu_accounting_data *acct = get_accounting(tsk); - unsigned long stime, stime_scaled; - vtime_delta_kernel(acct, &stime, &stime_scaled); + stime = vtime_delta(tsk, &stime_scaled, &steal_time); - if (tsk->flags & PF_VCPU) { + stime -= min(stime, steal_time); + acct->steal_time += steal_time; + + if ((tsk->flags & PF_VCPU) && !irq_count()) { acct->gtime += stime; #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME acct->utime_scaled += stime_scaled; #endif } else { - acct->stime += stime; + if (hardirq_count()) + acct->hardirq_time += stime; + else if (in_serving_softirq()) + acct->softirq_time += stime; + else + acct->stime += stime; + #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME acct->stime_scaled += stime_scaled; #endif @@ -367,32 +367,8 @@ unsigned long stime, stime_scaled, steal_time; struct cpu_accounting_data *acct = get_accounting(tsk); - stime = vtime_delta(acct, &stime_scaled, &steal_time); + stime = vtime_delta(tsk, &stime_scaled, &steal_time); acct->idle_time += stime + steal_time; -} - -static void vtime_account_irq_field(struct cpu_accounting_data *acct, - unsigned long *field) -{ - unsigned long stime, stime_scaled; - - vtime_delta_kernel(acct, &stime, &stime_scaled); - *field += stime; -#ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME - acct->stime_scaled += stime_scaled; -#endif -} - -void vtime_account_softirq(struct task_struct *tsk) -{ - struct cpu_accounting_data *acct = get_accounting(tsk); - vtime_account_irq_field(acct, &acct->softirq_time); -} - -void vtime_account_hardirq(struct task_struct *tsk) -{ - struct cpu_accounting_data *acct = get_accounting(tsk); - vtime_account_irq_field(acct, &acct->hardirq_time); } static void vtime_flush_scaled(struct task_struct *tsk, -- Gitblit v1.6.2