| .. | .. |
|---|
| 312 | 312 | return stime_scaled; |
|---|
| 313 | 313 | } |
|---|
| 314 | 314 | |
|---|
| 315 | | -static unsigned long vtime_delta(struct cpu_accounting_data *acct, |
|---|
| 315 | +static unsigned long vtime_delta(struct task_struct *tsk, |
|---|
| 316 | 316 | unsigned long *stime_scaled, |
|---|
| 317 | 317 | unsigned long *steal_time) |
|---|
| 318 | 318 | { |
|---|
| 319 | 319 | unsigned long now, stime; |
|---|
| 320 | + struct cpu_accounting_data *acct = get_accounting(tsk); |
|---|
| 320 | 321 | |
|---|
| 321 | 322 | WARN_ON_ONCE(!irqs_disabled()); |
|---|
| 322 | 323 | |
|---|
| .. | .. |
|---|
| 331 | 332 | return stime; |
|---|
| 332 | 333 | } |
|---|
| 333 | 334 | |
|---|
| 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 | | - |
|---|
| 344 | 335 | void vtime_account_kernel(struct task_struct *tsk) |
|---|
| 345 | 336 | { |
|---|
| 337 | + unsigned long stime, stime_scaled, steal_time; |
|---|
| 346 | 338 | struct cpu_accounting_data *acct = get_accounting(tsk); |
|---|
| 347 | | - unsigned long stime, stime_scaled; |
|---|
| 348 | 339 | |
|---|
| 349 | | - vtime_delta_kernel(acct, &stime, &stime_scaled); |
|---|
| 340 | + stime = vtime_delta(tsk, &stime_scaled, &steal_time); |
|---|
| 350 | 341 | |
|---|
| 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()) { |
|---|
| 352 | 346 | acct->gtime += stime; |
|---|
| 353 | 347 | #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME |
|---|
| 354 | 348 | acct->utime_scaled += stime_scaled; |
|---|
| 355 | 349 | #endif |
|---|
| 356 | 350 | } 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 | + |
|---|
| 358 | 358 | #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME |
|---|
| 359 | 359 | acct->stime_scaled += stime_scaled; |
|---|
| 360 | 360 | #endif |
|---|
| .. | .. |
|---|
| 367 | 367 | unsigned long stime, stime_scaled, steal_time; |
|---|
| 368 | 368 | struct cpu_accounting_data *acct = get_accounting(tsk); |
|---|
| 369 | 369 | |
|---|
| 370 | | - stime = vtime_delta(acct, &stime_scaled, &steal_time); |
|---|
| 370 | + stime = vtime_delta(tsk, &stime_scaled, &steal_time); |
|---|
| 371 | 371 | 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); |
|---|
| 396 | 372 | } |
|---|
| 397 | 373 | |
|---|
| 398 | 374 | static void vtime_flush_scaled(struct task_struct *tsk, |
|---|
| .. | .. |
|---|
| 460 | 436 | #define calc_cputime_factors() |
|---|
| 461 | 437 | #endif |
|---|
| 462 | 438 | |
|---|
| 463 | | -void __delay(unsigned long loops) |
|---|
| 439 | +void __no_kcsan __delay(unsigned long loops) |
|---|
| 464 | 440 | { |
|---|
| 465 | 441 | unsigned long start; |
|---|
| 466 | 442 | |
|---|
| .. | .. |
|---|
| 481 | 457 | } |
|---|
| 482 | 458 | EXPORT_SYMBOL(__delay); |
|---|
| 483 | 459 | |
|---|
| 484 | | -void udelay(unsigned long usecs) |
|---|
| 460 | +void __no_kcsan udelay(unsigned long usecs) |
|---|
| 485 | 461 | { |
|---|
| 486 | 462 | __delay(tb_ticks_per_usec * usecs); |
|---|
| 487 | 463 | } |
|---|