linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* flock(fd, LOCK_UN) taking 500ms+ ?
@ 2002-10-02  2:39 John Levon
  2002-10-02  3:23 ` John Levon
  0 siblings, 1 reply; 11+ messages in thread
From: John Levon @ 2002-10-02  2:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: willy


In 2.5.40, our application is getting seemingly very large
flock(LOCK_UN) latencies :

Unlock, took 541386 usecs
Old was 567999237 secs, 131042 usecs
now is 567999237 secs, 672428 usecs
Unlock, took 125083 usecs
Old was 567999237 secs, 699310 usecs
now is 567999237 secs, 824393 usecs
Unlock, took 151245 usecs
Old was 567999237 secs, 825119 usecs
now is 567999237 secs, 976364 usecs

(using gettimeofday ...)

No similar times are observed during the corresponding LOCK_EX call.

Is this just a silly app bug somewhere, or something funny in locks.c ?

More details, testing etc. on request ...

regards
john

-- 
"I never understood what's so hard about picking a unique
 first and last name - and not going beyond the 6 character limit."
 	- Toon Moene

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: flock(fd, LOCK_UN) taking 500ms+ ?
@ 2002-10-02 21:36 Manfred Spraul
  0 siblings, 0 replies; 11+ messages in thread
From: Manfred Spraul @ 2002-10-02 21:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Matthew Wilcox, linux-kernel

akpm wrote:
> It's not really clear why that yield is in there at all?  Unless that
> code is really, really slow (milliseconds) then probably it should just
> be deleted.
> 
It looks like a very simple starvation control:

thread 1:
	for(;;) {
		F_LOCK
		<do a few seconds work>
		F_UNLCK
	}
thread 2:
	F_LOCK.

If there is no yield after unlock, thread 2 might never receive the lock.
Is it possible to figure out if someone is waiting on the lock? F_UNLCK 
should schedule, if there is a waiter with higher priority.

--
	Manfred




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-10-02 21:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-02  2:39 flock(fd, LOCK_UN) taking 500ms+ ? John Levon
2002-10-02  3:23 ` John Levon
2002-10-02 13:14   ` Matthew Wilcox
2002-10-02 17:04     ` Andrew Morton
2002-10-02 18:30       ` Matthew Wilcox
2002-10-02 18:58         ` John Levon
2002-10-02 19:10           ` Robert Love
2002-10-02 19:21         ` Robert Love
2002-10-02 19:23         ` Andrew Morton
2002-10-02 20:05           ` Matthew Wilcox
2002-10-02 21:36 Manfred Spraul

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).