From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753064AbdBGHZR (ORCPT ); Tue, 7 Feb 2017 02:25:17 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35876 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752857AbdBGHZQ (ORCPT ); Tue, 7 Feb 2017 02:25:16 -0500 Date: Tue, 7 Feb 2017 08:25:12 +0100 From: Ingo Molnar To: Borislav Petkov Cc: Robert Richter , Arnaldo Carvalho de Melo , Peter Zijlstra , Vince Weaver , lkml Subject: Re: [RFC PATCH] perf/stat: Add --disable-hwdt Message-ID: <20170207072512.GB18584@gmail.com> References: <20170206121506.mtknwusus4djp2sx@pd.tnic> <20170206122231.GA9404@gmail.com> <20170206124116.7jmrmufthqtnd3dc@pd.tnic> <20170206124447.GA12772@gmail.com> <20170206124937.zlowglr5gpq35piy@pd.tnic> <20170206131832.GG4906@rric.localdomain> <20170206132349.bl6qbpjflez3lpkp@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170206132349.bl6qbpjflez3lpkp@pd.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Borislav Petkov 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