public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + unaligned-introduce-common-header.patch added to -mm tree
       [not found] <200811190614.mAJ6EsXA007330@imap1.linux-foundation.org>
@ 2008-11-19  8:21 ` Geert Uytterhoeven
  2008-11-19 17:16   ` Harvey Harrison
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2008-11-19  8:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: mm-commits, harvey.harrison, Benjamin Herrenschmidt, bryan.wu,
	David S. Miller, dhowells, Greg Ungerer, grundler, heiko.carstens,
	hskinnemoen, ink, kyle, lethal, linux-arch, mingo, Paul Mackerras,
	Ralf Baechle, Russell King, rth, schwidefsky, takata, tglx,
	tony.luck, ysato, zankel, Roman Zippel, Linux Kernel Development

On Tue, 18 Nov 2008, akpm@linux-foundation.org wrote:
> Subject: unaligned: introduce common header
> From: Harvey Harrison <harvey.harrison@gmail.com>
> 
> There are two common cases in the kernel, one where unaligned access is OK
> for an arch and one where the arch uses a packed-struct for the native
> endianness and opencoded C byteshifting for the other endianness. 
> Consolidate these two implementations in asm-generic/unaligned.h
> 
> Arches that require no special handling of unaligned access can define
> _UNALIGNED_ACCESS_OK in their asm/unaligned.h before including the generic
> version.
> 
> +static inline void __put_le32_noalign(u8 *p, u32 val)
> +{
> +	__put_le16_noalign(p + 2, val >> 16);
> +	__put_le16_noalign(p, val);

Isn't it more logical to reverse the order, to store in increasing memory
locations:

	__put_le16_noalign(p, val);
	__put_le16_noalign(p + 2, val >> 16);

> +}
> +
> +static inline void __put_le64_noalign(u8 *p, u64 val)
> +{
> +	__put_le32_noalign(p + 4, val >> 32);
> +	__put_le32_noalign(p, val);

Same here:

	__put_le32_noalign(p, val);
	__put_le32_noalign(p + 4, val >> 32);

> +}

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + unaligned-introduce-common-header.patch added to -mm tree
  2008-11-19  8:21 ` + unaligned-introduce-common-header.patch added to -mm tree Geert Uytterhoeven
@ 2008-11-19 17:16   ` Harvey Harrison
  0 siblings, 0 replies; 2+ messages in thread
From: Harvey Harrison @ 2008-11-19 17:16 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Andrew Morton, mm-commits, Benjamin Herrenschmidt, bryan.wu,
	David S. Miller, dhowells, Greg Ungerer, grundler, heiko.carstens,
	hskinnemoen, ink, kyle, lethal, linux-arch, mingo, Paul Mackerras,
	Ralf Baechle, Russell King, rth, schwidefsky, takata, tglx,
	tony.luck, ysato, zankel, Roman Zippel, Linux Kernel Development

On Wed, 2008-11-19 at 09:21 +0100, Geert Uytterhoeven wrote:
> On Tue, 18 Nov 2008, akpm@linux-foundation.org wrote:
> > Subject: unaligned: introduce common header
> > From: Harvey Harrison <harvey.harrison@gmail.com>
> > 
> > There are two common cases in the kernel, one where unaligned access is OK
> > for an arch and one where the arch uses a packed-struct for the native
> > endianness and opencoded C byteshifting for the other endianness. 
> > Consolidate these two implementations in asm-generic/unaligned.h
> > 
> > Arches that require no special handling of unaligned access can define
> > _UNALIGNED_ACCESS_OK in their asm/unaligned.h before including the generic
> > version.
> > 
> > +static inline void __put_le32_noalign(u8 *p, u32 val)
> > +{
> > +	__put_le16_noalign(p + 2, val >> 16);
> > +	__put_le16_noalign(p, val);
> 
> Isn't it more logical to reverse the order, to store in increasing memory
> locations:
> 
> 	__put_le16_noalign(p, val);
> 	__put_le16_noalign(p + 2, val >> 16);
> 

All of the byteshifting versions were cribbed from the ARM implementation.

I'm not sure if there was a particular reason for doing it in this order, but
a lot of work seems to have gone in to minimize register usage.

See include/asm-arm/unaligned.h circa 2.6.25.

Harvey


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-19 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200811190614.mAJ6EsXA007330@imap1.linux-foundation.org>
2008-11-19  8:21 ` + unaligned-introduce-common-header.patch added to -mm tree Geert Uytterhoeven
2008-11-19 17:16   ` Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox