[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170207072512.GB18584@gmail.com>
Date: Tue, 7 Feb 2017 08:25:12 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Robert Richter <rric@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Vince Weaver <vince@...ter.net>,
lkml <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] perf/stat: Add --disable-hwdt
* Borislav Petkov <bp@...en8.de> wrote:
> On Mon, Feb 06, 2017 at 02:18:32PM +0100, Robert Richter wrote:
>
> > Isn't there the danger the previous watchdog state is never restored if for
> > some reason perf got killed? So maybe have some other task running that
> > restores it once perf is gone.
>
> Currently, I'm restoring it in the atexit() sighandler. Isn't that always
> called?
Normally yes, but it's not guaranteed as atexit() is all user-space, SIGKILL (or
OOM) or a straight exit (or a crash in the exit handler itself) will cause it to
not run.
But there's only so much we can do about that, the /proc/sys API is fundamentally
lossy in that regard. We'd have to add much more involved kernel support to
guarantee that the watchdog state is restored.
A way to do it would be create a new /proc/sys/kernel/watchdog_disable_file that
disables that watchdog while it's _open_. When a task exits and the kernel
automatically closes the file, the watchdog is re-enabled again. (Or the process
itself can close the file too.)
This method would also nest properly and would handle multi-processes races
correctly: for example if a script runs perf as root, and root uses 'perf top',
the two should not race and the hardware watchdog should not end up being
disabled...
Thanks,
Ingo
Powered by blists - more mailing lists