On 2022/12/21 20:37, Leizhen (ThunderTown) wrote: >>>> I am not familiar with it. But task_cputime() in >>>> kernel/sched/cputime.c looks promising. And there must be >>>> the interface how the user space get this information. >>>> Some is available via /proc/<PID>/... I am not sure >>>> if there is a syscall. >> Please, try to investigate the above hints. > Yes, I will. Thanks. Function task_cputime() works well when CONFIG_VIRT_CPU_ACCOUNTING_GEN=y, but not when CONFIG_TICK_CPU_ACCOUNTING=y. The latter seems to be based on tick interrupt sampling, rather than recording timestamps during task switches. > -- Regards, Zhen Lei