All of lore.kernel.org
 help / color / mirror / Atom feed
* The purpose and implementation of cond_resched()
@ 2007-02-21 16:13 Dong Feng
  2007-02-21 17:08 ` Dong Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Dong Feng @ 2007-02-21 16:13 UTC (permalink / raw)
  To: linux-kernel

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?

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

* Re: The purpose and implementation of cond_resched()
  2007-02-21 16:13 The purpose and implementation of cond_resched() Dong Feng
@ 2007-02-21 17:08 ` Dong Feng
  0 siblings, 0 replies; 2+ messages in thread
From: Dong Feng @ 2007-02-21 17:08 UTC (permalink / raw)
  To: linux-kernel

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?
>

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

end of thread, other threads:[~2007-02-21 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 16:13 The purpose and implementation of cond_resched() Dong Feng
2007-02-21 17:08 ` Dong Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.