[PATCH 0/3] delayacct: optimization & code simplify

From: brookxu.cn
Date: Sun Oct 08 2023 - 06:49:50 EST


From: Chunguang Xu <chunguang.xu@xxxxxxxxxx>

Since in some scenarios we still want to get the task delayacct
through taskstats, so commit <0cd7c741f01de> introduces a sysctl to
enable it dynamically. However, since task->delays is allocated
during fork(), task->delays will not be reallocated when delayacct
is enabled later. This will make we cannot get the delayacct of old
tasks, but the new tasks cans. This can easily lead to confusion.
Therefore, try to workaround this issue by convert task->delays to
an object, just like sched_statistics. Besides, try to simplify the
code of delayacct.

Chunguang Xu (3):
delayacct: introduce delayacct_enabled() to simplify implement
delayacct: convert task->delays to a object
delayacct: remove delayacct_on to simplify the code

include/linux/delayacct.h | 83 +++++-------------------
include/linux/sched.h | 3 +-
kernel/delayacct.c | 129 ++++++++++++++++++--------------------
kernel/fork.c | 7 +--
4 files changed, 81 insertions(+), 141 deletions(-)

--
2.25.1