Re: [PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-08-08 Thread Daniel Walker
On Mon, 2007-08-06 at 09:21 +0200, Ingo Molnar wrote:
> * Daniel Walker <[EMAIL PROTECTED]> wrote:
> 
> > Replace the old PICK_OP style macros with PICK_FUNCTION. Although, 
> > seqlocks has some alien code, which I also replaced as can be seen 
> > from the line count below.
> 
> ok, i very much like the cleanup effects here, could you resend your 
> latest version of this (with Peter's suggested cleanup) against -rc2-rt2 
> so that i can apply it?

Ok, sent them privately. Updated to 2.6.23-rc2-rt2 w/ Peter's
suggestion. You'll get two sets the first had some unrefreshed hunks in
the 3/3 patch .

There is one thing I was wondering about in seqlock.h . There was a
class of these macro's like below,

#define PICK_SEQOP_CONST_RET(op, lock)  \
({  \
unsigned long __ret;\
\
if (TYPE_EQUAL((lock), raw_seqlock_t))  \
__ret = op##_raw((const raw_seqlock_t *)(lock));\
else if (TYPE_EQUAL((lock), seqlock_t)) \
__ret = op((seqlock_t *)(lock));\
else __ret = __bad_seqlock_type();  \
\
__ret;  \
})

Where the variable is specifically casted to "const raw_seqlock_t *".. I
ended up dropping these all together, and I'm wonder what the adverse
effects of that are .. The casting seems superfluous to me since you
know already that the type are compatible at that point. Any thoughts?

Daniel

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-08-08 Thread Daniel Walker
On Mon, 2007-08-06 at 09:21 +0200, Ingo Molnar wrote:
 * Daniel Walker [EMAIL PROTECTED] wrote:
 
  Replace the old PICK_OP style macros with PICK_FUNCTION. Although, 
  seqlocks has some alien code, which I also replaced as can be seen 
  from the line count below.
 
 ok, i very much like the cleanup effects here, could you resend your 
 latest version of this (with Peter's suggested cleanup) against -rc2-rt2 
 so that i can apply it?

Ok, sent them privately. Updated to 2.6.23-rc2-rt2 w/ Peter's
suggestion. You'll get two sets the first had some unrefreshed hunks in
the 3/3 patch .

There is one thing I was wondering about in seqlock.h . There was a
class of these macro's like below,

#define PICK_SEQOP_CONST_RET(op, lock)  \
({  \
unsigned long __ret;\
\
if (TYPE_EQUAL((lock), raw_seqlock_t))  \
__ret = op##_raw((const raw_seqlock_t *)(lock));\
else if (TYPE_EQUAL((lock), seqlock_t)) \
__ret = op((seqlock_t *)(lock));\
else __ret = __bad_seqlock_type();  \
\
__ret;  \
})

Where the variable is specifically casted to const raw_seqlock_t *.. I
ended up dropping these all together, and I'm wonder what the adverse
effects of that are .. The casting seems superfluous to me since you
know already that the type are compatible at that point. Any thoughts?

Daniel

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-08-06 Thread Ingo Molnar

* Daniel Walker <[EMAIL PROTECTED]> wrote:

> Replace the old PICK_OP style macros with PICK_FUNCTION. Although, 
> seqlocks has some alien code, which I also replaced as can be seen 
> from the line count below.

ok, i very much like the cleanup effects here, could you resend your 
latest version of this (with Peter's suggested cleanup) against -rc2-rt2 
so that i can apply it?

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-08-06 Thread Ingo Molnar

* Daniel Walker [EMAIL PROTECTED] wrote:

 Replace the old PICK_OP style macros with PICK_FUNCTION. Although, 
 seqlocks has some alien code, which I also replaced as can be seen 
 from the line count below.

ok, i very much like the cleanup effects here, could you resend your 
latest version of this (with Peter's suggested cleanup) against -rc2-rt2 
so that i can apply it?

Ingo
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-07-29 Thread Daniel Walker
Replace the old PICK_OP style macros with PICK_FUNCTION. Although,
seqlocks has some alien code, which I also replaced as can be seen
from the line count below.

Signed-off-by: Daniel Walker <[EMAIL PROTECTED]>

---
 include/linux/seqlock.h |  234 +++-
 1 file changed, 134 insertions(+), 100 deletions(-)

Index: linux-2.6.22/include/linux/seqlock.h
===
--- linux-2.6.22.orig/include/linux/seqlock.h
+++ linux-2.6.22/include/linux/seqlock.h
@@ -90,6 +90,12 @@ static inline void __write_seqlock(seqlo
smp_wmb();
 }
 
+static __always_inline unsigned long __write_seqlock_irqsave(seqlock_t *sl)
+{
+   __write_seqlock(sl);
+   return 0;
+}
+
 static inline void __write_sequnlock(seqlock_t *sl)
 {
smp_wmb();
@@ -97,6 +103,8 @@ static inline void __write_sequnlock(seq
spin_unlock(>lock);
 }
 
+#define __write_sequnlock_irqrestore(sl, flags)__write_sequnlock(sl)
+
 static inline int __write_tryseqlock(seqlock_t *sl)
 {
int ret = spin_trylock(>lock);
@@ -149,6 +157,28 @@ static __always_inline void __write_seql
smp_wmb();
 }
 
+static __always_inline unsigned long
+__write_seqlock_irqsave_raw(raw_seqlock_t *sl)
+{
+   unsigned long flags;
+
+   local_irq_save(flags);
+   __write_seqlock_raw(sl);
+   return flags;
+}
+
+static __always_inline void __write_seqlock_irq_raw(raw_seqlock_t *sl)
+{
+   local_irq_disable();
+   __write_seqlock_raw(sl);
+}
+
+static __always_inline void __write_seqlock_bh_raw(raw_seqlock_t *sl)
+{
+   local_bh_disable();
+   __write_seqlock_raw(sl);
+}
+
 static __always_inline void __write_sequnlock_raw(raw_seqlock_t *sl)
 {
smp_wmb();
@@ -156,6 +186,27 @@ static __always_inline void __write_sequ
spin_unlock(>lock);
 }
 
+static __always_inline void
+__write_sequnlock_irqrestore_raw(raw_seqlock_t *sl, unsigned long flags)
+{
+   __write_sequnlock_raw(sl);
+   local_irq_restore(flags);
+   preempt_check_resched();
+}
+
+static __always_inline void __write_sequnlock_irq_raw(raw_seqlock_t *sl)
+{
+   __write_sequnlock_raw(sl);
+   local_irq_enable();
+   preempt_check_resched();
+}
+
+static __always_inline void __write_sequnlock_bh_raw(raw_seqlock_t *sl)
+{
+   __write_sequnlock_raw(sl);
+   local_bh_enable();
+}
+
 static __always_inline int __write_tryseqlock_raw(raw_seqlock_t *sl)
 {
int ret = spin_trylock(>lock);
@@ -182,60 +233,92 @@ static __always_inline int __read_seqret
 
 extern int __bad_seqlock_type(void);
 
-#define PICK_SEQOP(op, lock)   \
+/*
+ * PICK_SEQ_OP() is a small redirector to allow less typing of the lock
+ * types raw_seqlock_t, seqlock_t, at the front of the PICK_FUNCTION
+ * macro.
+ */
+#define PICK_SEQ_OP(...) PICK_FUNCTION(raw_seqlock_t, seqlock_t, ##__VA_ARGS__)
+#define PICK_SEQ_OP_RET(...) \
+   PICK_FUNCTION_RET(raw_seqlock_t, seqlock_t, ##__VA_ARGS__)
+
+#define write_seqlock(sl) PICK_SEQ_OP(__write_seqlock_raw, __write_seqlock, sl)
+
+#define write_sequnlock(sl)\
+   PICK_SEQ_OP(__write_sequnlock_raw, __write_sequnlock, sl)
+
+#define write_tryseqlock(sl)   \
+   PICK_SEQ_OP_RET(__write_tryseqlock_raw, __write_tryseqlock, sl)
+
+#define read_seqbegin(sl)  \
+   PICK_SEQ_OP_RET(__read_seqbegin_raw, __read_seqbegin, sl)
+
+#define read_seqretry(sl, iv)  \
+   PICK_SEQ_OP_RET(__read_seqretry_raw, __read_seqretry, sl, iv)
+
+#define write_seqlock_irqsave(lock, flags) \
 do {   \
-   if (TYPE_EQUAL((lock), raw_seqlock_t))  \
-   op##_raw((raw_seqlock_t *)(lock));  \
-   else if (TYPE_EQUAL((lock), seqlock_t)) \
-   op((seqlock_t *)(lock));\
-   else __bad_seqlock_type();  \
+   flags = PICK_SEQ_OP_RET(__write_seqlock_irqsave_raw,\
+   __write_seqlock_irqsave, lock); \
 } while (0)
 
-#define PICK_SEQOP_RET(op, lock)   \
-({ \
-   unsigned long __ret;\
-   \
-   if (TYPE_EQUAL((lock), raw_seqlock_t))  \
-   __ret = op##_raw((raw_seqlock_t *)(lock));  \
-   else if (TYPE_EQUAL((lock), seqlock_t)) \
-   __ret = op((seqlock_t *)(lock));\
-   else __ret = __bad_seqlock_type();  \
-   \
-   __ret;  \
-})
-
-#define PICK_SEQOP_CONST_RET(op, lock) \
-({   

[PATCH -rt 9/9] seqlocks: use PICK_FUNCTION

2007-07-29 Thread Daniel Walker
Replace the old PICK_OP style macros with PICK_FUNCTION. Although,
seqlocks has some alien code, which I also replaced as can be seen
from the line count below.

Signed-off-by: Daniel Walker [EMAIL PROTECTED]

---
 include/linux/seqlock.h |  234 +++-
 1 file changed, 134 insertions(+), 100 deletions(-)

Index: linux-2.6.22/include/linux/seqlock.h
===
--- linux-2.6.22.orig/include/linux/seqlock.h
+++ linux-2.6.22/include/linux/seqlock.h
@@ -90,6 +90,12 @@ static inline void __write_seqlock(seqlo
smp_wmb();
 }
 
+static __always_inline unsigned long __write_seqlock_irqsave(seqlock_t *sl)
+{
+   __write_seqlock(sl);
+   return 0;
+}
+
 static inline void __write_sequnlock(seqlock_t *sl)
 {
smp_wmb();
@@ -97,6 +103,8 @@ static inline void __write_sequnlock(seq
spin_unlock(sl-lock);
 }
 
+#define __write_sequnlock_irqrestore(sl, flags)__write_sequnlock(sl)
+
 static inline int __write_tryseqlock(seqlock_t *sl)
 {
int ret = spin_trylock(sl-lock);
@@ -149,6 +157,28 @@ static __always_inline void __write_seql
smp_wmb();
 }
 
+static __always_inline unsigned long
+__write_seqlock_irqsave_raw(raw_seqlock_t *sl)
+{
+   unsigned long flags;
+
+   local_irq_save(flags);
+   __write_seqlock_raw(sl);
+   return flags;
+}
+
+static __always_inline void __write_seqlock_irq_raw(raw_seqlock_t *sl)
+{
+   local_irq_disable();
+   __write_seqlock_raw(sl);
+}
+
+static __always_inline void __write_seqlock_bh_raw(raw_seqlock_t *sl)
+{
+   local_bh_disable();
+   __write_seqlock_raw(sl);
+}
+
 static __always_inline void __write_sequnlock_raw(raw_seqlock_t *sl)
 {
smp_wmb();
@@ -156,6 +186,27 @@ static __always_inline void __write_sequ
spin_unlock(sl-lock);
 }
 
+static __always_inline void
+__write_sequnlock_irqrestore_raw(raw_seqlock_t *sl, unsigned long flags)
+{
+   __write_sequnlock_raw(sl);
+   local_irq_restore(flags);
+   preempt_check_resched();
+}
+
+static __always_inline void __write_sequnlock_irq_raw(raw_seqlock_t *sl)
+{
+   __write_sequnlock_raw(sl);
+   local_irq_enable();
+   preempt_check_resched();
+}
+
+static __always_inline void __write_sequnlock_bh_raw(raw_seqlock_t *sl)
+{
+   __write_sequnlock_raw(sl);
+   local_bh_enable();
+}
+
 static __always_inline int __write_tryseqlock_raw(raw_seqlock_t *sl)
 {
int ret = spin_trylock(sl-lock);
@@ -182,60 +233,92 @@ static __always_inline int __read_seqret
 
 extern int __bad_seqlock_type(void);
 
-#define PICK_SEQOP(op, lock)   \
+/*
+ * PICK_SEQ_OP() is a small redirector to allow less typing of the lock
+ * types raw_seqlock_t, seqlock_t, at the front of the PICK_FUNCTION
+ * macro.
+ */
+#define PICK_SEQ_OP(...) PICK_FUNCTION(raw_seqlock_t, seqlock_t, ##__VA_ARGS__)
+#define PICK_SEQ_OP_RET(...) \
+   PICK_FUNCTION_RET(raw_seqlock_t, seqlock_t, ##__VA_ARGS__)
+
+#define write_seqlock(sl) PICK_SEQ_OP(__write_seqlock_raw, __write_seqlock, sl)
+
+#define write_sequnlock(sl)\
+   PICK_SEQ_OP(__write_sequnlock_raw, __write_sequnlock, sl)
+
+#define write_tryseqlock(sl)   \
+   PICK_SEQ_OP_RET(__write_tryseqlock_raw, __write_tryseqlock, sl)
+
+#define read_seqbegin(sl)  \
+   PICK_SEQ_OP_RET(__read_seqbegin_raw, __read_seqbegin, sl)
+
+#define read_seqretry(sl, iv)  \
+   PICK_SEQ_OP_RET(__read_seqretry_raw, __read_seqretry, sl, iv)
+
+#define write_seqlock_irqsave(lock, flags) \
 do {   \
-   if (TYPE_EQUAL((lock), raw_seqlock_t))  \
-   op##_raw((raw_seqlock_t *)(lock));  \
-   else if (TYPE_EQUAL((lock), seqlock_t)) \
-   op((seqlock_t *)(lock));\
-   else __bad_seqlock_type();  \
+   flags = PICK_SEQ_OP_RET(__write_seqlock_irqsave_raw,\
+   __write_seqlock_irqsave, lock); \
 } while (0)
 
-#define PICK_SEQOP_RET(op, lock)   \
-({ \
-   unsigned long __ret;\
-   \
-   if (TYPE_EQUAL((lock), raw_seqlock_t))  \
-   __ret = op##_raw((raw_seqlock_t *)(lock));  \
-   else if (TYPE_EQUAL((lock), seqlock_t)) \
-   __ret = op((seqlock_t *)(lock));\
-   else __ret = __bad_seqlock_type();  \
-   \
-   __ret;  \
-})
-
-#define PICK_SEQOP_CONST_RET(op, lock) \
-({