[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1011291408050.4836@router.home>
Date: Mon, 29 Nov 2010 14:09:35 -0600 (CST)
From: Christoph Lameter <cl@...ux.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
cc: akpm@...ux-foundation.org, Pekka Enberg <penberg@...helsinki.fi>,
linux-kernel@...r.kernel.org,
Eric Dumazet <eric.dumazet@...il.com>,
Tejun Heo <tj@...nel.org>
Subject: Re: [thisops uV2 04/10] x86: Support for
this_cpu_add,sub,dec,inc_return
On Mon, 29 Nov 2010, Mathieu Desnoyers wrote:
> Ah, ok, so you don't mind if var and val have different types. You just want
> the compiler to be able to cast one into the other without complaining.
>
> Isn't it already checked by "typeof(var) pfo_ret__ = val;" ?
Right. I will drop that strange fragment.
> But at the end, you return :
>
> pfo_ret__ + (val);
>
> So if pfo_ret has a type smaller than val (e.g. unsigned short vs unsigned int),
> unless I'm mistakened, the type returned by percpu_add_return_op will be an
> unsigned int (the larger of the two), but the atomic operation is performed on
> an unsigned short. This might cause confusion for the caller. Casting
>
> pfo_ret__ + (typeof(var)) (val);
>
> might be appropriate.
The return needs to be constrained to pfo_ret__. If the value wraps around
then we do not want a value larger than the variable returned.
pfo_ret__ += val;
pfo_ret;
will do I think.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists