Skip to content

Commit 647750d

Browse files
joshhunt-akamaiDinh Nguyen
authored andcommitted
watchdog: don't run proc_watchdog_update if new value is same as old
[ Upstream commit a1ee193 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 59a0bb2 commit 647750d

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
@@ -823,6 +823,9 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
823823
* Update the run state of the lockup detectors.
824824
* Restore 'watchdog_enabled' on failure.
825825
*/
826+
if (old == new)
827+
goto out;
828+
826829
err = proc_watchdog_update();
827830
if (err)
828831
watchdog_enabled = old;
@@ -868,7 +871,7 @@ int proc_soft_watchdog(struct ctl_table *table, int write,
868871
int proc_watchdog_thresh(struct ctl_table *table, int write,
869872
void __user *buffer, size_t *lenp, loff_t *ppos)
870873
{
871-
int err, old;
874+
int err, old, new;
872875

873876
mutex_lock(&watchdog_proc_mutex);
874877

@@ -882,6 +885,10 @@ int proc_watchdog_thresh(struct ctl_table *table, int write,
882885
* Update the sample period.
883886
* Restore 'watchdog_thresh' on failure.
884887
*/
888+
new = ACCESS_ONCE(watchdog_thresh);
889+
if (old == new)
890+
goto out;
891+
885892
set_sample_period();
886893
err = proc_watchdog_update();
887894
if (err)

0 commit comments

Comments
 (0)