linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Galbraith <efault@gmx.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [rt-patch 2/3] sched: Introduce raw_cond_resched_lock()
Date: Sat, 28 Jul 2018 11:07:22 +0200	[thread overview]
Message-ID: <1532768842.9882.72.camel@gmx.de> (raw)
In-Reply-To: <1532764179.9882.14.camel@gmx.de>


Add raw_cond_resched_lock() infrastructure.

Signed-off-by: Mike Galbraith <efault@gmx.de>
---
 include/linux/sched.h |   15 +++++++++++++++
 kernel/sched/core.c   |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)

--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1779,12 +1779,18 @@ static inline int _cond_resched(void) {
 })
 
 extern int __cond_resched_lock(spinlock_t *lock);
+extern int __raw_cond_resched_lock(raw_spinlock_t *lock);
 
 #define cond_resched_lock(lock) ({				\
 	___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\
 	__cond_resched_lock(lock);				\
 })
 
+#define raw_cond_resched_lock(lock) ({				\
+	___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\
+	__raw_cond_resched_lock(lock);				\
+})
+
 #ifndef CONFIG_PREEMPT_RT_FULL
 extern int __cond_resched_softirq(void);
 
@@ -1817,6 +1823,15 @@ static inline int spin_needbreak(spinloc
 #else
 	return 0;
 #endif
+}
+
+static inline int raw_spin_needbreak(raw_spinlock_t *lock)
+{
+#ifdef CONFIG_PREEMPT
+	return raw_spin_is_contended(lock);
+#else
+	return 0;
+#endif
 }
 
 static __always_inline bool need_resched(void)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5065,6 +5065,26 @@ int __cond_resched_lock(spinlock_t *lock
 }
 EXPORT_SYMBOL(__cond_resched_lock);
 
+int __raw_cond_resched_lock(raw_spinlock_t *lock)
+{
+	int resched = should_resched(PREEMPT_LOCK_OFFSET);
+	int ret = 0;
+
+	lockdep_assert_held(lock);
+
+	if (raw_spin_needbreak(lock) || resched) {
+		raw_spin_unlock(lock);
+		if (resched)
+			preempt_schedule_common();
+		else
+			cpu_relax();
+		ret = 1;
+		raw_spin_lock(lock);
+	}
+	return ret;
+}
+EXPORT_SYMBOL(__raw_cond_resched_lock);
+
 #ifndef CONFIG_PREEMPT_RT_FULL
 int __sched __cond_resched_softirq(void)
 {

  parent reply	other threads:[~2018-07-28  9:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 21:57 [ANNOUNCE] v4.16.18-rt11 Sebastian Andrzej Siewior
2018-07-28  9:07 ` candidates for @devel-rt localversion-rt++ Mike Galbraith
2018-07-28  9:13   ` [rt-patch 1/3] arm64/acpi/perf: move pmu allocation to an early CPU up hook Mike Galbraith
2018-08-02 13:45     ` [rt-patch 1/3 v2] " Mike Galbraith
2018-07-29  6:55   ` candidates for @devel-rt localversion-rt++ Mike Galbraith
2018-07-29 11:47     ` Mike Galbraith
2018-07-30 16:24       ` Mike Galbraith
2018-07-31 18:28         ` bisected - arm64 kvm unit test failures Mike Galbraith
2018-08-01  5:35           ` Marc Zyngier
2018-08-01  6:02             ` Mike Galbraith
2018-08-01  7:22               ` Marc Zyngier
2018-08-01  7:48                 ` Mike Galbraith
2018-08-01  9:20                 ` Mike Galbraith
2018-08-21 15:34           ` Marc Zyngier
2018-08-22 13:38             ` Mike Galbraith
2018-08-22 13:50               ` Marc Zyngier
2018-08-22 13:57                 ` Mike Galbraith
     [not found] ` <1532764179.9882.14.camel@gmx.de>
2018-07-28  9:07   ` Mike Galbraith [this message]
2018-07-28  9:07   ` [rt-patch 3/3] arm, KVM: convert vgic_irq.irq_lock to raw_spinlock_t Mike Galbraith
2018-07-30  9:27     ` Peter Zijlstra
2018-07-30 13:34       ` Mike Galbraith
2018-08-02  6:56     ` [rt-patch 4/3] arm,KVM: Move phys_timer handling to hard irq context Mike Galbraith
2018-08-02 16:31       ` Steven Rostedt
2018-08-02 16:50         ` Mike Galbraith
2018-08-02 17:43           ` Mike Galbraith
2018-08-04 12:25             ` Mike Galbraith
2018-08-05  4:52               ` Mike Galbraith
2018-08-07 14:46                 ` Sebastian Andrzej Siewior

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=1532768842.9882.72.camel@gmx.de \
    --to=efault@gmx.de \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).