[PATCH v2 7/7] Test softlockup

From: Petr Mladek
Date: Thu Dec 10 2020 - 11:03:18 EST


Trigger busy loop by:
$> cat /proc/version

Stop the busy loop by:
$> cat /proc/consoles

The code also shows the first touch*watchdog() function that hides
softlockup on a "well known" location.

Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
fs/proc/consoles.c | 5 +++++
fs/proc/version.c | 7 +++++++
2 files changed, 12 insertions(+)

diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index dfe6ce3505ce..213c0a209a7c 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -9,6 +9,8 @@
#include <linux/seq_file.h>
#include <linux/tty_driver.h>

+extern volatile bool proc_version_wait;
+
/*
* This is handler for /proc/consoles
*/
@@ -30,6 +32,9 @@ static int show_console_dev(struct seq_file *m, void *v)
unsigned int a;
dev_t dev = 0;

+ printk("%s: Going to break /proc/version infinite loop\n", __func__);
+ proc_version_wait = false;
+
if (con->device) {
const struct tty_driver *driver;
int index;
diff --git a/fs/proc/version.c b/fs/proc/version.c
index b449f186577f..15ec6a502589 100644
--- a/fs/proc/version.c
+++ b/fs/proc/version.c
@@ -6,8 +6,15 @@
#include <linux/seq_file.h>
#include <linux/utsname.h>

+volatile bool proc_version_wait;
+
static int version_proc_show(struct seq_file *m, void *v)
{
+ printk("%s: Going to wait until stopped\n", __func__);
+ proc_version_wait = true;
+ while (proc_version_wait)
+ cpu_relax();
+
seq_printf(m, linux_proc_banner,
utsname()->sysname,
utsname()->release,
--
2.26.2