Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Vineet Gupta
On 07/09/2018 03:23 AM, Alexey Brodkin wrote: > Hi David, > > On Mon, 2018-07-09 at 10:18 +, David Laight wrote: >> From: Alexey Brodkin >>> Sent: 09 July 2018 11:00 >> >> ... >>> That's a good idea indeed but it doesn't solve the problem with >>> struct devres_node. Consider the following

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Vineet Gupta
On 07/09/2018 09:10 AM, David Laight wrote: > From: Mark Rutland >> Sent: 09 July 2018 16:49 >> >> On Mon, Jul 09, 2018 at 05:45:21PM +0200, Peter Zijlstra wrote: >>> On Mon, Jul 09, 2018 at 05:34:27PM +0200, Peter Zijlstra wrote: On Mon, Jul 09, 2018 at 04:29:58PM +0100, Mark Rutland wrote:

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Alexey Brodkin
Hi Greg, On Mon, 2018-07-09 at 07:48 +0200, Greg KH wrote: > On Mon, Jul 09, 2018 at 07:44:44AM +0300, Alexey Brodkin wrote: > > Depending on ABI "long long" type of a particular 32-bit CPU > > might be aligned by either word (32-bits) or double word (64-bits). > > Make sure "data" is really

RE: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread David Laight
From: Geert Uytterhoeven > Sent: 09 July 2018 10:23 > On Mon, Jul 9, 2018 at 11:15 AM David Laight wrote: > > From: Alexey Brodkin > > > Sent: 09 July 2018 05:45 > > > Depending on ABI "long long" type of a particular 32-bit CPU > > > might be aligned by either word (32-bits) or double word

RE: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread David Laight
From: Alexey Brodkin > Sent: 09 July 2018 11:00 ... > That's a good idea indeed but it doesn't solve the problem with > struct devres_node. Consider the following snippet: > >8--- > struct mystruct { > atomic64_t

RE: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread David Laight
From: Alexey Brodkin > Sent: 09 July 2018 05:45 > Depending on ABI "long long" type of a particular 32-bit CPU > might be aligned by either word (32-bits) or double word (64-bits). > Make sure "data" is really 64-bit aligned for any 32-bit CPU. > > At least for 32-bit ARC cores ABI requires "long

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Geert Uytterhoeven
Hi Alexey, On Mon, Jul 9, 2018 at 10:37 AM Alexey Brodkin wrote: > On Mon, 2018-07-09 at 09:52 +0200, Geert Uytterhoeven wrote: > > On Mon, Jul 9, 2018 at 9:22 AM Alexey Brodkin > > wrote: > > > On Mon, 2018-07-09 at 09:07 +0200, Geert Uytterhoeven wrote: > > > > On Mon, Jul 9, 2018 at 7:49 AM

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Alexey Brodkin
Hi David, On Mon, 2018-07-09 at 09:16 +, David Laight wrote: > From: Alexey Brodkin > > Sent: 09 July 2018 05:45 > > Depending on ABI "long long" type of a particular 32-bit CPU > > might be aligned by either word (32-bits) or double word (64-bits). > > Make sure "data" is really 64-bit

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Geert Uytterhoeven
On Mon, Jul 9, 2018 at 11:15 AM David Laight wrote: > From: Alexey Brodkin > > Sent: 09 July 2018 05:45 > > Depending on ABI "long long" type of a particular 32-bit CPU > > might be aligned by either word (32-bits) or double word (64-bits). > > Make sure "data" is really 64-bit aligned for any

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread g...@kroah.com
On Mon, Jul 09, 2018 at 06:46:50AM +, Alexey Brodkin wrote: > Hi Greg, > > On Mon, 2018-07-09 at 07:48 +0200, Greg KH wrote: > > On Mon, Jul 09, 2018 at 07:44:44AM +0300, Alexey Brodkin wrote: > > > Depending on ABI "long long" type of a particular 32-bit CPU > > > might be aligned by either

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Geert Uytterhoeven
On Mon, Jul 9, 2018 at 7:49 AM Greg KH wrote: > On Mon, Jul 09, 2018 at 07:44:44AM +0300, Alexey Brodkin wrote: > > Depending on ABI "long long" type of a particular 32-bit CPU > > might be aligned by either word (32-bits) or double word (64-bits). Or even 16-bit (on e.g. m68k). > > ---

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread g...@kroah.com
On Mon, Jul 09, 2018 at 07:17:11AM +, Alexey Brodkin wrote: > Hi Greg, > > On Mon, 2018-07-09 at 09:06 +0200, g...@kroah.com wrote: > > On Mon, Jul 09, 2018 at 06:46:50AM +, Alexey Brodkin wrote: > > > Hi Greg, > > > > > > On Mon, 2018-07-09 at 07:48 +0200, Greg KH wrote: > > > > On Mon,

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Alexey Brodkin
Hi Geert, On Mon, 2018-07-09 at 09:52 +0200, Geert Uytterhoeven wrote: > Hi Alexey, > > On Mon, Jul 9, 2018 at 9:22 AM Alexey Brodkin > wrote: > > On Mon, 2018-07-09 at 09:07 +0200, Geert Uytterhoeven wrote: > > > On Mon, Jul 9, 2018 at 7:49 AM Greg KH wrote: > > > > On Mon, Jul 09, 2018 at

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Alexey Brodkin
Hi Geert, On Mon, 2018-07-09 at 09:07 +0200, Geert Uytterhoeven wrote: > On Mon, Jul 9, 2018 at 7:49 AM Greg KH wrote: > > On Mon, Jul 09, 2018 at 07:44:44AM +0300, Alexey Brodkin wrote: > > > Depending on ABI "long long" type of a particular 32-bit CPU > > > might be aligned by either word

Re: [RESEND PATCH v2] devres: Really align data field to unsigned long long

2018-07-09 Thread Geert Uytterhoeven
Hi Alexey, On Mon, Jul 9, 2018 at 9:22 AM Alexey Brodkin wrote: > On Mon, 2018-07-09 at 09:07 +0200, Geert Uytterhoeven wrote: > > On Mon, Jul 9, 2018 at 7:49 AM Greg KH wrote: > > > On Mon, Jul 09, 2018 at 07:44:44AM +0300, Alexey Brodkin wrote: > > > > Depending on ABI "long long" type of a

RE: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread David Laight
From: Mark Rutland > Sent: 09 July 2018 16:49 > > On Mon, Jul 09, 2018 at 05:45:21PM +0200, Peter Zijlstra wrote: > > On Mon, Jul 09, 2018 at 05:34:27PM +0200, Peter Zijlstra wrote: > > > On Mon, Jul 09, 2018 at 04:29:58PM +0100, Mark Rutland wrote: > > > > Shouldn't that be 8? AFAICT,

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread kbuild test robot
Hi Alexey, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.18-rc4 next-20180709] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote: > diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h > index 8d28eb010d0d..b94b749b5952 100644 > --- a/include/asm-generic/atomic64.h > +++ b/include/asm-generic/atomic64.h > @@ -13,7 +13,7 @@ > #define

[PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Alexey Brodkin
data[] must be 64-bit aligned even on 32-bit architectures because it might be accessed by instructions that require aligned memory arguments. One example is "atomic64_t" type accessed by special atomic instructions which may read/write entire 64-bit word. Atomic instructions are a bit special

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > diff --git a/drivers/base/devres.c b/drivers/base/devres.c > index f98a097e73f2..d65327cb83c9 100644 > --- a/drivers/base/devres.c > +++ b/drivers/base/devres.c > @@ -24,8 +24,12 @@ struct devres_node { > > struct devres { >

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Will Deacon
On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote: > Atomic instructions require data they operate on to be aligned > according to data size. I.e. 32-bit atomic values must be 32-bit > aligned while 64-bit values must be 64-bit aligned. > > Otherwise even if CPU may handle

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Geert Uytterhoeven
On Mon, Jul 9, 2018 at 3:29 PM David Laight wrote: > From: Alexey Brodkin > > Sent: 09 July 2018 13:48 > > Atomic instructions require data they operate on to be aligned > > according to data size. I.e. 32-bit atomic values must be 32-bit > > aligned while 64-bit values must be 64-bit aligned. >

[PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Alexey Brodkin
Atomic instructions require data they operate on to be aligned according to data size. I.e. 32-bit atomic values must be 32-bit aligned while 64-bit values must be 64-bit aligned. Otherwise even if CPU may handle not-aligend normal data access, still atomic instructions fail and typically raise

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Alexey Brodkin
Hi Peter, On Mon, 2018-07-09 at 16:10 +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 04:07:17PM +0200, Peter Zijlstra wrote: > > On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > > > --- a/drivers/base/devres.c > > > +++ b/drivers/base/devres.c > > > @@ -24,8 +24,12 @@

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Mark Rutland
On Mon, Jul 09, 2018 at 03:54:09PM +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > > diff --git a/drivers/base/devres.c b/drivers/base/devres.c > > index f98a097e73f2..d65327cb83c9 100644 > > --- a/drivers/base/devres.c > > +++

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Alexey Brodkin
Hi Peter, On Mon, 2018-07-09 at 15:54 +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > > diff --git a/drivers/base/devres.c b/drivers/base/devres.c > > index f98a097e73f2..d65327cb83c9 100644 > > --- a/drivers/base/devres.c > > +++

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Russell King - ARM Linux
On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote: > Atomic instructions require data they operate on to be aligned > according to data size. I.e. 32-bit atomic values must be 32-bit > aligned while 64-bit values must be 64-bit aligned. > > Otherwise even if CPU may handle

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > --- a/drivers/base/devres.c > +++ b/drivers/base/devres.c > @@ -24,8 +24,12 @@ struct devres_node { > > struct devres { > struct devres_node node; > - /* -- 3 pointers */ > - unsigned long long

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Geert Uytterhoeven
On Mon, Jul 9, 2018 at 4:04 PM Mark Rutland wrote: > On Mon, Jul 09, 2018 at 03:54:09PM +0200, Peter Zijlstra wrote: > > On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > > > diff --git a/drivers/base/devres.c b/drivers/base/devres.c > > > index f98a097e73f2..d65327cb83c9 100644 >

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Alexey Brodkin
Hi Peter, On Mon, 2018-07-09 at 16:49 +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 02:33:26PM +, Alexey Brodkin wrote: > > > In fact, since alloc_dr() uses kmalloc() to allocate the entire thing, > > > it is impossible to guarantee a larger alignment than kmalloc does. > > > > Well

RE: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread David Laight
From: Peter Zijlstra > Sent: 09 July 2018 15:49 > On Mon, Jul 09, 2018 at 02:33:26PM +, Alexey Brodkin wrote: > > > In fact, since alloc_dr() uses kmalloc() to allocate the entire thing, > > > it is impossible to guarantee a larger alignment than kmalloc does. > > > > Well but 4-bytes [which

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 04:07:17PM +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 04:45:50PM +0300, Alexey Brodkin wrote: > > --- a/drivers/base/devres.c > > +++ b/drivers/base/devres.c > > @@ -24,8 +24,12 @@ struct devres_node { > > > > struct devres { > > struct devres_node

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Alexey Brodkin
Hi Peter, On Mon, 2018-07-09 at 15:35 +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 03:47:41PM +0300, Alexey Brodkin wrote: > > diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h > > index 8d28eb010d0d..b94b749b5952 100644 > > ---

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 02:30:41PM +, Alexey Brodkin wrote: > Hm, any thoughts on why it's "u64" for 32-bit x86? Accident probably. It probably doesn't really matter all that much because the kernel hard assumes 2s complement, but it is somewhat inconsistent.

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 02:33:26PM +, Alexey Brodkin wrote: > > In fact, since alloc_dr() uses kmalloc() to allocate the entire thing, > > it is impossible to guarantee a larger alignment than kmalloc does. > > Well but 4-bytes [which is critical for atomic64_t] should be much less > than a

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Mark Rutland
On Mon, Jul 09, 2018 at 04:49:25PM +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 02:33:26PM +, Alexey Brodkin wrote: > > > In fact, since alloc_dr() uses kmalloc() to allocate the entire thing, > > > it is impossible to guarantee a larger alignment than kmalloc does. > > > > Well but

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 04:29:58PM +0100, Mark Rutland wrote: > Shouldn't that be 8? AFAICT, __alignof__(unsigned long long) is 8 on > x86_32: Curious, I wonder why we put that align in atomic64_32 then. ___ linux-snps-arc mailing list

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Mark Rutland
On Mon, Jul 09, 2018 at 05:45:21PM +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 05:34:27PM +0200, Peter Zijlstra wrote: > > On Mon, Jul 09, 2018 at 04:29:58PM +0100, Mark Rutland wrote: > > > Shouldn't that be 8? AFAICT, __alignof__(unsigned long long) is 8 on > > > x86_32: > > > >

Re: [PATCH v3] devres: Explicitly align datai[] to 64-bit

2018-07-09 Thread Peter Zijlstra
On Mon, Jul 09, 2018 at 05:34:27PM +0200, Peter Zijlstra wrote: > On Mon, Jul 09, 2018 at 04:29:58PM +0100, Mark Rutland wrote: > > Shouldn't that be 8? AFAICT, __alignof__(unsigned long long) is 8 on > > x86_32: > > Curious, I wonder why we put that align in atomic64_32 then. Shiny, look at

Re: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment

2018-07-09 Thread kbuild test robot
Hi Alexey, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.18-rc4 next-20180709] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux