From: Peter Zijlstra <peterz@infradead.org>
To: Jean Delvare <khali@linux-fr.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
Leon Woestenberg <leon.woestenberg@gmail.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Sven-Thorsten Dietrich <sven@thebigcorporation.com>,
linux-i2c@vger.kernel.org,
rt-users <linux-rt-users@vger.kernel.org>,
"Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: yield() in i2c non-happy paths hits BUG under -rt patch
Date: Thu, 19 Nov 2009 15:15:54 +0100 [thread overview]
Message-ID: <1258640154.3931.407.camel@laptop> (raw)
In-Reply-To: <20091119150008.6e757c26@hyperion.delvare>
On Thu, 2009-11-19 at 15:00 +0100, Jean Delvare wrote:
> > cond_resched();
>
> Are you saying that most calls to yield() should be replaced with calls
> to cond_resched()?
No, depends on the reason yield() is used. Some cases can be replaced by
locking constructs, such as a condition variable.
> I admit I a little skeptical. While the description of cond_resched()
> ("latency reduction via explicit rescheduling in places that are safe")
> sounds promising, following the calls leads me to:
>
> static inline int need_resched(void)
> {
> return unlikely(test_thread_flag(TIF_NEED_RESCHED));
> }
>
> So apparently the condition for need_resched() to do anything is
> considered unlikely... suggesting that cond_resched() is a no-op in
> most cases? I don't quite get the point of moving away from sched()
> because it is a no-op, if we end up with a no-op under a different name.
TIF_NEED_RESCHED gets set by the scheduler whenever it decides current
needs to get preempted, its unlikely() because that reduces the code
impact of cond_resched() and similar in the case we don't schedule, if
we do schedule() a mis-predicted branch isn't going to be noticed on the
overhead of scheduling.
So there's a few cases,
1) PREEMPT=n
2) Voluntary preempt
3) PREEMPT=y
1) non of this has any effect, if the scheduler wants to reschedule a
task that's in the kernel, it'll have to wait until it gets back to
user-space.
2) uses cond_resched() and similar to have explicit preemption points,
so we don't need to wait as long as 1).
3) preempts directly when !preempt_count(), when IRQs are disabled, the
IPI that will accompany TIF_NEED_RESCHED will be delayed and
local_irq_enable()/restore() will effect a reschedule due to the pending
IPI. If preemption was disabled while the IPI hit nothing will happen,
but preempt_enable() will do the reschedule once preempt_count reaches
0.
next prev parent reply other threads:[~2009-11-19 14:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <c384c5ea0911071101u7415d37o2611c542e5fae309@mail.gmail.com>
[not found] ` <20091107210147.3e754278@hyperion.delvare>
[not found] ` <4AF7148C.9090706@thebigcorporation.com>
[not found] ` <20091112211255.09cd884a@hyperion.delvare>
2009-11-13 22:03 ` yield() in i2c non-happy paths hits BUG under -rt patch Thomas Gleixner
2009-11-14 18:02 ` Jean Delvare
2009-11-16 15:56 ` Mark Brown
2009-11-18 0:50 ` Leon Woestenberg
2009-11-18 1:05 ` Alan Cox
2009-11-18 16:28 ` Leon Woestenberg
2009-11-18 16:52 ` Jean Delvare
2009-11-18 20:36 ` Thomas Gleixner
2009-11-19 12:05 ` Jean Delvare
2009-11-19 12:59 ` Alan Cox
2009-11-19 13:06 ` Peter Zijlstra
2009-11-19 14:00 ` Jean Delvare
2009-11-19 14:15 ` Peter Zijlstra [this message]
2009-11-19 13:11 ` Thomas Gleixner
2009-11-19 13:21 ` Peter Zijlstra
2009-11-19 13:22 ` Thomas Gleixner
2009-11-19 13:18 ` Peter Zijlstra
2009-11-18 20:46 ` [PATCH] cleanup sched_yield (sys)call nesting Sven-Thorsten Dietrich
2009-11-18 20:56 ` Thomas Gleixner
2009-11-18 21:04 ` Sven-Thorsten Dietrich
2009-11-18 21:34 ` Thomas Gleixner
2009-11-19 4:48 ` Sven-Thorsten Dietrich
2009-11-19 10:36 ` Thomas Gleixner
2009-11-19 3:20 ` Ingo Molnar
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=1258640154.3931.407.camel@laptop \
--to=peterz@infradead.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ben-linux@fluff.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=khali@linux-fr.org \
--cc=leon.woestenberg@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=sven@thebigcorporation.com \
--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