Skip to contentSkip to conversation

Updates-from-Jon-Masters-for-hwlat_detector.c.patch

PATCH In review John Kacur 3 participants 6 messages Oct 22, 2009 – Nov 3, 2009 Char and misc drivers

lore
Share & tools
lore

John Kacur

author
#0 lore raw

PATCH 1/1 Updates-from-Jon-Masters-for-hwlat_detector.c.patch

Hello Thomas

I took Jon Masters' latest hwlat_detector patch for upstream, and grabbed the bits that aren't currently in -rt. The patch is fairly small.

Please consider it for the next -rt release.

John

Quoted 1 line

From 97e12a96f58eea70c6a223ac849ec894165884b5 Mon Sep 17 00:00:00 2001

From: Jon Masters <[email protected]>
Date: Thu, 22 Oct 2009 19:33:56 +0200
Subject: [PATCH] Updates from Jon Masters for hwlat_detector.c

---
 drivers/misc/Kconfig          |    2 +-
 drivers/misc/hwlat_detector.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/misc/Kconfig +1 -1
index 15cd6bc..35f441c 100644
@@ -95,7 +95,7 @@ config IBM_ASM
 config HWLAT_DETECTOR
 	tristate "Testing module to detect hardware-induced latencies"
 	depends on DEBUG_FS
-	select RING_BUFFER
+	depends on RING_BUFFER
 	default m
 	---help---
 	  A simple hardware latency detector. Use this module to detect
drivers/misc/hwlat_detector.c +12 -4
index be6553f..7191e17 100644
@@ -262,6 +262,8 @@ static int get_sample(void *unused)
 		/* Keep a running maximum ever recorded hardware latency */
 		if (sample > data.max_sample)
 			data.max_sample = sample;
+
+		wake_up(&data.wq); /* wake up reader(s) */
 	}
 
 	ret = 0;
@@ -299,8 +301,6 @@ static int kthread_fn(void *unused)
 			goto err_out;
 		}
 
-		wake_up(&data.wq); /* wake up reader(s) */
-
 		interval = data.sample_window - data.sample_width;
 		do_div(interval, USEC_PER_MSEC); /* modifies interval value */
 
@@ -607,7 +607,11 @@ static ssize_t  debug_enable_fwrite(struct file *filp,
 		if (!enabled)
 			goto unlock;
 		enabled = 0;
-		stop_kthread();
+		err = stop_kthread();
+		if (0 != err) {
+			printk(KERN_ERR BANNER "cannot stop kthread\n");
+			return -EFAULT;
+		}
 		wake_up(&data.wq);		/* reader(s) should return */
 	}
 unlock:
@@ -1194,9 +1198,13 @@ out:
  */
 static void detector_exit(void)
 {
+	int err;
+
 	if (enabled) {
 		enabled = 0;
-		stop_kthread();
+		err = stop_kthread();
+		if (0 != err)
+			printk(KERN_ERR BANNER "cannot stop kthread\n");
 	}
 
 	free_debugfs();
Signature · 1 line
1.6.0.6
#1 lore raw

Hi,

Quoted 4 lines · John Kacur

I took Jon Masters' latest hwlat_detector patch for upstream, and grabbed the bits that aren't currently in -rt. The patch is fairly small.

Please consider it for the next -rt release.

Not really.

Quoted 14 lines
drivers/misc/hwlat_detector.c +2 -0
index be6553f..7191e17 100644
@@ -262,6 +262,8 @@ static int get_sample(void *unused)
 		/* Keep a running maximum ever recorded hardware latency */
 		if (sample > data.max_sample)
 			data.max_sample = sample;
+
+		wake_up(&data.wq); /* wake up reader(s) */
 	}
 
 	ret = 0;

drivers/misc/hwlat_detector.c static int kthread_fn(void *unused) · line 303

Quoted 5 lines
drivers/misc/hwlat_detector.c +0 -2
@@ -299,8 +301,6 @@ static int kthread_fn(void *unused)
 			goto err_out;
 		}
 
-		wake_up(&data.wq); /* wake up reader(s) */
-

This reverts -rt commit 5fc485f6341c177e9d5f641c6fb9e33ca465aa84.

CONFIG_DEBUG_SPINLOCK_SLEEP resp. CONFIG_DEBUG_PREEMPT will tell you why this is a bad idea on -rt :)

Thanks,

tglx

author
#2 lore raw
Quoted 32 lines · Thomas Gleixner

Hi,

Quoted 4 lines · John Kacur

I took Jon Masters' latest hwlat_detector patch for upstream, and grabbed the bits that aren't currently in -rt. The patch is fairly small.

Please consider it for the next -rt release.

Not really.

Quoted 14 lines
drivers/misc/hwlat_detector.c +2 -0
index be6553f..7191e17 100644
@@ -262,6 +262,8 @@ static int get_sample(void *unused)
               /* Keep a running maximum ever recorded hardware latency */
               if (sample > data.max_sample)
                       data.max_sample = sample;
+
+             wake_up(&data.wq); /* wake up reader(s) */
       }
 
       ret = 0;

drivers/misc/hwlat_detector.c static int kthread_fn(void *unused) · line 303

Quoted 5 lines
drivers/misc/hwlat_detector.c +0 -2
@@ -299,8 +301,6 @@ static int kthread_fn(void *unused)
                       goto err_out;
               }
 
-             wake_up(&data.wq); /* wake up reader(s) */
-

This reverts -rt commit 5fc485f6341c177e9d5f641c6fb9e33ca465aa84.

Quoted 7 lines

CONFIG_DEBUG_SPINLOCK_SLEEP resp. CONFIG_DEBUG_PREEMPT will tell you why this is a bad idea on -rt :)

Thanks,

       tglx
--

Ugh. Thanks for catching that. To be honest not sure how it happened, so it must be my fault. :)

Updated patch just adds the error checking from Jon Masters then, patched against -rt.

From 06219178c632d9a949029ade1a85033629365dbf Mon Sep 17 00:00:00 2001
From: Jon Masters <[email protected]>
Date: Thu, 22 Oct 2009 19:33:56 +0200
Subject: [PATCH] Updates from Jon Masters for hwlat_detector.c

---
 drivers/misc/Kconfig          |    2 +-
 drivers/misc/hwlat_detector.c |   12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/misc/Kconfig +1 -1
index 15cd6bc..35f441c 100644
@@ -95,7 +95,7 @@ config IBM_ASM
 config HWLAT_DETECTOR
 	tristate "Testing module to detect hardware-induced latencies"
 	depends on DEBUG_FS
-	select RING_BUFFER
+	depends on RING_BUFFER
 	default m
 	---help---
 	  A simple hardware latency detector. Use this module to detect
drivers/misc/hwlat_detector.c +10 -2
index be6553f..0ffb43a 100644
@@ -607,7 +607,11 @@ static ssize_t  debug_enable_fwrite(struct file *filp,
 		if (!enabled)
 			goto unlock;
 		enabled = 0;
-		stop_kthread();
+		err = stop_kthread();
+		if (0 != err) {
+			printk(KERN_ERR BANNER "cannot stop kthread\n");
+			return -EFAULT;
+		}
 		wake_up(&data.wq);		/* reader(s) should return */
 	}
 unlock:
@@ -1194,9 +1198,13 @@ out:
  */
 static void detector_exit(void)
 {
+	int err;
+
 	if (enabled) {
 		enabled = 0;
-		stop_kthread();
+		err = stop_kthread();
+		if (0 != err)
+			printk(KERN_ERR BANNER "cannot stop kthread\n");
 	}
 
 	free_debugfs();
Signature · 1 line
1.6.0.6
#3 lore raw
Quoted 2 lines · John Kacur

Updated patch just adds the error checking from Jon Masters then, patched against -rt.

Can you please inline patches ?

@@ -607,7 +607,11 @@ static ssize_t debug_enable_fwrite(stru
if (!enabled)
goto unlock;
enabled = 0;
- stop_kthread();
+ err = stop_kthread();
+ if (0 != err) {

Eeew !

Thanks,

tglx

author
#4 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · John Kacur

Updated patch just adds the error checking from Jon Masters then, patched against -rt.

Can you please inline patches ?

drivers/misc/hwlat_detector.c static ssize_t debug_enable_fwrite(stru · line 613

Quoted 8 lines
drivers/misc/hwlat_detector.c +2 -1
@@ -607,7 +607,11 @@ static ssize_t  debug_enable_fwrite(stru
 		if (!enabled)
 			goto unlock;
 		enabled = 0;
-		stop_kthread();
+		err = stop_kthread();
+		if (0 != err) {
 
 	Eeew !	

Yeah, I saw that too and thought it a bit ugly. However, my goal was only to make sure that the latest version of Jon's hwlat patch got into -rt, so I didn't think it was my place to "fix" his style.

Note - even the much hated checkpatch program doesn't balk at that. However that is hardly an authority.

If you read the introduction to "Expert C Programming - Deep C Secrets", they mention that some programmers write
if (3==i)
instead of
if (i==3)

because if you mistakenly only type one '=', then the compiler can complain about it, instead of silently assigning 3 to i.

I can only guess that is the sort of idea / habit that Jon got that style from.

John

#5 lore raw
In reply to John Kacur
Quoted 29 lines · John Kacur
Quoted 27 lines · Thomas Gleixner
Quoted 14 lines
drivers/misc/hwlat_detector.c +2 -0
index be6553f..7191e17 100644
@@ -262,6 +262,8 @@ static int get_sample(void *unused)
              /* Keep a running maximum ever recorded hardware latency */
              if (sample > data.max_sample)
                      data.max_sample = sample;
+
+             wake_up(&data.wq); /* wake up reader(s) */
      }
 
      ret = 0;

drivers/misc/hwlat_detector.c static int kthread_fn(void *unused) · line 303

Quoted 5 lines
drivers/misc/hwlat_detector.c +0 -2
@@ -299,8 +301,6 @@ static int kthread_fn(void *unused)
                      goto err_out;
              }
 
-             wake_up(&data.wq); /* wake up reader(s) */
-

This reverts -rt commit 5fc485f6341c177e9d5f641c6fb9e33ca465aa84.

CONFIG_DEBUG_SPINLOCK_SLEEP resp. CONFIG_DEBUG_PREEMPT will tell you why this is a bad idea on -rt :)

Thanks,

Quoted 8 lines
Quoted 2 lines

tglx
--

Ugh. Thanks for catching that. To be honest not sure how it happened, so it must be my fault. :)

Updated patch just adds the error checking from Jon Masters then, patched against -rt.

Actually, I think it might be my fault. I'll talk to you about the best way to proceed with updates since we're still looking for a reproducer on that lockup Clark was seeing a while back.

Jon.