Re: [patch 18/23] dynticks: i386 arch code

From: Andrew Morton
Date: Sat Sep 30 2006 - 04:46:44 EST


On Fri, 29 Sep 2006 23:58:37 -0000
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> From: Ingo Molnar <mingo@xxxxxxx>
>
> prepare i386 for dyntick: idle handler callbacks and IRQ callback.
>
> Index: linux-2.6.18-mm2/arch/i386/kernel/nmi.c
> ===================================================================
> --- linux-2.6.18-mm2.orig/arch/i386/kernel/nmi.c 2006-09-30 01:41:10.000000000 +0200
> +++ linux-2.6.18-mm2/arch/i386/kernel/nmi.c 2006-09-30 01:41:19.000000000 +0200
> @@ -20,6 +20,7 @@
> #include <linux/sysdev.h>
> #include <linux/sysctl.h>
> #include <linux/percpu.h>
> +#include <linux/kernel_stat.h>
> #include <linux/dmi.h>
> #include <linux/kprobes.h>
>
> @@ -908,7 +909,7 @@ __kprobes int nmi_watchdog_tick(struct p
> touched = 1;
> }
>
> - sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
> + sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_irqs(0);

Why?

> ===================================================================
> --- linux-2.6.18-mm2.orig/arch/i386/kernel/process.c 2006-09-30 01:41:10.000000000 +0200
> +++ linux-2.6.18-mm2/arch/i386/kernel/process.c 2006-09-30 01:41:19.000000000 +0200
> @@ -178,24 +178,27 @@ void cpu_idle(void)
>
> /* endless idle loop with no priority at all */
> while (1) {
> - while (!need_resched()) {
> - void (*idle)(void);
> + if (!hrtimer_stop_sched_tick()) {
> + while (!need_resched()) {

I don't see why hrtimer_stop_sched_tick() returns need_resched(). We
immediately reevaluate it anyway. hrtimer_stop_sched_tick() could return 1.

> + void (*idle)(void);
>
> - if (__get_cpu_var(cpu_idle_state))
> - __get_cpu_var(cpu_idle_state) = 0;
> + if (__get_cpu_var(cpu_idle_state))
> + __get_cpu_var(cpu_idle_state) = 0;
>
> - rmb();
> - idle = pm_idle;
> + rmb();
> + idle = pm_idle;
>
> - if (!idle)
> - idle = default_idle;
> + if (!idle)
> + idle = default_idle;
>
> - if (cpu_is_offline(cpu))
> - play_dead();
> + if (cpu_is_offline(cpu))
> + play_dead();
>
> - __get_cpu_var(irq_stat).idle_timestamp = jiffies;
> - idle();
> + __get_cpu_var(irq_stat).idle_timestamp = jiffies;
> + idle();
> + }
> }
> + hrtimer_restart_sched_tick();
> preempt_enable_no_resched();
> schedule();
> preempt_disable();
>

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