Re: kernel preemption does not work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 12, 2008 at 9:53 PM, Patrick McManus <mcmanus@xxxxxxxxxxxx> wrote:
>  no. without CONFIG_PREEMPT kernel code is not pre-emptable. Userspace
>  code is different - that is always pre-emptable and the HZ options you
>  are looking at help determine the quanta (in either case I believe,
>  assuming config_preempt is enabled)
>

Possibly contentious, but I would like to get a better picture from
this discussion.

Like you all along I had this assumption that without CONFIG_PREEMPT
kernel code is NOT preemptible.   But then why everywhere there are so
many preempt() function, eg preempt_disable() and preempt_enable()
which executed whether u compile with CONFIG_PREEMPT or not.

Then looking at almost all the architecture independent files + those
of x86, I came to the conclusion that CONFIG_PREEMPT is to instrument
the codes so as to allow it to call schedule(), eg:

#ifndef CONFIG_PREEMPT
        cond_resched();
#endif /* CONFIG_PREEMPT */

So the conclusion is that CONFIG_PREEMPT is to enable the scheduler to
reexamine the tasks queue more often, making the kernel more
interactive, but at the cost of higher volume of processing.

As for CONFIG_NO_HZ, after reading kernel/softirq.c:

void irq_enter(void)
{
#ifdef CONFIG_NO_HZ
        int cpu = smp_processor_id();
        if (idle_cpu(cpu) && !in_interrupt())
                tick_nohz_stop_idle(cpu);
#endif
        __irq_enter();
#ifdef CONFIG_NO_HZ
        if (idle_cpu(cpu))
                tick_nohz_update_jiffies();
#endif
}

The interpretation is that this CONFIG_NO_HZ is to enable the update
of the jiffies whenever possible (when current task on current CPU is
idling),  eg, like at interrupt time as show above, as compared with
the past timer-trigger function to update it, preventing it from
unnecessarily interrupted during busy time.

And there are no dependencies among the two - u can see dependencies
when "depend" exists in Kconfig files:

kernel/Kconfig.hz and kernel/Kconfig.preempt.

Thanks.

-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux