samples-extend-hung_task-detector-test-with-semaphore-support.patch removed from -mm tree
The quilt patch titled
Subject: samples: extend hung_task detector test with semaphore support
has been removed from the -mm tree. Its filename was
samples-extend-hung_task-detector-test-with-semaphore-support.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Zi Li <[email protected]>
Subject: samples: extend hung_task detector test with semaphore support
Date: Mon, 14 Apr 2025 22:59:45 +0800
Extend the existing hung_task detector test module to support multiple lock types, including mutex and semaphore, with room for future additions (e.g., spinlock, etc.). This module creates dummy files under <debugfs>/hung_task, such as 'mutex' and 'semaphore'. The read process on any of these files will sleep for enough long time (256 seconds) while holding the respective lock. As a result, the second process will wait on the lock for a prolonged duration and be detected by the hung_task detector.
This change unifies the previous mutex-only sample into a single, extensible hung_task_tests module, reducing code duplication and improving maintainability.
Usage is:
> cd /sys/kernel/debug/hung_task
> cat mutex & cat mutex # Test mutex blocking
> cat semaphore & cat semaphore # Test semaphore blocking
Update the Kconfig description to reflect multiple debugfs files support.
---
samples/Kconfig | 9 +- samples/hung_task/Makefile | 2 samples/hung_task/hung_task_mutex.c | 66 ----------------- samples/hung_task/hung_task_tests.c | 97 ++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 71 deletions(-)
samples/hung_task/hung_task_mutex.c deleted +0 -66
@@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* hung_task_mutex.c - Sample code which causes hung task by mutex -* -* Usage: load this module and read `<debugfs>/hung_task/mutex` -* by 2 or more processes. -* -* This is for testing kernel hung_task error message. -* Note that this will make your system freeze and maybe -* cause panic. So do not use this except for the test. -*/ - -#include <linux/debugfs.h> -#include <linux/delay.h> -#include <linux/fs.h> -#include <linux/module.h> -#include <linux/mutex.h> - -#define HUNG_TASK_DIR "hung_task" -#define HUNG_TASK_FILE "mutex" -#define SLEEP_SECOND 256 - -static const char dummy_string[] ="This is a dummy string." ; -static DEFINE_MUTEX (dummy_mutex); -static struct dentry *hung_task_dir; - -static ssize_t read_dummy (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -/* If the second task waits on the lock, it is uninterruptible sleep. */ -guard (mutex)(&dummy_mutex); - -/* When the first task sleep here, it is interruptible. */ -msleep_interruptible (SLEEP_SECOND *1000 ); - -return simple_read_from_buffer (user_buf, count, ppos, - dummy_string,sizeof (dummy_string)); -} - -static const struct file_operations hung_task_fops = { - .read = read_dummy, -}; - -static int __init hung_task_sample_init (void ) -{ - hung_task_dir =debugfs_create_dir (HUNG_TASK_DIR ,NULL ); -if (IS_ERR (hung_task_dir)) -return PTR_ERR (hung_task_dir); - -debugfs_create_file (HUNG_TASK_FILE ,0400 , hung_task_dir, -NULL , &hung_task_fops); - -return 0 ; -} - -static void __exit hung_task_sample_exit(void) -{ -debugfs_remove_recursive (hung_task_dir); -} - -module_init (hung_task_sample_init); -module_exit (hung_task_sample_exit); - -MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Masami Hiramatsu" ); -MODULE_DESCRIPTION ("Simple sleep under mutex file for testing hung task" );
samples/hung_task/hung_task_tests.c new file +97 -0
97 lines not on this page · raw message
samples/hung_task/Makefile renamed from samples/hung_task/Makefile~samples-extend-hung_task-detector-test-with-semaphore-support +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_SAMPLE_HUNG_TASK) += hung_task_mutex.o +obj-$(CONFIG_SAMPLE_HUNG_TASK) += hung_task_tests.o
samples/Kconfig renamed from samples/Kconfig~samples-extend-hung_task-detector-test-with-semaphore-support +5 -4
@@ -304,10 +304,11 @@ config SAMPLE_HUNG_TASK tristate "Hung task detector test code" depends on DETECT_HUNG_TASK && DEBUG_FS help - Build a module which provide a simple debugfs file. If user reads - the file, it will sleep long time (256 seconds) with holding a - mutex. Thus if there are 2 or more processes read this file, it - will be detected by the hung_task watchdog. + Build a module that provides debugfs files (e.g., mutex, semaphore, + etc.) under <debugfs>/hung_task. If user reads one of these files, + it will sleep long time (256 seconds) with holding a lock. Thus, + if 2 or more processes read the same file concurrently, it will + be detected by the hung_task watchdog. source "samples/rust/Kconfig"
_
Patches currently in -mm which might be from [email protected] are