linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Hafting <helge.hafting@aitel.hist.no>
To: davids@webmaster.com
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	hancockr@shaw.ca
Subject: Re: sched_yield() makes OpenLDAP slow
Date: Thu, 26 Jan 2006 09:30:22 +0100	[thread overview]
Message-ID: <43D8889E.3020907@aitel.hist.no> (raw)
In-Reply-To: <MDEHLPKNGKAHNMBLJOLKAEJBJKAB.davids@webmaster.com>

David Schwartz wrote:

>>Robert Hancock wrote:
>>    
>>
>>But the thread the released the
>>mutex is not one of the waiting threads, and is not eligible for
>>consideration.
>>    
>>
>
>	Where are you getting this from? Nothing requires the scheduler to schedule
>any threads when the mutex is released.
>  
>
Correct.

>	All that must happen is that the mutex must be unlocked. The scheduler is
>permitted to allow any thread it wants to run at that point, or no thread.
>Nothing says the thread that released the mutex can't continue running and
>  
>
Correct. The releasing thread may keep running.

>nothing says that it can't call pthread_mutex_lock and re-acquire the mutex
>before any other thread gets around to getting it.
>  
>
Wrong.
The spec says that the mutex must be given to a waiter (if any) at the
moment of release.  The waiter don't have to be scheduled at that
point, it may keep sleeping with its freshly unlocked mutex.  So the
unlocking thread may continue - but if it tries to reaquire the mutex
it will find the mutex taken and go to sleep at that point. Then other
processes will schedule, and at some time the one now owning the mutex
will wake up and do its work.

>	In general, it is very bad karma for the scheduler to stop a thread before
>its timeslice is up if it doesn't have to. Consider one CPU and two threads,
>each needing to do 100 quick lock/unlock cycles. Why force 200 context
>switches?
>
Good point, except it is a strange program that do this.  Lock the mutex 
once,
do 100 operations, then unlock is the better way. :-)

Helge Hafting

  reply	other threads:[~2006-01-26  8:25 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-24 22:59 e100 oops on resume Stefan Seyfried
2006-01-24 23:21 ` Mattia Dongili
2006-01-25  9:02   ` Olaf Kirch
2006-01-25 12:11     ` Olaf Kirch
2006-01-25 13:51       ` sched_yield() makes OpenLDAP slow Howard Chu
2006-01-25 14:38         ` Robert Hancock
2006-01-25 17:49         ` Christopher Friesen
2006-01-25 18:26           ` pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow) Howard Chu
2006-01-25 18:59             ` Nick Piggin
2006-01-25 19:32               ` Howard Chu
2006-01-26  8:51                 ` Nick Piggin
2006-01-26 14:15                   ` Kyle Moffett
2006-01-26 14:43                     ` Howard Chu
2006-01-26 19:57                       ` David Schwartz
2006-01-26 20:27                         ` Howard Chu
2006-01-26 20:46                           ` Nick Piggin
2006-01-26 21:32                             ` Howard Chu
2006-01-26 21:41                               ` Nick Piggin
2006-01-26 21:56                                 ` Howard Chu
2006-01-26 22:24                                   ` Nick Piggin
2006-01-27  8:08                                     ` Howard Chu
2006-01-27 19:25                                       ` Philipp Matthias Hahn
2006-02-01 12:31                                       ` Nick Piggin
2006-01-27  4:27                                   ` Steven Rostedt
2006-01-26 21:58                               ` Christopher Friesen
2006-01-27  4:13                               ` Steven Rostedt
2006-01-27  2:16                           ` David Schwartz
2006-01-27  8:19                             ` Howard Chu
2006-01-27 19:50                               ` David Schwartz
2006-01-27 20:13                                 ` Howard Chu
2006-01-27 21:05                                   ` David Schwartz
2006-01-27 21:23                                     ` Howard Chu
2006-01-27 23:31                                       ` David Schwartz
2006-01-30  8:28                         ` Helge Hafting
2006-01-26 10:38                 ` Nikita Danilov
2006-01-30  8:35                   ` Helge Hafting
2006-01-30 11:13                     ` Nikita Danilov
2006-01-31 23:18                     ` David Schwartz
2006-01-25 21:06             ` Lee Revell
2006-01-25 22:14               ` Howard Chu
2006-01-26  0:16                 ` Robert Hancock
2006-01-26  0:49                   ` Howard Chu
2006-01-26  1:04                     ` Lee Revell
2006-01-26  1:31                       ` Howard Chu
2006-01-26  2:05                 ` David Schwartz
2006-01-26  2:48                   ` Mark Lord
2006-01-26  3:30                     ` David Schwartz
2006-01-26  3:49                       ` Samuel Masham
2006-01-26  4:02                         ` Samuel Masham
2006-01-26  4:53                           ` Lee Revell
2006-01-26  6:14                             ` Samuel Masham
2006-01-26  8:54                 ` Nick Piggin
2006-01-26 14:24                   ` Howard Chu
2006-01-26 14:54                     ` Nick Piggin
2006-01-26 15:23                       ` Howard Chu
2006-01-26 15:51                         ` Nick Piggin
2006-01-26 16:44                           ` Howard Chu
2006-01-26 17:34                             ` linux-os (Dick Johnson)
2006-01-26 19:00                               ` Nick Piggin
2006-01-26 19:14                                 ` linux-os (Dick Johnson)
2006-01-26 21:12                                   ` Nick Piggin
2006-01-26 21:31                                     ` linux-os (Dick Johnson)
2006-01-27  7:06                                       ` Valdis.Kletnieks
2006-01-30  8:44                               ` Helge Hafting
2006-01-30  8:50                                 ` Howard Chu
2006-01-30 15:33                                   ` Kyle Moffett
2006-01-30 13:28                                 ` linux-os (Dick Johnson)
2006-01-30 15:15                                   ` Helge Hafting
2006-01-26 10:44                 ` Nikita Danilov
2006-01-26  0:08             ` Robert Hancock
2006-01-26  1:07         ` sched_yield() makes OpenLDAP slow David Schwartz
2006-01-26  8:30           ` Helge Hafting [this message]
2006-01-26  9:01             ` Nick Piggin
2006-01-26 10:50             ` Nikita Danilov
2006-01-25 19:37       ` e100 oops on resume Jesse Brandeburg
2006-01-25 20:14         ` Olaf Kirch
2006-01-25 22:28           ` Jesse Brandeburg
2006-01-26  0:28         ` Jesse Brandeburg
2006-01-26  9:32           ` Pavel Machek
2006-01-26 19:02           ` Stefan Seyfried
2006-01-26 19:09             ` Olaf Kirch
2006-01-28 11:53             ` Mattia Dongili
2006-01-28 19:53               ` Jesse Brandeburg
2006-02-07  6:57                 ` Jeff Garzik
     [not found]           ` <BAY108-DAV111F6EF46F6682FEECCC1593140@phx.gbl>
     [not found]             ` <4807377b0601271404w6dbfcff6s4de1c3f785dded9f@mail.gmail.com>
2006-01-30 17:25               ` Can I do a regular read to simulate prefetch instruction? John Smith
     [not found] <5uZqb-4fo-15@gated-at.bofh.it>
2006-01-14 22:47 ` sched_yield() makes OpenLDAP slow Robert Hancock
  -- strict thread matches above, loose matches on Subject: below --
2006-01-14 19:29 Howard Chu
     [not found] <43057641.70700@symas.com.suse.lists.linux.kernel>
     [not found] ` <17157.45712.877795.437505@gargle.gargle.HOWL.suse.lists.linux.kernel>
     [not found]   ` <430666DB.70802@symas.com.suse.lists.linux.kernel>
2005-08-20 13:48     ` Andi Kleen
2005-08-21 19:47       ` Florian Weimer
2005-08-22  5:09         ` Howard Chu
2005-08-22 13:06           ` Andi Kleen
2005-08-22 18:47             ` Howard Chu
2005-08-22 13:20           ` Florian Weimer
2005-08-22 23:19             ` Howard Chu
     [not found] <4D8eT-4rg-31@gated-at.bofh.it>
2005-08-20  3:20 ` Robert Hancock
2005-08-20  4:18   ` Nick Piggin
2005-08-20 18:38     ` Howard Chu
2005-08-20 20:57       ` Lee Revell
2005-08-20 21:24         ` Howard Chu
2005-08-21  0:36           ` Nick Piggin
2005-08-21 11:33           ` Nikita Danilov
2005-08-22  8:06             ` Howard Chu
2005-08-20 21:50       ` Lee Revell
2005-08-21  1:04       ` Robert Hancock
2005-08-22 11:44         ` linux-os (Dick Johnson)
2005-08-22 14:26           ` Robert Hancock
2005-08-23 11:17             ` linux-os (Dick Johnson)
2005-08-23 12:07               ` Denis Vlasenko
2005-08-24  3:37                 ` Lincoln Dale
2005-08-19  6:03 Howard Chu
2005-08-19  6:34 ` Nick Piggin
2005-08-19  6:59 ` Chris Wedgwood
2005-08-19 22:45   ` Howard Chu
2005-08-19 10:21 ` Nikita Danilov
2005-08-19 23:10   ` Howard Chu
2005-08-20 13:23     ` Nikita Danilov
2005-08-20 19:49       ` Howard Chu
2005-08-20 22:08         ` Nikita Danilov
     [not found] <4303DB48.8010902@develer.com.suse.lists.linux.kernel>
     [not found] ` <20050818010703.GA13127@nineveh.rivenstone.net.suse.lists.linux.kernel>
     [not found]   ` <4303F967.6000404@yahoo.com.au.suse.lists.linux.kernel>
     [not found]     ` <43054D9A.7090509@develer.com.suse.lists.linux.kernel>
2005-08-19  3:19       ` Andi Kleen
2005-08-19  3:30         ` Bernardo Innocenti
2005-08-18  0:50 Bernardo Innocenti
2005-08-18  0:47 ` Con Kolivas
2005-08-18 10:48   ` Maciej Soltysiak
2005-08-18  1:07 ` Joseph Fannin
2005-08-18  2:25   ` Bernardo Innocenti
2005-08-18  2:58   ` Nick Piggin
2005-08-19  3:10     ` Bernardo Innocenti

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=43D8889E.3020907@aitel.hist.no \
    --to=helge.hafting@aitel.hist.no \
    --cc=davids@webmaster.com \
    --cc=hancockr@shaw.ca \
    --cc=linux-kernel@vger.kernel.org \
    /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).