watchdog: using u64 in get_sample_period()
PATCH 1/1 watchdog: using u64 in get_sample_period()
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
Quoted 1 line
From case2, we need use u64 to express the sample period.
Otherwise, Changing the threshold thru proc often can not be successful.
--- kernel/watchdog.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/watchdog.c +2 -2
@@ -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 */
Signature · 1 line
1.7.0.4
Quoted 7 lines · Chuansheng Liu
In
get_sample_period(), unsigned long is not enough:watchdog_thresh* 2 * (NSEC_PER_SEC/ 5)case1:
watchdog_threshis 10 by default,
the sample value will be:0xEE6B2800
Quoted 6 lines
case2: set
watchdog_threshis 20,
the sample value will be:0x1DCD6 5000Quoted 1 line
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.
Quoted 33 lines
Signed-off-by liu chuansheng <[email protected]>--- kernel/watchdog.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)kernel/watchdog.c +2
-2@@ -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 */ Signature · 1 line
1.7.0.4