hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/powerpc/kernel/time.c
....@@ -312,11 +312,12 @@
312312 return stime_scaled;
313313 }
314314
315
-static unsigned long vtime_delta(struct cpu_accounting_data *acct,
315
+static unsigned long vtime_delta(struct task_struct *tsk,
316316 unsigned long *stime_scaled,
317317 unsigned long *steal_time)
318318 {
319319 unsigned long now, stime;
320
+ struct cpu_accounting_data *acct = get_accounting(tsk);
320321
321322 WARN_ON_ONCE(!irqs_disabled());
322323
....@@ -331,30 +332,29 @@
331332 return stime;
332333 }
333334
334
-static void vtime_delta_kernel(struct cpu_accounting_data *acct,
335
- unsigned long *stime, unsigned long *stime_scaled)
336
-{
337
- unsigned long steal_time;
338
-
339
- *stime = vtime_delta(acct, stime_scaled, &steal_time);
340
- *stime -= min(*stime, steal_time);
341
- acct->steal_time += steal_time;
342
-}
343
-
344335 void vtime_account_kernel(struct task_struct *tsk)
345336 {
337
+ unsigned long stime, stime_scaled, steal_time;
346338 struct cpu_accounting_data *acct = get_accounting(tsk);
347
- unsigned long stime, stime_scaled;
348339
349
- vtime_delta_kernel(acct, &stime, &stime_scaled);
340
+ stime = vtime_delta(tsk, &stime_scaled, &steal_time);
350341
351
- if (tsk->flags & PF_VCPU) {
342
+ stime -= min(stime, steal_time);
343
+ acct->steal_time += steal_time;
344
+
345
+ if ((tsk->flags & PF_VCPU) && !irq_count()) {
352346 acct->gtime += stime;
353347 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
354348 acct->utime_scaled += stime_scaled;
355349 #endif
356350 } else {
357
- acct->stime += stime;
351
+ if (hardirq_count())
352
+ acct->hardirq_time += stime;
353
+ else if (in_serving_softirq())
354
+ acct->softirq_time += stime;
355
+ else
356
+ acct->stime += stime;
357
+
358358 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
359359 acct->stime_scaled += stime_scaled;
360360 #endif
....@@ -367,32 +367,8 @@
367367 unsigned long stime, stime_scaled, steal_time;
368368 struct cpu_accounting_data *acct = get_accounting(tsk);
369369
370
- stime = vtime_delta(acct, &stime_scaled, &steal_time);
370
+ stime = vtime_delta(tsk, &stime_scaled, &steal_time);
371371 acct->idle_time += stime + steal_time;
372
-}
373
-
374
-static void vtime_account_irq_field(struct cpu_accounting_data *acct,
375
- unsigned long *field)
376
-{
377
- unsigned long stime, stime_scaled;
378
-
379
- vtime_delta_kernel(acct, &stime, &stime_scaled);
380
- *field += stime;
381
-#ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
382
- acct->stime_scaled += stime_scaled;
383
-#endif
384
-}
385
-
386
-void vtime_account_softirq(struct task_struct *tsk)
387
-{
388
- struct cpu_accounting_data *acct = get_accounting(tsk);
389
- vtime_account_irq_field(acct, &acct->softirq_time);
390
-}
391
-
392
-void vtime_account_hardirq(struct task_struct *tsk)
393
-{
394
- struct cpu_accounting_data *acct = get_accounting(tsk);
395
- vtime_account_irq_field(acct, &acct->hardirq_time);
396372 }
397373
398374 static void vtime_flush_scaled(struct task_struct *tsk,