linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: "Ted Ts'o" <tytso@mit.edu>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 1/2] ext4: use little-endian bitops directly
Date: Tue, 31 May 2011 18:43:44 +0900	[thread overview]
Message-ID: <BANLkTimnB5okiG_M9zhUG6F22PHPoAsZLw@mail.gmail.com> (raw)
In-Reply-To: <4B858003-053B-4895-BAD7-71861AAFB00E@dilger.ca>

2011/5/31 Andreas Dilger <adilger@dilger.ca>:
> On 2011-05-30, at 9:45 PM, Akinobu Mita wrote:
>> 2011/5/31 Andreas Dilger <adilger@dilger.ca>:
>>> I would also encourage you to finish off this patch series by pushing up the generic ext2_{set,clear}_bit_atomic() to the few places that are currently using ext2_{set,clear}_bit_atomic() directly (looks like only fs/nilfs2/alloc.h and include/linux/ext3.h) and then removing them from the arch headers.
>>
>> The difficulty of doing this is that there are two different
>> implementations of ext2_{set,clear}_bit_atomic (spin lock version and
>> test_and_{set,clear}_bit_le version).  If we can switch to one of which
>> on all architectures, the change is easy.  But I don't have less messy idea
>> to keep current behavior on all architectures.
>
> It looks like all of the versions that are #defined in arch/*/asm/bitops.h are really just re-implementations of test_and_{set,clear}_bit_le(), since they ignore the "lock" parameter entirely.
>
> It would be sufficient to replace all of those implementations with:
>
> #define ARCH_NO_EXT2_ATOMIC_SPINLOCK
> #include <asm-generic/bitops/ext2-atomic.h>
>
> and then change the ext2-atomic.h to check for this:
>
> #ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK
> #define EXT2_SPIN_LOCK(lock)   do {} while(0)
> #define EXT2_SPIN_UNLOCK(lock) do {} while(0)
> #else
> #define EXT2_SPIN_LOCK(lock)   spin_lock(lock)
> #define EXT2_SPIN_UNLOCK(lock) spin_unlock(lock)
> #endif
>
> #define ext2_set_bit_atomic(lock, nr, addr)             \
>       ({                                              \
>               int ret;                                \
>               EXT2_SPIN_LOCK(lock);                   \
>               ret = __test_and_set_bit_le(nr, addr);  \
>               EXT2_SPIN_UNLOCK(lock);                 \
>               ret;                                    \
>       })

This is not equivalent change if ARCH_NO_EXT2_ATOMIC_SPINLOCK is defined
because ext2_set_bit_atomic for the majority of architectures is

#define ext2_set_bit_atomic(lock, nr, addr) \
        test_and_set_bit_le((nr), (unsigned long*)addr)

So ext2-atomic.h could be:

#ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK

#define ext2_set_bit_atomic(l, nr, addr)	test_and_set_bit_le(nr, addr)
#define ext2_clear_bit_atomic(l, nr, addr)	test_and_clear_bit_le(nr, addr)

#else

#define ext2_set_bit_atomic(lock, nr, addr)		\
	({						\
		int ret;				\
		spin_lock(lock);			\
		ret = __test_and_set_bit_le(nr, addr);	\
		spin_unlock(lock);			\
		ret;					\
	})

#define ext2_clear_bit_atomic(lock, nr, addr)		\
	({						\
		int ret;				\
		spin_lock(lock);			\
		ret = __test_and_clear_bit_le(nr, addr);	\
		spin_unlock(lock);			\
		ret;					\
	})

#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2011-05-31  9:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-30 13:49 [PATCH 1/2] ext4: use little-endian bitops directly Akinobu Mita
2011-05-30 13:49 ` [PATCH 2/2] ext4: use proper little-endian bitops Akinobu Mita
2011-05-30 14:49 ` [PATCH 1/2] ext4: use little-endian bitops directly Andreas Dilger
2011-05-30 15:43   ` Ted Ts'o
2011-05-30 16:21     ` Akinobu Mita
2011-05-30 17:58       ` Andreas Dilger
2011-05-31  3:45         ` Akinobu Mita
2011-05-31  4:56           ` Andreas Dilger
2011-05-31  9:43             ` Akinobu Mita [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=BANLkTimnB5okiG_M9zhUG6F22PHPoAsZLw@mail.gmail.com \
    --to=akinobu.mita@gmail.com \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).