mbox series

[v4,0/2] Exposing nice CPU usage to userspace

Message ID 20241002184717.153302-1-joshua.hahnjy@gmail.com (mailing list archive)
Headers show
Series Exposing nice CPU usage to userspace | expand

Message

Joshua Hahn Oct. 2, 2024, 6:47 p.m. UTC
Changes in v4
	- Removed unnecessary forking from selftest.
	- Style changes in rstat.c (fallthrough & indents)
	- Fixed a selftest bug that raised false negatives, caused by
		cputime_adjust sometimes adjusting utime below ntime.
	- Reworded cover letter for clarity & motivation
Changes in v3
	- Signed-off-by & renamed subject for clarity.
Changes in v2
	- Edited commit messages for clarity.

Niced CPU usage is a metric reported in host-level /proc/stat, but is
not currently reported in cgroup-level statistics. Thus, even if one
can observe that a fracion of the host's CPU time is spent on (non-)nice
tasks, the distribution of the CPU usage across cgroups is not readily
available to the user.

This patch introduces cgroup-level niced CPU utilization to cpu.stat.
Exposing this metric will allow users to accurately probe the niced CPU
metric for each workload, and make more informed decisions when
directing higher priority tasks. For instance, service routers will be
able to probe cgroups in the host to determine CPU time spent on niced
processes in each cgroup, and direct more traffic to cgroups with lower
non-nice CPU utilization.

Signed-off-by Joshua Hahn <joshua.hahnjy@gmail.com>

Joshua Hahn (2):
  Tracking cgroup-level niced CPU time
  Selftests for niced CPU statistics

 include/linux/cgroup-defs.h               |  1 +
 kernel/cgroup/rstat.c                     | 19 ++++--
 tools/testing/selftests/cgroup/test_cpu.c | 75 +++++++++++++++++++++++
 3 files changed, 90 insertions(+), 5 deletions(-)

Comments

Tejun Heo Oct. 8, 2024, 6:51 p.m. UTC | #1
On Wed, Oct 02, 2024 at 11:47:15AM -0700, Joshua Hahn wrote:
> Changes in v4
> 	- Removed unnecessary forking from selftest.
> 	- Style changes in rstat.c (fallthrough & indents)
> 	- Fixed a selftest bug that raised false negatives, caused by
> 		cputime_adjust sometimes adjusting utime below ntime.
> 	- Reworded cover letter for clarity & motivation
> Changes in v3
> 	- Signed-off-by & renamed subject for clarity.
> Changes in v2
> 	- Edited commit messages for clarity.

Applied to cgroup/for-6.13. If there are issues, let's iterate in tree.

Thanks.