From: Mikulas Patocka <mpatocka@redhat.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, mingo@elte.hu, rml@tech9.net,
Alasdair G Kergon <agk@redhat.com>, Milan Broz <mbroz@redhat.com>
Subject: Re: Active waiting with yield()
Date: Thu, 20 Nov 2008 04:18:17 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0811200414100.17455@hs20-bc2-1.build.redhat.com> (raw)
In-Reply-To: <20081118212652.46d36da5@lxorguk.ukuu.org.uk>
On Tue, 18 Nov 2008, Alan Cox wrote:
> > This makes a code branch that is very rarely tested and a potential bug.
> > Every such rarely executed branch is a danger and even a silly typo in the
> > code can hide there for many years without being noticed.
>
> Learn to use a debugger. You want an unusual timing to occur you
> breakpoint the relevant task and suspend it for a bit.
>
> > So, I say msleep(1) instead of yield(). What are the counterarguments to
> > msleep?
>
> msleep isn't particularly a problem. You are giving up the CPU and not
> wasting so much power and you won't deadlock in realtime. Assuming you
> only expect one or two msleep cycles its fine.
So msleep(1) should be OK. I can't think of a case when it could break.
> And if you think virtualisation and power management and correctness
> (as Ingo noted) are a "bad reason" you need to wake up to the real world.
If the involved cases are:
- a race condition that never happened to a user, only seen during
artifical testing
- a race condition that existed for 5 years and just one user hit it
--- then yes, considering power management is a bad reason.
Mikulas
> Alan
>
next prev parent reply other threads:[~2008-11-20 9:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-14 18:59 Mikulas Patocka
2008-11-14 19:06 ` Alan Cox
2008-11-14 19:34 ` Mikulas Patocka
2008-11-14 20:57 ` Peter Zijlstra
2008-11-14 21:41 ` Mikulas Patocka
2008-11-15 22:55 ` Peter Zijlstra
2008-11-17 17:39 ` Mikulas Patocka
2008-11-17 18:01 ` Alan Cox
2008-11-18 14:34 ` Mikulas Patocka
2008-11-18 14:40 ` Alan Cox
2008-11-18 17:11 ` Mikulas Patocka
2008-11-18 21:26 ` Alan Cox
2008-11-20 9:18 ` Mikulas Patocka [this message]
2008-11-19 16:14 ` Peter Zijlstra
2008-11-18 14:49 ` Arjan van de Ven
2008-11-18 17:14 ` Mikulas Patocka
2008-11-14 21:21 ` Alan Cox
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=Pine.LNX.4.64.0811200414100.17455@hs20-bc2-1.build.redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=mbroz@redhat.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rml@tech9.net \
/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®