Message ID | 20241027120747.42833-2-ioworker0@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | add detect count for hung tasks | expand |
Hi Andrew, Sorry, I made a stupid mistake :( sysctl_hung_task_detect_count is defined as an unsigned long, so we need to use proc_doulongvec_minmax instead of proc_dointvec to handle it correctly. Could you please fold the following changes into this patch? --- kernel/hung_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 229ff3d4e501..c18717189f32 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -330,7 +330,7 @@ static struct ctl_table hung_task_sysctls[] = { .data = &sysctl_hung_task_detect_count, .maxlen = sizeof(unsigned long), .mode = 0444, - .proc_handler = proc_dointvec, + .proc_handler = proc_doulongvec_minmax, }, };
diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 959d99583d1c..229ff3d4e501 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -30,6 +30,11 @@ */ static int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT; +/* + * Total number of tasks detected as hung since boot: + */ +static unsigned long __read_mostly sysctl_hung_task_detect_count; + /* * Limit number of tasks checked in a batch. * @@ -115,6 +120,12 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) if (time_is_after_jiffies(t->last_switch_time + timeout * HZ)) return; + /* + * This counter tracks the total number of tasks detected as hung + * since boot. + */ + sysctl_hung_task_detect_count++; + trace_sched_process_hang(t); if (sysctl_hung_task_panic) { @@ -314,6 +325,13 @@ static struct ctl_table hung_task_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_NEG_ONE, }, + { + .procname = "hung_task_detect_count", + .data = &sysctl_hung_task_detect_count, + .maxlen = sizeof(unsigned long), + .mode = 0444, + .proc_handler = proc_dointvec, + }, }; static void __init hung_task_sysctl_init(void)