Re: [profile] amortize atomic hit count increments

Andrew Morton
2004-09-14T06:54:28Z

William Lee Irwin III <wli@holomorphy.com> wrote:
>

A few comments which describe the design would be nice...

> +#ifdef CONFIG_SMP
> +static void __profile_flip_buffers(void *unused)
> +{
> + int cpu = get_cpu();
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + per_cpu(cpu_profile_flip, cpu) = !per_cpu(cpu_profile_flip, cpu);
> + local_irq_restore(flags);
> + put_cpu();
> +}

hm. Does an IPI handler need to disable local IRQs?

> +static void profile_flip_buffers(void)
> +{
> + static DECLARE_MUTEX(profile_flip_mutex);
> + int i, j, cpu;
> +
> + down(&profile_flip_mutex);
> + j = per_cpu(cpu_profile_flip, smp_processor_id());

Is this preempt-safe?

> + on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
> + for_each_online_cpu(cpu) {
> + struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[j];