public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	akpm@linux-foundation.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v4 00/24] Introduce little endian bitops
Date: Mon, 17 Jan 2011 09:34:18 +0000	[thread overview]
Message-ID: <20110117093418.GA25694@flint.arm.linux.org.uk> (raw)
In-Reply-To: <AANLkTimvUaGJ1eps5thgBUKjAjXuNN-6O4i-oBXZtQsd@mail.gmail.com>

On Sun, Jan 16, 2011 at 06:50:39PM -0800, Linus Torvalds wrote:
> On Sun, Jan 16, 2011 at 6:37 PM, Akinobu Mita <akinobu.mita@gmail.com> wrote:
> >
> > Changing *_bit_le() to take "void *" instead of "unsigned long *"
> > makes this patch series acceptable?
> 
> That would seem to at least make all the filesystem code happier, and
> they can continue to do just something like
> 
>    #define ext2_set_bit __set_bit_le
> 
> (or whatever the exact sequence ends up being).
> 
> > Or do we also need to change *_bit_le() to handle unaligned address
> > correctly?  (i.e. not only long aligned address but also byte aligned
> > address)
> 
> No, I don't think that is required. We've never done it before, and
> we've never had the type-safety for the little-endian (aka "minix")
> bitops historically. So I'd just keep the status quo.

The ARM bitops (set_bit/clear_bit/change_bit) have always taken an
unsigned long argument and we have casts in our preprocessor macros
for them.  Only a couple of the find_bit functions have taken a
void pointer.

I really don't want to have to change the function prototypes on ARM,
and I really don't want to hide this fact from non-fs users that ARM
bitops require such pointers, with the exception of what's required
for ext2/minix.  If we do hide it, at some point we'll have someone
believing that ARM's wrong to be requiring stricter alignment.

As ARM bitops now (in my tree) require strict alignment to unsigned long.
A 32-bit load exclusive assembly instruction must never be misaligned,
there's no way to safely fix that kind thing up.  (No, you can't reliably
use spinlocks and normal stores - what if another thread does an aligned
load exclusive/store exclusive, which won't trap?)

The reason for this change is to avoid the current situation where people
are building kernels which support multiple platforms - including SMP -
but because the instructions used for the SMP-safe bitops (byte load
exclusive) are not supported on some of the selected processors, we fall
back to the SMP-unsafe versions.  However, using the word load exclusive
instructions are supported.

I've also added tests in the assembly to ensure pointer alignment (which,
as we're talking about filesystem data corruption if for some reason
these misbehave due to misaligned pointers is something I've done anyway).

If the generic bitops are going to be changed to void pointers, maybe the
solution to this is to document that bitops require 'unsigned long *'
alignment on some platforms?

  reply	other threads:[~2011-01-17  9:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-16 13:08 [PATCH v4 00/24] Introduce little endian bitops Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 01/24] bitops: merge little and big endian definisions in asm-generic/bitops/le.h Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 02/24] asm-generic: rename generic little-endian bitops functions Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 03/24] powerpc: introduce little-endian bitops Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 04/24] s390: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 05/24] arm: " Akinobu Mita
2011-01-16 17:51   ` Russell King
2011-01-17  2:36     ` Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 06/24] m68k: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 07/24] bitops: introduce CONFIG_GENERIC_FIND_BIT_LE Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 08/24] m68knommu: introduce little-endian bitops Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 09/24] bitops: introduce little-endian bitops for most architectures Akinobu Mita
2011-01-16 21:18   ` H. Peter Anvin
2011-01-17 10:01   ` Hans-Christian Egtvedt
2011-01-16 13:08 ` [PATCH v4 10/24] rds: stop including asm-generic/bitops/le.h Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 11/24] kvm: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 12/24] asm-generic: use little-endian bitops Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 13/24] ext3: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 14/24] ext4: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 15/24] ocfs2: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 16/24] nilfs2: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 17/24] reiserfs: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 18/24] udf: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 19/24] ufs: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 20/24] md: use little-endian bit operations Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 21/24] dm: " Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 22/24] bitops: remove ext2 non-atomic bitops from asm/bitops.h Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 23/24] m68k: remove inline asm from minix_find_first_zero_bit Akinobu Mita
2011-01-16 13:08 ` [PATCH v4 24/24] bitops: remove minix bitops from asm/bitops.h Akinobu Mita
2011-01-16 18:57 ` [PATCH v4 00/24] Introduce little endian bitops Linus Torvalds
2011-01-17  2:37   ` Akinobu Mita
2011-01-17  2:50     ` Linus Torvalds
2011-01-17  9:34       ` Russell King [this message]
2011-01-18  9:49         ` Akinobu Mita

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=20110117093418.GA25694@flint.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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