Performance analysis of i386 SMP timer interrupt

From: Chuck Ebbert
Date: Sat Dec 04 2004 - 14:56:00 EST


Performance analysis of arch/i386/kernel/apic.c::smp_local_timer_interrupt:

{
int cpu = smp_processor_id();

profile_tick(CPU_PROFILING, regs);
1 -> if (--per_cpu(prof_counter, cpu) <= 0) {

per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
2 -> if (per_cpu(prof_counter, cpu) !=
per_cpu(prof_old_multiplier, cpu)) {
3 -> __setup_APIC_LVTT(
calibration_result/
per_cpu(prof_counter, cpu));
4 -> per_cpu(prof_old_multiplier, cpu) =
per_cpu(prof_counter, cpu);
}

5 -> update_process_times(user_mode(regs));
}
}


(1) Needs likely().

(2) Needs unlikely().

(3,4) (4) should be done before (3) to minimize register usage.
(function becomes 6 insns smaller and uses 8 bytes less stack space)

(5) The user_mode() macro is inefficient:
#define user_mode(regs) ((VM_MASK & (regs)->eflags) || (3 & (regs)->xcs))

(VM86 mode is very rare compared to normal cpu mode, so both
parts of the 'or' are evaluated almost every time on most systems.)


--Chuck Ebbert 04-Dec-04 14:50:39
-
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/