* [PATCH] hung_task : check the value of "sysctl_hung_task_timeout_sec"
[not found] <1394089669-18285-1-git-send-email-sdu.liu@huawei.com>
@ 2014-03-06 7:19 ` Liu hua
2014-03-06 15:35 ` Paul Gortmaker
0 siblings, 1 reply; 3+ messages in thread
From: Liu hua @ 2014-03-06 7:19 UTC (permalink / raw)
To: Ingo Molnar; +Cc: oleg, paul.gortmaker, Li Zefan, Wang Nan, linux-kernel
As sysctl_hung_task_timeout_sec is unsigned long, when this value is
larger then LONG_MAX, the function schedule_timeout_interruptible in
watchdog will return immediately without sleep :
for example (in x86_64 platform):
linux# echo 0xFFFFFFFFFFFFFFFF > /proc/sys/kernel/hung_task_timeout_secs
[ 66.798350] schedule_timeout: wrong timeout value ffffffffffffff06
[ 66.800064] schedule_timeout: wrong timeout value ffffffffffffff06
[ 66.801774] schedule_timeout: wrong timeout value ffffffffffffff06
[ 66.803488] schedule_timeout: wrong timeout value ffffffffffffff06
[ 66.805225] schedule_timeout: wrong timeout value ffffffffffffff06
The screen was filled with "schedule_timeout: wrong timeout value
ffffffffffffff06" and the system stalled.
So I do some check and correction in timeout_jiffies, to let the function
schedule_timeout_interruptible allways get the valid parameter.
Signed-off-by: Liu Hua <sdu.liu@huawei.com>
---
kernel/hung_task.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 06bb141..ef96650 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -186,7 +186,16 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
static unsigned long timeout_jiffies(unsigned long timeout)
{
/* timeout of 0 will disable the watchdog */
- return timeout ? timeout * HZ : MAX_SCHEDULE_TIMEOUT;
+ if ((timeout == 0) || (timeout > MAX_SCHEDULE_TIMEOUT)) {
+ pr_err("%s : wrong timeout value %lx\n",
+ __func__, timeout);
+ pr_err("Timeout value is set to MAX_SCHEDULE_TIMEOUT(%lx) now.\n",
+ MAX_SCHEDULE_TIMEOUT);
+ return MAX_SCHEDULE_TIMEOUT;
+ }
+
+ return (timeout * HZ) < MAX_SCHEDULE_TIMEOUT ?
+ timeout * HZ : MAX_SCHEDULE_TIMEOUT;
}
/*
--
1.8.5.5.dirty
.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hung_task : check the value of "sysctl_hung_task_timeout_sec"
2014-03-06 7:19 ` [PATCH] hung_task : check the value of "sysctl_hung_task_timeout_sec" Liu hua
@ 2014-03-06 15:35 ` Paul Gortmaker
2014-03-10 3:34 ` Liu hua
0 siblings, 1 reply; 3+ messages in thread
From: Paul Gortmaker @ 2014-03-06 15:35 UTC (permalink / raw)
To: Liu hua, Ingo Molnar; +Cc: oleg, Li Zefan, Wang Nan, linux-kernel
On 14-03-06 02:19 AM, Liu hua wrote:
> As sysctl_hung_task_timeout_sec is unsigned long, when this value is
> larger then LONG_MAX, the function schedule_timeout_interruptible in
> watchdog will return immediately without sleep :
>
> for example (in x86_64 platform):
>
> linux# echo 0xFFFFFFFFFFFFFFFF > /proc/sys/kernel/hung_task_timeout_secs
>
> [ 66.798350] schedule_timeout: wrong timeout value ffffffffffffff06
> [ 66.800064] schedule_timeout: wrong timeout value ffffffffffffff06
> [ 66.801774] schedule_timeout: wrong timeout value ffffffffffffff06
> [ 66.803488] schedule_timeout: wrong timeout value ffffffffffffff06
> [ 66.805225] schedule_timeout: wrong timeout value ffffffffffffff06
>
> The screen was filled with "schedule_timeout: wrong timeout value
> ffffffffffffff06" and the system stalled.
>
> So I do some check and correction in timeout_jiffies, to let the function
> schedule_timeout_interruptible allways get the valid parameter.
>
> Signed-off-by: Liu Hua <sdu.liu@huawei.com>
> ---
> kernel/hung_task.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> index 06bb141..ef96650 100644
> --- a/kernel/hung_task.c
> +++ b/kernel/hung_task.c
> @@ -186,7 +186,16 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
> static unsigned long timeout_jiffies(unsigned long timeout)
> {
> /* timeout of 0 will disable the watchdog */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You are breaking the above functionality/feature by declaring
zero invalid.
Paul.
--
> - return timeout ? timeout * HZ : MAX_SCHEDULE_TIMEOUT;
> + if ((timeout == 0) || (timeout > MAX_SCHEDULE_TIMEOUT)) {
> + pr_err("%s : wrong timeout value %lx\n",
> + __func__, timeout);
> + pr_err("Timeout value is set to MAX_SCHEDULE_TIMEOUT(%lx) now.\n",
> + MAX_SCHEDULE_TIMEOUT);
> + return MAX_SCHEDULE_TIMEOUT;
> + }
> +
> + return (timeout * HZ) < MAX_SCHEDULE_TIMEOUT ?
> + timeout * HZ : MAX_SCHEDULE_TIMEOUT;
> }
>
> /*
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hung_task : check the value of "sysctl_hung_task_timeout_sec"
2014-03-06 15:35 ` Paul Gortmaker
@ 2014-03-10 3:34 ` Liu hua
0 siblings, 0 replies; 3+ messages in thread
From: Liu hua @ 2014-03-10 3:34 UTC (permalink / raw)
To: Paul Gortmaker, Ingo Molnar; +Cc: oleg, Li Zefan, Wang Nan, linux-kernel
on 2014/3/6 23:35, Paul Gortmaker wrote:
> On 14-03-06 02:19 AM, Liu hua wrote:
>> As sysctl_hung_task_timeout_sec is unsigned long, when this value is
>> larger then LONG_MAX, the function schedule_timeout_interruptible in
>> watchdog will return immediately without sleep :
>>
>> for example (in x86_64 platform):
>>
>> linux# echo 0xFFFFFFFFFFFFFFFF > /proc/sys/kernel/hung_task_timeout_secs
>>
>> [ 66.798350] schedule_timeout: wrong timeout value ffffffffffffff06
>> [ 66.800064] schedule_timeout: wrong timeout value ffffffffffffff06
>> [ 66.801774] schedule_timeout: wrong timeout value ffffffffffffff06
>> [ 66.803488] schedule_timeout: wrong timeout value ffffffffffffff06
>> [ 66.805225] schedule_timeout: wrong timeout value ffffffffffffff06
>>
>> The screen was filled with "schedule_timeout: wrong timeout value
>> ffffffffffffff06" and the system stalled.
>>
>> So I do some check and correction in timeout_jiffies, to let the function
>> schedule_timeout_interruptible allways get the valid parameter.
>>
>> Signed-off-by: Liu Hua <sdu.liu@huawei.com>
>> ---
>> kernel/hung_task.c | 11 ++++++++++-
>> 1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/hung_task.c b/kernel/hung_task.c
>> index 06bb141..ef96650 100644
>> --- a/kernel/hung_task.c
>> +++ b/kernel/hung_task.c
>> @@ -186,7 +186,16 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
>> static unsigned long timeout_jiffies(unsigned long timeout)
>> {
>> /* timeout of 0 will disable the watchdog */
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> You are breaking the above functionality/feature by declaring
> zero invalid.
>
> Paul.
> --
>
Actually the patch will disable the watchdog if the timeout is illegal(except 0) for
schedule_timeout_interruptible.
I will make a new patch that disables the watchdog when the timeout is 0 or above
LONG_MAX without printing errors ?
What do you think?
Liu Hua
>> - return timeout ? timeout * HZ : MAX_SCHEDULE_TIMEOUT;
>> + if ((timeout == 0) || (timeout > MAX_SCHEDULE_TIMEOUT)) {
>> + pr_err("%s : wrong timeout value %lx\n",
>> + __func__, timeout);
>> + pr_err("Timeout value is set to MAX_SCHEDULE_TIMEOUT(%lx) now.\n",
>> + MAX_SCHEDULE_TIMEOUT);
>> + return MAX_SCHEDULE_TIMEOUT;
>> + }
>> +
>> + return (timeout * HZ) < MAX_SCHEDULE_TIMEOUT ?
>> + timeout * HZ : MAX_SCHEDULE_TIMEOUT;
>> }
>>
>> /*
>>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-10 3:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1394089669-18285-1-git-send-email-sdu.liu@huawei.com>
2014-03-06 7:19 ` [PATCH] hung_task : check the value of "sysctl_hung_task_timeout_sec" Liu hua
2014-03-06 15:35 ` Paul Gortmaker
2014-03-10 3:34 ` Liu hua
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox