Skip to content

Commit a1ee193

Browse files
joshhunt-akamaitorvalds
authored andcommitted
watchdog: don't run proc_watchdog_update if new value is same as old
While working on a script to restore all sysctl params before a series of tests I found that writing any value into the /proc/sys/kernel/{nmi_watchdog,soft_watchdog,watchdog,watchdog_thresh} causes them to call proc_watchdog_update(). NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. There doesn't appear to be a reason for doing this work every time a write occurs, so only do it when the values change. Signed-off-by: Josh Hunt <[email protected]> Acked-by: Don Zickus <[email protected]> Reviewed-by: Aaron Tomlin <[email protected]> Cc: Ulrich Obergfell <[email protected]> Cc: <[email protected]> [4.1.x+] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4c11e55 commit a1ee193

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/watchdog.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,9 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
923923
* both lockup detectors are disabled if proc_watchdog_update()
924924
* returns an error.
925925
*/
926+
if (old == new)
927+
goto out;
928+
926929
err = proc_watchdog_update();
927930
}
928931
out:
@@ -967,7 +970,7 @@ int proc_soft_watchdog(struct ctl_table *table, int write,
967970
int proc_watchdog_thresh(struct ctl_table *table, int write,
968971
void __user *buffer, size_t *lenp, loff_t *ppos)
969972
{
970-
int err, old;
973+
int err, old, new;
971974

972975
get_online_cpus();
973976
mutex_lock(&watchdog_proc_mutex);
@@ -987,6 +990,10 @@ int proc_watchdog_thresh(struct ctl_table *table, int write,
987990
/*
988991
* Update the sample period. Restore on failure.
989992
*/
993+
new = ACCESS_ONCE(watchdog_thresh);
994+
if (old == new)
995+
goto out;
996+
990997
set_sample_period();
991998
err = proc_watchdog_update();
992999
if (err) {

0 commit comments

Comments
 (0)