Skip to content

RFC cputime: Convert task/cpu cputime accounting to nsecs

Frederic Weisbecker lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest30 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30jiffies: Remove HZ > USEC_PER_SEC special casekernel/time/time.c+5 -60 replies
2/30time: Introduce jiffies64_to_nsecs()include/linux/jiffies.h kernel/time/time.c kernel/time/timeconst.bc+18 -00 replies
3/30cputime: Introduce nsecs_to_cputime64()include/linux/cputime.h+10 -01 reply
4/30s390: Convert open coded idle time seqcountarch/s390/include/asm/idle.h arch/s390/kernel/idle.c+17 -141 reply
5/30s390: Translate cputime magic constants to macrosarch/s390/include/asm/cputime.h+24 -232 replies
6/30s390: Introduce cputime64_to_nsecs()arch/s390/include/asm/cputime.h+5 -03 replies
7/30cputime: Convert kcpustat to nsecsarch/s390/appldata/appldata_os.c drivers/cpufreq/cpufreq.c drivers/cpufreq/cpufreq_governor.c +4 more+69 -788 replies
8/30apm32: Fix cputime == jiffies assumptionarch/x86/kernel/apm_32.c+1 -10 replies
9/30alpha: Fix jiffies based cputime assumptionarch/alpha/kernel/osf_sys.c+9 -40 replies
10/30cputime: Convert guest time accounting to nsecsfs/proc/array.c include/linux/sched.h kernel/sched/cputime.c+11 -110 replies
11/30cputime: Special API to return old-typed cputimearch/alpha/kernel/osf_sys.c arch/x86/kernel/apm_32.c drivers/isdn/mISDN/stack.c +10 more+80 -450 replies
12/30cputime: Convert task/group cputime to nsecsarch/alpha/kernel/osf_sys.c fs/binfmt_elf.c fs/binfmt_elf_fdpic.c +6 more+107 -670 replies
13/30alpha: Convert obsolete cputime_t to nsecsarch/alpha/kernel/osf_sys.c+4 -40 replies
14/30x86: Convert obsolete cputime type to nsecsarch/x86/kernel/apm_32.c+4 -40 replies
15/30isdn: Convert obsolete cputime type to nsecsdrivers/isdn/mISDN/stack.c+3 -30 replies
16/30binfmt: Convert obsolete cputime type to nsecsfs/binfmt_elf.c fs/binfmt_elf_fdpic.c fs/compat_binfmt_elf.c+29 -330 replies
17/30acct: Convert obsolete cputime type to nsecsinclude/linux/sched.h kernel/acct.c+6 -50 replies
18/30delaycct: Convert obsolete cputime type to nsecskernel/delayacct.c+5 -50 replies
19/30tsacct: Convert obsolete cputime type to nsecsinclude/linux/sched.h kernel/tsacct.c+13 -130 replies
20/30signal: Convert obsolete cputime type to nsecskernel/signal.c+8 -80 replies
21/30cputime: Remove task_cputime_t_scaledinclude/linux/sched.h+0 -130 replies
22/30u64_stats_sync: Introduce preempt-unsafe readersinclude/linux/u64_stats_sync.h+23 -120 replies
23/30cputime: Convert irq_time_accounting to use u64_stats_synckernel/sched/cputime.c kernel/sched/sched.h+22 -490 replies
24/30cputime: Increment kcpustat directly on irqtime accountkernel/sched/cputime.c kernel/sched/sched.h+21 -283 replies
25/30cputime: Remove temporary irqtime statesinclude/linux/kernel_stat.h kernel/sched/cputime.c kernel/sched/sched.h+30 -340 replies
26/30cputime: Push time to account_user_time() in nanosecsarch/ia64/kernel/time.c arch/powerpc/kernel/time.c arch/s390/kernel/vtime.c +3 more+28 -160 replies
27/30cputime: Push time to account_steal_time() in nanosecsarch/powerpc/kernel/time.c arch/s390/kernel/vtime.c include/linux/kernel_stat.h +1 more+9 -170 replies
28/30cputime: Push time to account_idle_time() in nanosecsarch/ia64/kernel/time.c arch/powerpc/kernel/time.c arch/s390/kernel/idle.c +2 more+9 -90 replies
29/30cputime: Push time to account_guest_time() in nanosecskernel/sched/cputime.c+12 -120 replies
30/30cputime: Push time to account_system_time() in nanosecsarch/ia64/kernel/time.c arch/powerpc/kernel/time.c arch/s390/kernel/vtime.c +3 more+21 -190 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/30] cputime: Convert task/cpu cputime accounting to nsecs

Hi,

Thomas suggested to store the cpu and task stats in nanoseconds in order to avoid back and forth conversion between cputime_t to nsecs.

This patchset does that (plus many fixes and cleanups).

There should be a performance impact for CONFIG_VIRT_CPU_ACCOUNTING_NATIVE configurations which account cputime from arch's kernel entrypoint. As this config always use cputime_t as a time source, the conversion to nsecs is required on each accounting update. This concern only powerpc and s390 (ia64 also support this mode but its cputime_t wraps nsecs so the conversion is a noop there). I'm not sure how much this config is used in powerpc, it doesn't appear in its defconfigs and that mode is expected to be a bit slower than tick based accounting anyway. But s390 only supports this mode (no support for tick based accounting).

But on the other side of the balance, it simplifies the core code a bit.

The patchset isn't complete, I have yet to convert the posix cpu timers code as well. I just need to post the current state before moving forward to details.

I need to get your opinion on that patchset before going deeper. Is this conversion a right direction to take?

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
cpustat/nsecs

HEAD: 3539960cb3be04512d5f601c8e83c8bab658e0c1

Thanks,
Frederic
---

Frederic Weisbecker (30):
jiffies: Remove HZ > USEC_PER_SEC special case
time: Introduce jiffies64_to_nsecs()
cputime: Introduce nsecs_to_cputime64()
s390: Convert open coded idle time seqcount
s390: Translate cputime magic constants to macros
s390: Introduce cputime64_to_nsecs()
cputime: Convert kcpustat to nsecs
apm32: Fix cputime == jiffies assumption
alpha: Fix jiffies based cputime assumption
cputime: Convert guest time accounting to nsecs
cputime: Special API to return old-typed cputime
cputime: Convert task/group cputime to nsecs
alpha: Convert obsolete cputime_t to nsecs
x86: Convert obsolete cputime type to nsecs
isdn: Convert obsolete cputime type to nsecs
binfmt: Convert obsolete cputime type to nsecs
acct: Convert obsolete cputime type to nsecs
delaycct: Convert obsolete cputime type to nsecs
tsacct: Convert obsolete cputime type to nsecs
signal: Convert obsolete cputime type to nsecs
cputime: Remove task_cputime_t_scaled
u64_stats_sync: Introduce preempt-unsafe readers
cputime: Convert irq_time_accounting to use u64_stats_sync
cputime: Increment kcpustat directly on irqtime account
cputime: Remove temporary irqtime states
cputime: Push time to account_user_time() in nanosecs
cputime: Push time to account_steal_time() in nanosecs
cputime: Push time to account_idle_time() in nanosecs
cputime: Push time to account_guest_time() in nanosecs
cputime: Push time to account_system_time() in nanosecs

 arch/alpha/kernel/osf_sys.c        |  15 ++-
 arch/ia64/kernel/time.c            |   9 +-
 arch/powerpc/kernel/time.c         |  10 +-
 arch/s390/appldata/appldata_os.c   |  16 +--
 arch/s390/include/asm/cputime.h    |  52 +++++----
 arch/s390/include/asm/idle.h       |   3 +-
 arch/s390/kernel/idle.c            |  30 ++---
 arch/s390/kernel/vtime.c           |  15 ++-
 arch/x86/kernel/apm_32.c           |   6 +-
 drivers/cpufreq/cpufreq.c          |   6 +-
 drivers/cpufreq/cpufreq_governor.c |  14 +--
 drivers/isdn/mISDN/stack.c         |   4 +-
 drivers/macintosh/rack-meter.c     |   2 +-
 fs/binfmt_elf.c                    |  15 +--
 fs/binfmt_elf_fdpic.c              |  14 +--
 fs/compat_binfmt_elf.c             |  20 ++--
 fs/proc/array.c                    |  15 ++-
 fs/proc/stat.c                     |  68 +++++------
 fs/proc/uptime.c                   |   6 +-
 include/linux/cputime.h            |  22 ++++
 include/linux/init_task.h          |   2 +-
 include/linux/jiffies.h            |   2 +
 include/linux/kernel_stat.h        |  10 +-
 include/linux/sched.h              |  83 ++++++++++----
 include/linux/u64_stats_sync.h     |  29 +++--
 kernel/acct.c                      |   7 +-
 kernel/delayacct.c                 |   6 +-
 kernel/exit.c                      |   4 +-
 kernel/sched/cputime.c             | 224 ++++++++++++++++++-------------------
 kernel/sched/sched.h               |  44 ++------
 kernel/sched/stats.h               |   8 +-
 kernel/signal.c                    |  12 +-
 kernel/sys.c                       |  16 +--
 kernel/time/itimer.c               |   2 +-
 kernel/time/posix-cpu-timers.c     |  44 ++++----
 kernel/time/time.c                 |  21 +++-
 kernel/time/timeconst.bc           |   6 +
 kernel/tsacct.c                    |  18 +--
 38 files changed, 475 insertions(+), 405 deletions(-)