Re: [patch 6/6] x86: add c1e aware idle function

From: Andrew Morton
Date: Thu Jun 12 2008 - 20:56:40 EST


On Thu, 12 Jun 2008 10:29:00 -0000
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> +static void c1e_idle(void)
> +{
> + static cpumask_t c1e_mask = CPU_MASK_NONE;
> + static int c1e_detected;
> +
> + if (need_resched())
> + return;
> +
> + if (!c1e_detected) {
> + u32 lo, hi;
> +
> + rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi);
> + if (lo & K8_INTP_C1E_ACTIVE_MASK) {
> + c1e_detected = 1;
> + mark_tsc_unstable("TSC halt in C1E");
> + printk(KERN_INFO "System has C1E enabled\n");
> + }
> + }
> +
> + if (c1e_detected) {
> + int cpu = smp_processor_id();
> +
> + if (!cpu_isset(cpu, c1e_mask)) {
> + cpu_set(cpu, c1e_mask);
> + /* Force broadcast so ACPI can not interfere */
> + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE,
> + &cpu);
> + printk(KERN_INFO "Switch to broadcast mode on CPU%d\n",
> + cpu);
> + }
> + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
> + default_idle();
> + local_irq_disable();
> + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
> + local_irq_enable();

I worked it out! It took me a while.

This function is called with local irqs disabled.

default_idle() is entered with local irqs disabled but returns with them
enabled.

clockevents_notify() is supposed to be called with local irqs disabled.

This functions returns with local irqs enabled.

Was I right? None of any of that is documented anywhere. But it should
be.


> + } else
> + default_idle();
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/