On Sun, Oct 08, 2023 at 06:49:37PM +0800, brookxu.cn wrote:Yes, this way will increase about 80 bytes for task_struct, about 0.85% of size of task_struct, I think this just like sched_statistics, so that can better support dynamically enable through sysctl.
From: Chunguang Xu <chunguang.xu@xxxxxxxxxx>This is not the canonical way to reference a commit.
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 allocatedAnd grow task_struct for no reason? I think not.
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.
diff --git a/include/linux/sched.h b/include/linux/sched.hYeah, no.
index 77f01ac385f7..5cc78184a31f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -37,6 +37,7 @@
#include <linux/kcsan.h>
#include <linux/rv.h>
#include <linux/livepatch_sched.h>
+#include <linux/delayacct.h>
#include <asm/kmap_size.h>
/* task_struct member predeclarations (sorted alphabetically): */
@@ -1331,7 +1332,7 @@ struct task_struct {
struct page_frag task_frag;
#ifdef CONFIG_TASK_DELAY_ACCT
- struct task_delay_info *delays;
+ struct task_delay_info delays;
#endif