public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kirill Tkhai <tkhai@yandex.ru>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [RFC] rtmutex: Do not boost fair tasks each other
Date: Thu, 01 May 2014 13:21:47 +0400	[thread overview]
Message-ID: <5362122B.8060305@yandex.ru> (raw)

Higher priority does not provide exclusive privilege
of one fair task over the other. In this case priority
boosting looks excess.

On RT patch with enabled PREEMPT_RT_FULL I see a lot of
rt_mutex_setprio() actions like

	120 -> 118
	118 -> 120

They harm RT tasks.

RT patch has lazy preemtion feature, so if idea is we care
about excess preemption inside fair class, we should care
about excess priority inheritance too.

In case of vanila kernel the problem is the same, but there
are no so many rt mutexes. Do I skip anything?

Kirill
---
 kernel/locking/rtmutex.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index aa4dff0..609a57e 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -197,11 +197,14 @@ rt_mutex_dequeue_pi(struct task_struct *task,
struct rt_mutex_waiter *waiter)
  */
 int rt_mutex_getprio(struct task_struct *task)
 {
-	if (likely(!task_has_pi_waiters(task)))
-		return task->normal_prio;
+	if (unlikely(task_has_pi_waiters(task))) {
+		int prio = task_top_pi_waiter(task)->prio;
+
+		if (rt_prio(prio) || dl_prio(prio))
+			return min(prio, task->normal_prio);
+	}

-	return min(task_top_pi_waiter(task)->prio,
-		   task->normal_prio);
+	return task->normal_prio;
 }

 struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
@@ -218,10 +221,14 @@ struct task_struct *rt_mutex_get_top_task(struct
task_struct *task)
  */
 int rt_mutex_check_prio(struct task_struct *task, int newprio)
 {
-	if (!task_has_pi_waiters(task))
-		return 0;
+	if (unlikely(task_has_pi_waiters(task))) {
+		int prio = task_top_pi_waiter(task)->task->prio;

-	return task_top_pi_waiter(task)->task->prio <= newprio;
+		if (rt_prio(prio) || dl_prio(prio))
+			return prio <= newprio;
+	}
+
+	return 0;
 }

 /*

             reply	other threads:[~2014-05-01  9:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01  9:21 Kirill Tkhai [this message]
2014-05-03 18:54 ` [RFC] rtmutex: Do not boost fair tasks each other Thomas Gleixner
2014-05-04  7:17   ` Peter Zijlstra
2014-05-04 12:13     ` Thomas Gleixner
2014-05-05 18:31   ` Kirill Tkhai
2014-05-28 20:26     ` Thomas Gleixner
2014-05-29 20:52       ` Kirill Tkhai
2014-06-17 14:19         ` Kirill Tkhai

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=5362122B.8060305@yandex.ru \
    --to=tkhai@yandex.ru \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul.gortmaker@windriver.com \
    --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