Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4404227yba; Tue, 9 Apr 2019 18:40:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGYahyNygMmyN8wNU/t6FPLs9dG2i5I5jEAK0Nl+/cZNJLKRspFHGoTJXSW4bi78w7vaKf X-Received: by 2002:a63:6849:: with SMTP id d70mr37857767pgc.21.1554860430614; Tue, 09 Apr 2019 18:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554860430; cv=none; d=google.com; s=arc-20160816; b=P5ULk9+x33pi+Mny/yPhY43iGbzluGvZOzf4+0PXb9cz8AKZ+X11nnF+9WW6m9lIEp 5kQqVYrMY/isFXvww12NCy4/O4OnHdlSuuAPqHaQGfCzPSPhTmCGjHk4XCDvY/uTSifS Z2gxIKYgWWKTXjNnIxdav7YLAWzw35IcB5SpNGnuzwXk9jcnPBLbMO/HwGj8mWzdiaQ2 bkH/pBGp4Y58cFtpcso88bwrb1S2ONIfoOCiMibw4t3vPPDtl3ZsfBKW71kO+fLyyI6n KI4cuzf4tA7GvhfsonDDJPE0ZaPjBPUTq6FPIHE/z5eZx8GD+HS/amNU4RuFrAFCRDUf 6ggQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=t1fyBw69Kdg/wkPZbUaMvmY2QMqliEsTRkKhG/EJu4c=; b=J9s+kuP5IfnqGZUyUdmQEdwUGalE/GJrSi7RGppAC5au2c5BwzYxJ63Wadnve2O2G5 QLbjq0gFFLx0Ex0Bv9ZiUHlXHhYTFG3TxNE5x9FyENaGsUEi33JsGyBOetDcDHXC2dtR AYoP2eGEnqZ0DkVsVzMVoypUE+PuZcTYFJ/n/jzVnN94eBbKWjG2dMlYlrMSKo0miB0w ymE8rtMkZwE4jdo3XFW6MhoRxHAW5LQpbofS2a8E1Vtjf7oyHnM9ICk6BkHSoicDWoAv EsUTy2HWqj79Rtx7/SPxinXqI1ftpuqomjob3fLwx27cCLMyVMPTOct28KiyMsyqnhwP gOAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si30583098plm.171.2019.04.09.18.40.13; Tue, 09 Apr 2019 18:40:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbfDJBOT (ORCPT + 99 others); Tue, 9 Apr 2019 21:14:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:15468 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfDJBOT (ORCPT ); Tue, 9 Apr 2019 21:14:19 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2019 18:14:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,331,1549958400"; d="scan'208";a="141418189" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga003.jf.intel.com with ESMTP; 09 Apr 2019 18:14:17 -0700 Date: Tue, 9 Apr 2019 18:13:07 -0700 From: Ricardo Neri To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Ashok Raj , Andi Kleen , "Ravi V. Shankar" , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "H. Peter Anvin" , Tony Luck , Clemens Ladisch , Arnd Bergmann , Philippe Ombredanne , Kate Stewart , "Rafael J. Wysocki" , Mimi Zohar , Jan Kiszka , Nick Desaulniers , Masahiro Yamada , Nayna Jain Subject: Re: [RFC PATCH v2 11/14] x86/watchdog/hardlockup: Add an HPET-based hardlockup detector Message-ID: <20190410011307.GB10062@ranerica-svr.sc.intel.com> References: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> <1551283518-18922-12-git-send-email-ricardo.neri-calderon@linux.intel.com> <20190409105946.GR4038@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190409105946.GR4038@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 09, 2019 at 12:59:46PM +0200, Peter Zijlstra wrote: > On Tue, Mar 26, 2019 at 09:49:13PM +0100, Thomas Gleixner wrote: > > So way you should handle this is: > > > > cpumask_set_cpu(cpu, hld_data->cpu_monitored_mask); > > > > if (!hld_data->enabled_cpus++) { > > hld_data->handling_cpu = cpu; > > kick_timer(); > > enable_timer(); > > } > > > > The cpu mask starts off empty and each CPU sets itself when the function is > > invoked on it. > > > > data->enabled_cpus keeps track of the enabled cpus so you avoid > > reconfiguration just because a different cpu comes online. And it's > > required for disable as well. > > > > > +void hardlockup_detector_hpet_disable(void) > > > +{ > > > + struct cpumask *allowed = watchdog_get_allowed_cpumask(); > > > + > > > + if (!hld_data) > > > + return; > > > + > > > + /* Only disable the timer if there are no more CPUs to monitor. */ > > > + if (!cpumask_weight(allowed)) > > > + disable_timer(hld_data); > > > > Again this should be: > > > > cpumask_clear_cpu(cpu, hld_data->cpu_monitored_mask); > > hld_data->enabled_cpus--; > > > > if (hld_data->handling_cpu != cpu) > > return; > > > > disable_timer(); > > if (hld_data->enabled_cpus) > > return; > > if (!hld_data->enabled_cpus) > return; > > > > > hld_data->handling_cpu = cpumask_first(hld_data->cpu_monitored_mask); > > enable_timer(); > > That said; you can do the above without ->enabled_cpus, by using > ->handling_cpu == nr_cpu_ids to indicate 'empty'. But I'm not at all > sure that is worth the effort, it results in less obious code. I agree. It is probably clearer to check for !hld_data->enabled_cpus as it clearly indicates what happens if there are no more CPUs to monitor. Thanks and BR, Ricardo