Re: [cpuops cmpxchg double V2 1/4] Generic support forthis_cpu_cmpxchg_double

From: Christoph Lameter
Date: Fri Jan 21 2011 - 12:50:40 EST


On Fri, 21 Jan 2011, Mathieu Desnoyers wrote:

> > this_cpu_cmpxchg_double(percpu_dd, oldword1, oldword2, newword1, newword2)
> >
> > with the problem of type checking
>
> What is the problem with type checking here ?

You need to know the fields in the struct to do the type checking with
each of the other parameters.

> We could use a gcc builtin like the following to check if the alignment of
> "percpu_dd" meets the double-cas requirements:
>
> #define testmacro(a, b) \
> __builtin_choose_expr(__alignof__(a) >= 2 * sizeof(unsigned long), \
> ((a).low) = (b), \ /* success */
> ((a).low) = (void) 0) /* compile-error */
>
> > or
> >
> > this_cpu_cmpxchg_double(percpu_dd, old_dd, new_dd)
> >
> > with the problem of 128 bit constants/structs passed by value.
>
> Yeah, I guess trying to deal with 128-bit value might be a bit tricky. But
> having something sane and with compile-time-checked alignment for the percpu_dd
> type is not to be looked over.

The existing implementation could be equipped to do a compile time check
for the proper alignment if the pointer passed is constant.


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