Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-24 Thread Steven Rostedt
On Fri, 24 May 2019 19:30:45 +0300 Nikolay Borisov wrote: > > Yes I do. I corrected it in my next email. > > > > http://lkml.kernel.org/r/20190523133648.591f9...@gandalf.local.home > > Or perhaps just using is_power_of_2 from include/linux/log2.h ? Even better. Thanks, -- Steve

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-24 Thread Nikolay Borisov
On 24.05.19 г. 18:26 ч., Steven Rostedt wrote: > On Fri, 24 May 2019 16:11:14 +0100 > Roger Willcocks wrote: > >> On 23/05/2019 16:27, Steven Rostedt wrote: >>> >>> I haven't yet tested this, but what about something like the following: >>> >>> ...perhaps forget about the constant check, and j

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-24 Thread Steven Rostedt
On Fri, 24 May 2019 16:11:14 +0100 Roger Willcocks wrote: > On 23/05/2019 16:27, Steven Rostedt wrote: > > > > I haven't yet tested this, but what about something like the following: > > > > ...perhaps forget about the constant check, and just force > > the power of two check: > > > >

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-24 Thread Roger Willcocks
On 23/05/2019 16:27, Steven Rostedt wrote: I haven't yet tested this, but what about something like the following: ...perhaps forget about the constant check, and just force the power of two check: \ if (!(__y & (__y >> 1))) {

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Linus Torvalds
On Thu, May 23, 2019 at 10:36 AM Steven Rostedt wrote: > > > > > Of course, you probably want the usual "at least use 'int'" semantics, > > in which case the "type" should be "(x)+0": > > > > #define round_up(x, y) size_fn((x)+0, round_up_size, x, y) > > > > and the 8-bit and 16-bit cases wi

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Steven Rostedt
On Thu, 23 May 2019 09:51:29 -0700 Linus Torvalds wrote: > On Thu, May 23, 2019 at 8:27 AM Steven Rostedt wrote: > > > > I haven't yet tested this, but what about something like the following: > > So that at least handles the constant case that the normal "roundup()" > case also handles. > >

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Linus Torvalds
On Thu, May 23, 2019 at 8:27 AM Steven Rostedt wrote: > > I haven't yet tested this, but what about something like the following: So that at least handles the constant case that the normal "roundup()" case also handles. At the same time, in the case you are talking about, I really do suspect tha

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Steven Rostedt
On Thu, 23 May 2019 08:10:44 -0700 Linus Torvalds wrote: > On Thu, May 23, 2019 at 7:00 AM Steven Rostedt wrote: > > > > +# define roundup_64(x, y) (\ > > +{ \ > > + typeof(y) __y = y;

Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Linus Torvalds
On Thu, May 23, 2019 at 7:00 AM Steven Rostedt wrote: > > +# define roundup_64(x, y) (\ > +{ \ > + typeof(y) __y = y; \ > + typeof(x) __x = (x) + (__y - 1);\ >

[RFC][PATCH] kernel.h: Add generic roundup_64() macro

2019-05-23 Thread Steven Rostedt
From: Steven Rostedt (VMware) In discussing a build failure on x86_32 due to the use of roundup() on a 64 bit number, I realized that there's no generic equivalent roundup_64(). It is implemented in two separate places in the kernel, but there really should be just one that all can use. Althoug