Re: [PATCH v1 1/1] x86/percpu: Cast -1 to argument type when comparing in percpu_add_op()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 17, 2024 at 08:18:59PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 16, 2024 at 12:44:18PM -0700, Dave Hansen wrote:
> 
> > Would anybody hate if we broke this up a bit, like:
> > 
> >         const typeof(var) _val = val;
> >         const int paoconst = __builtin_constant_p(val);
> >         const int paoinc   = paoconst && ((_val) == 1);
> >         const int paodec   = paoconst && ((_val) == (typeof(var))-1);
> > 
> > and then did
> > 
> > 	if (paoinc)
> > 		percpu_unary_op(size, qual, "inc", var);
> > 	...
> 
> I think that is an overall improvement. Proceed! :-)

Wouldn't typeof(var) be a regression? The val can be wider (in term of bits)
than var and cutting it like this might bring different result depending on
the signedness. TL;DR: Whatever is done, please add more (corner) test cases
to the percpu_test.c.

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux