From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
xen-devel <xen-devel@lists.xensource.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
kvm-devel <kvm-devel@lists.sourceforge.net>,
benh@kernel.crashing.org, x86@kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Virtualization Mailing List <virtualization@lists.osdl.org>,
Hugh Dickins <hugh@veritas.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1 of 4] mm: add a ptep_modify_prot transaction abstraction
Date: Fri, 20 Jun 2008 12:10:28 +0200 [thread overview]
Message-ID: <20080620101028.GA23664@elte.hu> (raw)
In-Reply-To: <20080619164708.GA32190@elte.hu>
* Ingo Molnar <mingo@elte.hu> wrote:
>
> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> > On Thu, 19 Jun 2008, Ingo Molnar wrote:
> > >
> > > Below is the commit, it needed a small amount of massaging to apply the
> > > void * -> unsigned long * change in the x86/bitops topic.
> >
> > Well, that's your bug right there.
> >
> > The macros very much depended on the pointers being "void *", due to
> > the pointer arithmetic (which is a gcc extension that we use
> > extensively - "void *" arithmetic works as if it was a byte
> > pointer).
>
> duh, yeah - of course. Will retry with that fixed :)
yep, the patch below got it all going and it passed 5 hours of testing
already. Thanks,
Ingo
------------------->
commit 7dbceaf9bb68919651901b101f44edd5391ee489
Author: Ingo Molnar <mingo@elte.hu>
Date: Fri Jun 20 07:28:24 2008 +0200
x86, bitops: make constant-bit set/clear_bit ops faster, adapt, clean up
fix integration bug introduced by "x86: bitops take an unsigned long *"
which turned "(void *) + x" into "(long *) + x".
small cleanups to make it more apparent which value get propagated where.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h
index ab7635a..6c50548 100644
--- a/include/asm-x86/bitops.h
+++ b/include/asm-x86/bitops.h
@@ -28,16 +28,15 @@
#define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
#endif
-#define ADDR BITOP_ADDR(addr)
+#define ADDR BITOP_ADDR(addr)
/*
* We do the locked ops that don't return the old value as
* a mask operation on a byte.
*/
-#define IS_IMMEDIATE(nr) \
- (__builtin_constant_p(nr))
-#define CONST_MASK_ADDR BITOP_ADDR(addr + (nr>>3))
-#define CONST_MASK (1 << (nr & 7))
+#define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
+#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
+#define CONST_MASK(nr) (1 << ((nr) & 7))
/**
* set_bit - Atomically set a bit in memory
@@ -56,13 +55,17 @@
*/
static inline void set_bit(unsigned int nr, volatile unsigned long *addr)
{
- if (IS_IMMEDIATE(nr))
- asm volatile(LOCK_PREFIX "orb %1,%0" : CONST_MASK_ADDR : "i" (CONST_MASK) : "memory");
- else
- asm volatile(LOCK_PREFIX "bts %1,%0" : ADDR : "Ir" (nr) : "memory");
+ if (IS_IMMEDIATE(nr)) {
+ asm volatile(LOCK_PREFIX "orb %1,%0"
+ : CONST_MASK_ADDR(nr, addr)
+ : "i" (CONST_MASK(nr))
+ : "memory");
+ } else {
+ asm volatile(LOCK_PREFIX "bts %1,%0"
+ : BITOP_ADDR(addr) : "Ir" (nr) : "memory");
+ }
}
-
/**
* __set_bit - Set a bit in memory
* @nr: the bit to set
@@ -89,10 +92,15 @@ static inline void __set_bit(int nr, volatile unsigned long *addr)
*/
static inline void clear_bit(int nr, volatile unsigned long *addr)
{
- if (IS_IMMEDIATE(nr))
- asm volatile(LOCK_PREFIX "andb %1,%0" : CONST_MASK_ADDR : "i" (~CONST_MASK));
- else
- asm volatile(LOCK_PREFIX "btr %1,%0" : ADDR : "Ir" (nr));
+ if (IS_IMMEDIATE(nr)) {
+ asm volatile(LOCK_PREFIX "andb %1,%0"
+ : CONST_MASK_ADDR(nr, addr)
+ : "i" (~CONST_MASK(nr)));
+ } else {
+ asm volatile(LOCK_PREFIX "btr %1,%0"
+ : BITOP_ADDR(addr)
+ : "Ir" (nr));
+ }
}
/*
next prev parent reply other threads:[~2008-06-20 10:10 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-16 11:29 [PATCH 0 of 4] mm+paravirt+xen: add pte read-modify-write abstraction (take 2) Jeremy Fitzhardinge
2008-06-16 11:30 ` [PATCH 1 of 4] mm: add a ptep_modify_prot transaction abstraction Jeremy Fitzhardinge
2008-06-16 17:29 ` Linus Torvalds
2008-06-16 18:13 ` Hugh Dickins
2008-06-16 18:49 ` Ingo Molnar
2008-06-18 23:23 ` Benjamin Herrenschmidt
2008-06-18 23:59 ` Jeremy Fitzhardinge
2008-06-19 0:15 ` Jeremy Fitzhardinge
2008-06-19 0:24 ` Linus Torvalds
2008-06-19 0:37 ` Jeremy Fitzhardinge
2008-06-19 0:49 ` Linus Torvalds
2008-06-19 4:03 ` Linus Torvalds
2008-06-19 11:58 ` Ingo Molnar
2008-06-19 12:03 ` Ingo Molnar
2008-06-19 12:20 ` Akinobu Mita
2008-06-19 16:30 ` Linus Torvalds
2008-06-19 16:47 ` Ingo Molnar
2008-06-20 10:10 ` Ingo Molnar [this message]
2008-06-20 19:06 ` Jeremy Fitzhardinge
2008-06-20 19:15 ` Linus Torvalds
2008-06-20 19:56 ` Ingo Molnar
2008-06-20 20:03 ` Linus Torvalds
2008-06-20 20:16 ` Jeremy Fitzhardinge
2008-06-20 20:22 ` Jeremy Fitzhardinge
2008-06-21 6:06 ` Ingo Molnar
2008-06-20 20:05 ` Jeremy Fitzhardinge
2008-06-19 0:39 ` Benjamin Herrenschmidt
2008-06-19 5:03 ` Jeremy Fitzhardinge
2008-06-19 7:20 ` Benjamin Herrenschmidt
2008-06-19 17:57 ` Jeremy Fitzhardinge
2008-06-16 11:30 ` [PATCH 2 of 4] paravirt: add hooks for ptep_modify_prot_start/commit Jeremy Fitzhardinge
2008-06-16 11:30 ` [PATCH 3 of 4] xen: implement ptep_modify_prot_start/commit Jeremy Fitzhardinge
2008-06-16 11:30 ` [PATCH 4 of 4] xen: add mechanism to extend existing multicalls Jeremy Fitzhardinge
-- strict thread matches above, loose matches on Subject: below --
2008-05-31 0:04 [PATCH 0 of 4] mm+paravirt+xen: add pte read-modify-write abstraction (take 2) Jeremy Fitzhardinge
2008-05-31 0:04 ` [PATCH 1 of 4] mm: add a ptep_modify_prot transaction abstraction Jeremy Fitzhardinge
2008-06-02 11:13 ` Ingo Molnar
2008-06-02 11:57 ` Jeremy Fitzhardinge
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=20080620101028.GA23664@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=benh@kernel.crashing.org \
--cc=hugh@veritas.com \
--cc=jeremy@goop.org \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=virtualization@lists.osdl.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.com \
/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).