All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: using u64 in get_sample_period()
@ 2012-11-21 10:56 Chuansheng Liu
  2012-11-21 13:57 ` Don Zickus
  0 siblings, 1 reply; 2+ messages in thread
From: Chuansheng Liu @ 2012-11-21 10:56 UTC (permalink / raw)
  To: akpm, dzickus, mingo; +Cc: linux-kernel, chuansheng.liu


In get_sample_period(), unsigned long is not enough:
watchdog_thresh * 2 * (NSEC_PER_SEC / 5)

case1: watchdog_thresh is 10 by default,
the sample value will be: 0xEE6B 2800

case2: set watchdog_thresh is 20,
the sample value will be: 0x1 DCD6 5000

>From case2, we need use u64 to express the sample period.
Otherwise, Changing the threshold thru proc often can
not be successful.

Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
 kernel/watchdog.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 9d4c8d5..dd4b80a 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -116,7 +116,7 @@ static unsigned long get_timestamp(int this_cpu)
 	return cpu_clock(this_cpu) >> 30LL;  /* 2^30 ~= 10^9 */
 }
 
-static unsigned long get_sample_period(void)
+static u64 get_sample_period(void)
 {
 	/*
 	 * convert watchdog_thresh from seconds to ns
@@ -125,7 +125,7 @@ static unsigned long get_sample_period(void)
 	 * and hard thresholds) to increment before the
 	 * hardlockup detector generates a warning
 	 */
-	return get_softlockup_thresh() * (NSEC_PER_SEC / 5);
+	return get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
 }
 
 /* Commands for resetting the watchdog */
-- 
1.7.0.4




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: using u64 in get_sample_period()
  2012-11-21 10:56 [PATCH] watchdog: using u64 in get_sample_period() Chuansheng Liu
@ 2012-11-21 13:57 ` Don Zickus
  0 siblings, 0 replies; 2+ messages in thread
From: Don Zickus @ 2012-11-21 13:57 UTC (permalink / raw)
  To: Chuansheng Liu; +Cc: akpm, mingo, linux-kernel

On Wed, Nov 21, 2012 at 06:56:07PM +0800, Chuansheng Liu wrote:
> 
> In get_sample_period(), unsigned long is not enough:
> watchdog_thresh * 2 * (NSEC_PER_SEC / 5)
> 
> case1: watchdog_thresh is 10 by default,
> the sample value will be: 0xEE6B 2800
> 
> case2: set watchdog_thresh is 20,
> the sample value will be: 0x1 DCD6 5000
> 
> >From case2, we need use u64 to express the sample period.
> Otherwise, Changing the threshold thru proc often can
> not be successful.

I guess I should have tested 32-bit more. :-) Good catch.

Acked-by: Don Zickus <dzickus@redhat.com>

> 
> Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
> ---
>  kernel/watchdog.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index 9d4c8d5..dd4b80a 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -116,7 +116,7 @@ static unsigned long get_timestamp(int this_cpu)
>  	return cpu_clock(this_cpu) >> 30LL;  /* 2^30 ~= 10^9 */
>  }
>  
> -static unsigned long get_sample_period(void)
> +static u64 get_sample_period(void)
>  {
>  	/*
>  	 * convert watchdog_thresh from seconds to ns
> @@ -125,7 +125,7 @@ static unsigned long get_sample_period(void)
>  	 * and hard thresholds) to increment before the
>  	 * hardlockup detector generates a warning
>  	 */
> -	return get_softlockup_thresh() * (NSEC_PER_SEC / 5);
> +	return get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
>  }
>  
>  /* Commands for resetting the watchdog */
> -- 
> 1.7.0.4
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-21 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-21 10:56 [PATCH] watchdog: using u64 in get_sample_period() Chuansheng Liu
2012-11-21 13:57 ` Don Zickus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.