mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Primiano Tucci <p.tucci@gmail.com>,
	linux-kernel@vger.kernel.org, tglx <tglx@linutronix.de>
Subject: Re: Considerations on sched APIs under RT patch
Date: Wed, 21 Apr 2010 08:46:56 -0400	[thread overview]
Message-ID: <1271854016.10448.172.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1271839772.1776.58.camel@laptop>

On Wed, 2010-04-21 at 10:49 +0200, Peter Zijlstra wrote:
> On Wed, 2010-04-21 at 07:16 +0200, Primiano Tucci wrote:
> > Hi steve
> > > read_locks are converted into "special" rt_mutexes. The only thing
> > > special about them, is the owner may grab the same read lock more than
> > > once (recursive).
> > >
> > > If a lower priority process currently holds the tasklist_lock for write,
> > > when a high priority process tries to take it for read (or write for
> > > that matter) it will block on the lower priority process. But that lower
> > > priority process will acquire the priority of the higher priority
> > > process (priority inheritance) and will run at that priority until it
> > > releases the lock. Then it will go back to its low priority and the
> > > higher priority process will then preempt it and acquire the lock for
> > > read.
> > 
> > In your example you implied that the low priority process, holding the
> > lock for write, runs on the same CPU of the higher priority process
> > that wants to lock it for read. This is clear to me.
> > My problem is, in a SMP environment, what happens if a process (let's
> > say T1 on CPU #1) holds the lock for write (its priority does not
> > matter, it is not a PI problem) and now a process T0 on cpu #0 wants
> > to lock it for read?
> > The process T0 will be blocked! But who will run now on CPU 0, until
> > the rwlock is held by T1? Probably the next ready process on CPU #'0.
> > Is it right?
> 
> Yes. This is the reality of SMP systems, nothing much you can do about
> that. System resources are shared between all cpus, irrespective of task
> affinities.

Actually, we do better than that. With adaptive locks, if the process on
the other CPU is still running, the high priority task will spin until
the other process releases the lock or goes to sleep. If it goes to
sleep, then the high prio task will also sleep, otherwise it just spins
and takes the lock when it is released.

-- Steve




  reply	other threads:[~2010-04-21 12:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-19 20:48 Primiano Tucci
2010-04-20  9:20 ` Peter Zijlstra
2010-04-20 21:56   ` Primiano Tucci
2010-04-20 23:00     ` Steven Rostedt
2010-04-21  5:16       ` Primiano Tucci
2010-04-21  8:49         ` Peter Zijlstra
2010-04-21 12:46           ` Steven Rostedt [this message]
2010-04-21 19:24             ` Primiano Tucci
2010-04-21 19:57               ` Peter Zijlstra
2010-04-21 20:38                 ` Primiano Tucci
2010-04-21 20:58                   ` Peter Zijlstra
2010-04-22 13:20                     ` Steven Rostedt
2010-04-22 13:50                       ` Primiano Tucci
2010-04-22 13:57                         ` Peter Zijlstra
2010-04-22 15:40                           ` Primiano Tucci
2010-04-22 16:28                             ` Peter Zijlstra
2010-04-22 17:48                               ` Bjoern Brandenburg
2010-04-22 19:33                               ` Primiano Tucci
2010-04-21 12:56     ` Peter Zijlstra
2010-04-27 13:18     ` Thomas Gleixner

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=1271854016.10448.172.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.tucci@gmail.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

all inboxes | Powered by JetHome®