public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Chris Zankel <chris@zankel.net>,
	Russell King <rmk@arm.linux.org.uk>,
	David Howells <dhowells@redhat.com>,
	Hirokazu Takata <takata@linux-m32r.org>
Subject: Re: [PATCH 1/4] h8300: Change unaligned access to use packed struct implementation
Date: Wed, 08 Oct 2008 18:18:11 -0700	[thread overview]
Message-ID: <1223515092.8195.136.camel@brick> (raw)
In-Reply-To: <20081008140214.GC2739@x200.localdomain>

On Wed, 2008-10-08 at 18:02 +0400, Alexey Dobriyan wrote:
> On Tue, Oct 07, 2008 at 11:38:22PM -0700, Harvey Harrison wrote:
> > There are only 3 arches that use the memmove-based implementation, there
> > doesn't seem to be any obvious reason not to use the struct implementation.
> 
> 1. Extensive use of "--- " area means changelogs are written badly.
> 2. Changing one of arch core header we can deduce from patch and this
>    exactly what subject line says.
> 3. As such there is absolutely no changelog.
> 
> [goes into digging how all this byteorder and endian activity was
> started]

It started by introducing the unaligned endian helper functions such as
get_unaligned_le16 to replace the repeated pattern of
u16 foo = le16_to_cpu(get_unaligned(some_le16 *));

and put_unaligned_le16 to replace the pattern of
put_unaligned(cpu_to_le16(some_u16), some_le16 *)

To do this I first consolidated the various unaligned implementations that
were in the kernel, which fell into the following:

1) Unaligned access was OK
2) Access values through a packed-struct (inspired by ia64 first I think)
3) Open-coded C byteshifting version (inspired by ARM)
4) memcpy/memmove based
5) FRV had a custom

So I collected them into a common include/linux/unaligned/ folder and moved
the arches to pull the implementation from there, with no behavioral changes,
except for FRV which lost its assembly version as the C (3) version produced
better code.

SO of the 4 remaining implementations, we have the following:

1) Unaligned Access-ok
Cris,m68k,mn10300,x86,m68knommu (non-coldfire),powerpc,s390

2) Struct-based
Alpha,AVR32,Mips,parisc,blackfin,ia64,m68knommu (coldfire),sh,sparc,sparc64

3) Open-coded byteshifting for both native and opposite endianness
Arm,FRV

4) memmove-based
xtensa,m32r,h8300

This series should have had an RFC on the front as I'm really just asking the maintainers
of these arches if they could move to the packed-struct versions, or if they had a particlar
need for the memmove version (toolchain, code generation, etc.)

In addition I'm also investigating moving FRV and ARM to use the packed-sruct version and if
so the whole unaligned/ folder could just become a single implementation in asm-generic
making it easier to change some of the unaligned access/byteorder functions _if_ needed.

As it stands the proposal I was going to make looked somewhat like the following:

Introduce the api:
load_le16(const __le16 *)
store_le16(__le16 *, u16)
load_unaligned_le16(const __le16 *)
store_unaligned_le16(__le16 *, u16)

load_le16() is a duplicate of the existing le16_to_cpup, all of which would
be replaced by the new api and the pointer variant removed.  All of the existing
users of cpu_to_le16p would also be removed as there are a trivial number of users
and many of them would be more efficient if they just used the value-based endian
helpers directly.

store_le16 is new-API and would replace a few private helpers that exist already in
the kernel.

The get_unaligned/put_unaligned API would then be transitioned to the load/store
variants, which are no different in the get/load case, and have opposite argument
ordering in the put/store case.


This would leave the endian helpers looking like:

cpu_to_le16
le16_to_cpu
cpu_to_le16s
le16_to_cpus
load_le16
store_le16
load_unaligned_le16
store_unaligned_le16

Notice that cpu_to_le16p, le16_to_cpup are gone.

Hope that helps with the larger picture.

Cheers,

Harvey


      reply	other threads:[~2008-10-09  1:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08  6:38 [PATCH 1/4] h8300: Change unaligned access to use packed struct implementation Harvey Harrison
2008-10-08 14:02 ` Alexey Dobriyan
2008-10-09  1:18   ` Harvey Harrison [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1223515092.8195.136.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@zankel.net \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=takata@linux-m32r.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox