lkml.org 
[lkml]   [2013]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] watchdog: update watchdog attributes atomically
On Fri, Jul 26, 2013 at 02:49:34PM +0200, Michal Hocko wrote:
> proc_dowatchdog doesn't synchronize multiple callers which
> might lead to confusion when two parallel callers might confuse
> watchdog_enable_all_cpus resp. watchdog_disable_all_cpus (e.g. watchdog
> gets enabled even if watchdog_thresh was set to 0 already).
>
> This patch adds a local mutex which synchronizes callers to the sysctl
> handler.
>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>

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


> ---
> kernel/watchdog.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index 1241d8c..2d64c02 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -520,13 +520,15 @@ int proc_dowatchdog(struct ctl_table *table, int write,
> void __user *buffer, size_t *lenp, loff_t *ppos)
> {
> int err, old_thresh, old_enabled;
> + static DEFINE_MUTEX(watchdog_proc_mutex);
>
> + mutex_lock(&watchdog_proc_mutex);
> old_thresh = ACCESS_ONCE(watchdog_thresh);
> old_enabled = ACCESS_ONCE(watchdog_user_enabled);
>
> err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
> if (err || !write)
> - return err;
> + goto out;
>
> set_sample_period();
> /*
> @@ -544,7 +546,8 @@ int proc_dowatchdog(struct ctl_table *table, int write,
> watchdog_thresh = old_thresh;
> watchdog_user_enabled = old_enabled;
> }
> -
> +out:
> + mutex_unlock(&watchdog_proc_mutex);
> return err;
> }
> #endif /* CONFIG_SYSCTL */
> --
> 1.8.3.2
>


\
 
 \ /
  Last update: 2013-07-26 19:01    [W:1.418 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site