From: Waiman Long <longman@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org, Waiman Long <longman@redhat.com>
Subject: [RFC PATCH 3/7] locking/rtqspinlock: Use static RT priority when in interrupt context
Date: Tue, 3 Jan 2017 13:00:26 -0500 [thread overview]
Message-ID: <1483466430-8028-4-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1483466430-8028-1-git-send-email-longman@redhat.com>
When in interrupt context, the priority of the interrupted task is
meaningless. So static RT priority is assigned in this case to make
sure that it can get lock ASAP to reduce latency to the interrupted
task.
Signed-off-by: Waiman Long <longman@redhat.com>
---
kernel/locking/qspinlock_rt.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/qspinlock_rt.h b/kernel/locking/qspinlock_rt.h
index 69513d6..b6289fb 100644
--- a/kernel/locking/qspinlock_rt.h
+++ b/kernel/locking/qspinlock_rt.h
@@ -19,6 +19,13 @@
*
* As RT qspinlock needs the whole pending byte, it cannot be used on kernel
* configured to support 16K or more CPUs (CONFIG_NR_CPUS).
+ *
+ * In interrupt context, the priority of the interrupted task is not
+ * meaningful. So a fixed static RT priority is used and they won't go into
+ * the MCS wait queue.
+ * 1) Soft IRQ = 1
+ * 2) Hard IRQ = MAX_RT_PRIO
+ * 3) NMI = MAX_RT_PRIO+1
*/
#include <linux/sched.h>
@@ -60,11 +67,15 @@ static inline int rt_pending(int val)
static bool rt_spin_trylock(struct qspinlock *lock)
{
struct __qspinlock *l = (void *)lock;
- u8 prio = rt_task_priority(current);
+ struct task_struct *task = in_interrupt() ? NULL : current;
+ u8 prio;
BUILD_BUG_ON(_Q_PENDING_BITS != 8);
- if (!prio)
+ if (!task)
+ prio = in_nmi() ? MAX_RT_PRIO + 1
+ : in_irq() ? MAX_RT_PRIO : 1;
+ else if (!(prio = rt_task_priority(task)))
return false;
/*
--
1.8.3.1
next prev parent reply other threads:[~2017-01-03 18:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-03 18:00 [RFC PATCH 0/7] locking/rtqspinlock: Realtime queued spinlocks Waiman Long
2017-01-03 18:00 ` [RFC PATCH 1/7] locking/spinlock: Remove the unused spin_lock_bh_nested API Waiman Long
2017-01-03 18:00 ` [RFC PATCH 2/7] locking/rtqspinlock: Introduce realtime queued spinlocks Waiman Long
2017-01-03 18:00 ` Waiman Long [this message]
2017-01-03 18:00 ` [RFC PATCH 4/7] locking/rtqspinlock: Override spin_lock_nested with special RT variants Waiman Long
2017-01-03 18:00 ` [RFC PATCH 5/7] locking/rtqspinlock: Handle priority boosting Waiman Long
2017-01-03 18:00 ` [RFC PATCH 6/7] locking/rtqspinlock: Voluntarily yield CPU when need_sched() Waiman Long
2017-01-04 10:07 ` Boqun Feng
2017-01-04 21:57 ` Waiman Long
2017-01-05 10:16 ` Daniel Bristot de Oliveira
2017-01-03 18:00 ` [RFC PATCH 7/7] locking/rtqspinlock: Enable collection of event counts Waiman Long
2017-01-04 12:49 ` [RFC PATCH 0/7] locking/rtqspinlock: Realtime queued spinlocks Peter Zijlstra
2017-01-04 15:25 ` Waiman Long
2017-01-04 15:55 ` Steven Rostedt
2017-01-04 20:02 ` Waiman Long
2017-01-05 18:43 ` Steven Rostedt
2017-01-05 9:26 ` Daniel Bristot de Oliveira
2017-01-05 9:44 ` Peter Zijlstra
2017-01-05 15:55 ` Waiman Long
2017-01-05 16:08 ` Peter Zijlstra
2017-01-05 17:07 ` Waiman Long
2017-01-05 18:50 ` Steven Rostedt
2017-01-05 19:24 ` Waiman Long
2017-01-05 18:05 ` Daniel Bristot de Oliveira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1483466430-8028-4-git-send-email-longman@redhat.com \
--to=longman@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox