mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/nmi: Use raw lock
@ 2017-07-24 21:32 Scott Wood
  2017-07-25 16:22 ` Don Zickus
  2017-08-16 18:42 ` [tip:x86/spinlocks] " tip-bot for Scott Wood
  0 siblings, 2 replies; 3+ messages in thread
From: Scott Wood @ 2017-07-24 21:32 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin
  Cc: linux-kernel, Don Zickus, Scott Wood

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.

Signed-off-by: Scott Wood <swood@redhat.com>
---
 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 <trace/events/nmi.h>
 
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/nmi: Use raw lock
  2017-07-24 21:32 [PATCH] x86/nmi: Use raw lock Scott Wood
@ 2017-07-25 16:22 ` Don Zickus
  2017-08-16 18:42 ` [tip:x86/spinlocks] " tip-bot for Scott Wood
  1 sibling, 0 replies; 3+ messages in thread
From: Don Zickus @ 2017-07-25 16:22 UTC (permalink / raw)
  To: Scott Wood; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, linux-kernel

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 <dzickus@redhat.com>


> 
> Signed-off-by: Scott Wood <swood@redhat.com>
> ---
>  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 <trace/events/nmi.h>
>  
>  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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/spinlocks] x86/nmi: Use raw lock
  2017-07-24 21:32 [PATCH] x86/nmi: Use raw lock Scott Wood
  2017-07-25 16:22 ` Don Zickus
@ 2017-08-16 18:42 ` tip-bot for Scott Wood
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Scott Wood @ 2017-08-16 18:42 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, swood, linux-kernel, dzickus, mingo, tglx

Commit-ID:  c455fd9235b6bd2802db86109cfa0ec105992f68
Gitweb:     http://git.kernel.org/tip/c455fd9235b6bd2802db86109cfa0ec105992f68
Author:     Scott Wood <swood@redhat.com>
AuthorDate: Mon, 24 Jul 2017 16:32:42 -0500
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 16 Aug 2017 20:40:09 +0200

x86/nmi: Use raw lock

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.

Signed-off-by: Scott Wood <swood@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/20170724213242.27598-1-swood@redhat.com

---
 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 446c8aa..35aafc9 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -39,26 +39,26 @@
 #include <trace/events/nmi.h>
 
 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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-16 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-24 21:32 [PATCH] x86/nmi: Use raw lock Scott Wood
2017-07-25 16:22 ` Don Zickus
2017-08-16 18:42 ` [tip:x86/spinlocks] " tip-bot for Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome