Flexible I/O Tester development
 help / color / mirror / Atom feed
* "Fix wrong clock source in mutex" broke fio for me
@ 2009-10-07  6:56 Roland Dreier
  2009-10-07 20:01 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2009-10-07  6:56 UTC (permalink / raw)
  To: Jens Axboe, fio

With the latest fio git tree, I get:

    fio: job startup hung? exiting.

on startup, and it looks like the latest commit, 69a852f5 ("Fix wrong
clock source in mutex") breaks things for me (Ubuntu 9.10 beta).  My
system seems to use CLOCK_REALTIME for pthread_cond_timedwait() by
default.

The cleanest solution seems to be to explicitly set which clock to use
in pthread_cond_timedwait() via pthread_condattr_setclock() when
initializing the condition variable, although I'm not sure how portable
this is away from modern Linux (ie do all platforms that fio cares about
have pthread_condattr_setclock()?).

Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
 mutex.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mutex.c b/mutex.c
index 9f0f094..34b3324 100644
--- a/mutex.c
+++ b/mutex.c
@@ -72,6 +72,7 @@ struct fio_mutex *fio_mutex_init(int value)
 
 	pthread_condattr_init(&cond);
 	pthread_condattr_setpshared(&cond, mflag);
+	pthread_condattr_setclock(&cond, CLOCK_MONOTONIC);
 	pthread_cond_init(&mutex->cond, &cond);
 
 	ret = pthread_mutex_init(&mutex->lock, &attr);


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

* Re: "Fix wrong clock source in mutex" broke fio for me
  2009-10-07  6:56 "Fix wrong clock source in mutex" broke fio for me Roland Dreier
@ 2009-10-07 20:01 ` Jens Axboe
  2009-10-07 20:22   ` Roland Dreier
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2009-10-07 20:01 UTC (permalink / raw)
  To: Roland Dreier; +Cc: fio

On Tue, Oct 06 2009, Roland Dreier wrote:
> With the latest fio git tree, I get:
> 
>     fio: job startup hung? exiting.
> 
> on startup, and it looks like the latest commit, 69a852f5 ("Fix wrong
> clock source in mutex") breaks things for me (Ubuntu 9.10 beta).  My
> system seems to use CLOCK_REALTIME for pthread_cond_timedwait() by
> default.

Woops, how did I miss that?

> The cleanest solution seems to be to explicitly set which clock to use
> in pthread_cond_timedwait() via pthread_condattr_setclock() when
> initializing the condition variable, although I'm not sure how portable
> this is away from modern Linux (ie do all platforms that fio cares about
> have pthread_condattr_setclock()?).

I did a quick check, and at least newer revisions have it. Hmm I'm a bit
torn on this, perhaps the safer option is just to revert the bad commit.

OK, what I'll do is apply this and then we can worry about older
platforms later. I usually try and test FreeBSD and Solaris
occasionally, to ensure that full releases at least work.

Thanks for reporting and fixing this, Roland!

-- 
Jens Axboe


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

* Re: "Fix wrong clock source in mutex" broke fio for me
  2009-10-07 20:01 ` Jens Axboe
@ 2009-10-07 20:22   ` Roland Dreier
  2009-10-08  6:54     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2009-10-07 20:22 UTC (permalink / raw)
  To: Jens Axboe; +Cc: fio


 > I did a quick check, and at least newer revisions have it. Hmm I'm a bit
 > torn on this, perhaps the safer option is just to revert the bad commit.

But presumably you made that commit because it fixed some platform?

The default clock for pthread_cond_timedwait() seems poorly specified,
I'm not able to find any definitive statement about what it uses, and
pthread_condattr_setclock() seems to be option in the pthreads spec.
Seems to be a mess.

Anyway not sure what the best idea is....

 - R.

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

* Re: "Fix wrong clock source in mutex" broke fio for me
  2009-10-07 20:22   ` Roland Dreier
@ 2009-10-08  6:54     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2009-10-08  6:54 UTC (permalink / raw)
  To: Roland Dreier; +Cc: fio

On Wed, Oct 07 2009, Roland Dreier wrote:
> 
>  > I did a quick check, and at least newer revisions have it. Hmm I'm a bit
>  > torn on this, perhaps the safer option is just to revert the bad commit.
> 
> But presumably you made that commit because it fixed some platform?
> 
> The default clock for pthread_cond_timedwait() seems poorly specified,
> I'm not able to find any definitive statement about what it uses, and
> pthread_condattr_setclock() seems to be option in the pthreads spec.
> Seems to be a mess.
> 
> Anyway not sure what the best idea is....

I agree, in any case it's a lot more sane to specifically set the used
clock source. So lets just keep it as-is, if there's any fall out later
I'll deal with it.

-- 
Jens Axboe


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

end of thread, other threads:[~2009-10-08  6:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07  6:56 "Fix wrong clock source in mutex" broke fio for me Roland Dreier
2009-10-07 20:01 ` Jens Axboe
2009-10-07 20:22   ` Roland Dreier
2009-10-08  6:54     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox