Re: [PATCH] netfilter: use per-cpu recursive lock (v11)

From: Ingo Molnar
Date: Tue Apr 21 2009 - 15:40:32 EST



* Stephen Hemminger <shemminger@xxxxxxxxxx> wrote:

> +void xt_info_wrunlock_bh(void)
> + __releases(xt_info_lock)
> +{
> + unsigned int i;
> +
> + for_each_possible_cpu(i) {
> +#if NR_CPUS > (PREEMPT_MASK - 1)
> + /*
> + * Spin_unlock calls preempt_enable, but since we had
> + * to adjust the count in xt_info_wrlock_bh, do it again
> + */
> + preempt_disable();
> +#endif
> + write_unlock(&per_cpu(xt_info_locks, i));
> + }
> + local_bh_enable();
> +}

In the global/local lock scheme i proposed this would become:

global_write_unlock(void)
{
write_unlock(&global_lock);
}

As we dont hold the local locks during the write-locked critical
section. No loop needed over CPUs, no preempt nesting complications,
no lockdep complications, etc.

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