Re: [PATCH -rt] Updates-from-Jon-Masters-for-hwlat_detector.c.patch

From: John Kacur
Date: Mon Nov 02 2009 - 14:46:21 EST


On Mon, Nov 2, 2009 at 4:43 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> Hi,
>
> On Fri, 23 Oct 2009, John Kacur wrote:
>> 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.
>
>> diff --git a/drivers/misc/hwlat_detector.c b/drivers/misc/hwlat_detector.c
>> index be6553f..7191e17 100644
>> --- a/drivers/misc/hwlat_detector.c
>> +++ b/drivers/misc/hwlat_detector.c
>> @@ -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) */
>> -
>
> 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
> --

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 <jcm@xxxxxxxxxxxxxx>
Date: Thu, 22 Oct 2009 19:33:56 +0200
Subject: [PATCH] Updates from Jon Masters for hwlat_detector.c

Signed-off-by: Jon Masters <jcm@xxxxxxxxxxxxxx>
Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
drivers/misc/Kconfig | 2 +-
drivers/misc/hwlat_detector.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 15cd6bc..35f441c 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -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
diff --git a/drivers/misc/hwlat_detector.c b/drivers/misc/hwlat_detector.c
index be6553f..0ffb43a 100644
--- a/drivers/misc/hwlat_detector.c
+++ b/drivers/misc/hwlat_detector.c
@@ -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();
--
1.6.0.6