Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489AbdGYQXA (ORCPT ); Tue, 25 Jul 2017 12:23:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34838 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752243AbdGYQW7 (ORCPT ); Tue, 25 Jul 2017 12:22:59 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 233D6654A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzickus@redhat.com Date: Tue, 25 Jul 2017 12:22:55 -0400 From: Don Zickus To: Scott Wood Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/nmi: Use raw lock Message-ID: <20170725162255.qeduzogbzqu5al5m@redhat.com> References: <20170724213242.27598-1-swood@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170724213242.27598-1-swood@redhat.com> User-Agent: NeoMutt/20170428-dirty (1.8.2) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 25 Jul 2017 16:22:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2822 Lines: 91 On Mon, Jul 24, 2017 at 04:32:42PM -0500, Scott Wood wrote: > register_nmi_handler() can be called from PREEMPT_RT atomic context > (e.g. wakeup_cpu_via_init_nmi() or native_stop_other_cpus()), and thus > ordinary spinlocks cannot be used. Yeah, I guess we have a few awkward places where we register an nmi handler. Acked-by: Don Zickus > > Signed-off-by: Scott Wood > --- > arch/x86/kernel/nmi.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c > index 446c8aa09b9b..35aafc95e4b8 100644 > --- a/arch/x86/kernel/nmi.c > +++ b/arch/x86/kernel/nmi.c > @@ -39,26 +39,26 @@ > #include > > struct nmi_desc { > - spinlock_t lock; > + raw_spinlock_t lock; > struct list_head head; > }; > > static struct nmi_desc nmi_desc[NMI_MAX] = > { > { > - .lock = __SPIN_LOCK_UNLOCKED(&nmi_desc[0].lock), > + .lock = __RAW_SPIN_LOCK_UNLOCKED(&nmi_desc[0].lock), > .head = LIST_HEAD_INIT(nmi_desc[0].head), > }, > { > - .lock = __SPIN_LOCK_UNLOCKED(&nmi_desc[1].lock), > + .lock = __RAW_SPIN_LOCK_UNLOCKED(&nmi_desc[1].lock), > .head = LIST_HEAD_INIT(nmi_desc[1].head), > }, > { > - .lock = __SPIN_LOCK_UNLOCKED(&nmi_desc[2].lock), > + .lock = __RAW_SPIN_LOCK_UNLOCKED(&nmi_desc[2].lock), > .head = LIST_HEAD_INIT(nmi_desc[2].head), > }, > { > - .lock = __SPIN_LOCK_UNLOCKED(&nmi_desc[3].lock), > + .lock = __RAW_SPIN_LOCK_UNLOCKED(&nmi_desc[3].lock), > .head = LIST_HEAD_INIT(nmi_desc[3].head), > }, > > @@ -163,7 +163,7 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action) > > init_irq_work(&action->irq_work, nmi_max_handler); > > - spin_lock_irqsave(&desc->lock, flags); > + raw_spin_lock_irqsave(&desc->lock, flags); > > /* > * Indicate if there are multiple registrations on the > @@ -181,7 +181,7 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action) > else > list_add_tail_rcu(&action->list, &desc->head); > > - spin_unlock_irqrestore(&desc->lock, flags); > + raw_spin_unlock_irqrestore(&desc->lock, flags); > return 0; > } > EXPORT_SYMBOL(__register_nmi_handler); > @@ -192,7 +192,7 @@ void unregister_nmi_handler(unsigned int type, const char *name) > struct nmiaction *n; > unsigned long flags; > > - spin_lock_irqsave(&desc->lock, flags); > + raw_spin_lock_irqsave(&desc->lock, flags); > > list_for_each_entry_rcu(n, &desc->head, list) { > /* > @@ -207,7 +207,7 @@ void unregister_nmi_handler(unsigned int type, const char *name) > } > } > > - spin_unlock_irqrestore(&desc->lock, flags); > + raw_spin_unlock_irqrestore(&desc->lock, flags); > synchronize_rcu(); > } > EXPORT_SYMBOL_GPL(unregister_nmi_handler); > -- > 1.8.3.1 >