Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754143AbcJUDZb (ORCPT ); Thu, 20 Oct 2016 23:25:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39983 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752903AbcJUDZ3 (ORCPT ); Thu, 20 Oct 2016 23:25:29 -0400 Date: Thu, 20 Oct 2016 20:25:27 -0700 From: Andrew Morton To: Don Zickus Cc: Babu Moger , mingo@kernel.org, ak@linux.intel.com, jkosina@suse.cz, baiyaowei@cmss.chinamobile.com, atomlin@redhat.com, uobergfe@redhat.com, tj@kernel.org, hidehiro.kawai.ez@hitachi.com, johunt@akamai.com, davem@davemloft.net, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, sam@ravnborg.org Subject: Re: [PATCH v2 1/2] watchdog: Introduce arch_watchdog_nmi_enable and arch_watchdog_nmi_disable Message-Id: <20161020202527.b01839356c6d34ed0cba3569@linux-foundation.org> In-Reply-To: <20161020161414.GE35881@redhat.com> References: <1476391082-77928-1-git-send-email-babu.moger@oracle.com> <1476391082-77928-2-git-send-email-babu.moger@oracle.com> <20161019170012.6006d06d9326e62a8059fd08@linux-foundation.org> <20161020161414.GE35881@redhat.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1528 Lines: 37 On Thu, 20 Oct 2016 12:14:14 -0400 Don Zickus wrote: > > > -static int watchdog_nmi_enable(unsigned int cpu) { return 0; } > > > -static void watchdog_nmi_disable(unsigned int cpu) { return; } > > > +/* > > > + * These two functions are mostly architecture specific > > > + * defining them as weak here. > > > + */ > > > +int __weak arch_watchdog_nmi_enable(unsigned int cpu) { return 0; } > > > +void __weak arch_watchdog_nmi_disable(unsigned int cpu) { return; } > > > + > > > #endif /* CONFIG_HARDLOCKUP_DETECTOR */ > > > > This is a strange way of using __weak. > > > > Take a look at (one of many examples) kernel/module.c:module_alloc(). > > We simply provide a default implementation and some other compilation > > unit can override (actually replace) that at link time. No strange > > ifdeffing needed. > > Yeah, this is mostly because of how we enable the hardlockup detector. > > Some arches use the perf hw and enable CONFIG_HARDLOCKUP_DETECTOR. Other > arches just use their own variant of nmi and set CONFIG_HAVE_NMI_WATCHDOG and > the rest of the arches do not use this. > > So the thought was if CONFIG_HARDLOCKUP_DETECTOR use that implementation, > everyone else use the __weak version. Then the arches like sparc can override > the weak version with their own nmi enablement. > > I don't know how to represent those 3 states correctly and the above is what > we end up with. Is there a suitable site where we could capture these considerations in a code comment?