On Thu, 30 Sep 2010 12:22:16 +0200 Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote: > Le jeudi 30 septembre 2010 __ 01:14 -0700, Andrew Morton a __crit : > > > Perhaps > > > > WARN_ON_ONCE(preemptible()); > > > > if we had a developer-only version of WARN_ON_ONCE, which we don't. > > Or just use a regular PER_CPU variable, even on !SMP, and get preempt > safe implementation. Good stuff. > What do you think of following patch, on top of current linux-2.6 tree ? > > ... > > +static noinline unsigned int last_ino_get(void) > +{ > + unsigned int *p = &get_cpu_var(last_ino); > + unsigned int res = *p; > + > +#ifdef CONFIG_SMP > + if (unlikely((res & (LAST_INO_BATCH - 1)) == 0)) { > + static atomic_t shared_last_ino; > + int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino); > + > + res = next - LAST_INO_BATCH; > + } > +#endif > + *p = ++res; > + put_cpu_var(last_ino); > + return res; > +} Could eliminate `p' I guess, but that would involve using __get_cpu_var() as an lval, which looks vile and might generate worse code. Readers of this code won't know why last_ino_get() was marked noinline. It looks wrong, really. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html