From: "Dong Feng" <middle.fengdong@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: The purpose and implementation of cond_resched()
Date: Thu, 22 Feb 2007 01:08:25 +0800 [thread overview]
Message-ID: <a2ebde260702210908o52b93002u19e8200b6b56ae5a@mail.gmail.com> (raw)
In-Reply-To: <a2ebde260702210813h14bc98b6s8c4c8c560c3647ff@mail.gmail.com>
I re-checked the code. And this time, I think cond_resched() is useful
while a kernel is compiled with no full preemption function but only
voluntary kernel preemption is enabled (i.e. CONFIG_PREEMPT_VOLUNTARY
is set but CONFIG_PREEMPT is not set). In this case, kernel performs
scheduling at explicit voluntary preemption points only, and those
points are determined by invoking cond_resched().
But I still have questions, why cond_resched() does not yield no-op
while CONFIG_PREEMPT is set? And why does it deal with the
PREEMPT_ACTIVE flag anyway?
2007/2/22, Dong Feng <middle.fengdong@gmail.com>:
> I have a question about cond_resched().
>
> What is the condition under which I should invoke cond_resched() irreplaceably?
>
> For example, I see the following code in ksoftirqd(),
>
> preempt_enable_no_resched();
> cond_resched();
> preempt_disable();
>
> But I do not understand why I should not write the following code,
>
> preempt_enable();
> preempt_disable();
>
> Are the above two pieces of code equal in functionality?
>
> On the other hand, I see cond_resched() check and set PREEMPT_ACTIVE.
> I currently do not understand why it should do this, since I think
> PREEMPT_ACTIVE is only used to be set in the return-from-interrupt
> code in order to prevent schedule() from removing task from run queue
> unpredictably. But for cond_resched(), which is a planned voluntary
> switch, why does it also deal with this flag?
>
prev parent reply other threads:[~2007-02-21 17:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-21 16:13 Dong Feng
2007-02-21 17:08 ` Dong Feng [this message]
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=a2ebde260702210908o52b93002u19e8200b6b56ae5a@mail.gmail.com \
--to=middle.fengdong@gmail.com \
--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
all inboxes | Powered by JetHome®