Skip to contentSkip to conversation

RT: update rcurefs for RT

PATCH Applied Daniel Walker 3 participants 7 messages Sep 27, 2005 – Sep 30, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RT: update rcurefs for RT

Make rcurefs compatible with RT w/o cmpxchg() .

kernel/rcupdate.c +21 -12
Index: linux-2.6.13/kernel/rcupdate.c
===================================================================
@@ -96,6 +96,25 @@ static void rcu_torture_init(void);
 static inline void rcu_torture_init(void) { }
 #endif
 
+#ifndef __HAVE_ARCH_CMPXCHG
+/*
+ * We use an array of spinlocks for the rcurefs -- similar to ones in sparc
+ * 32 bit atomic_t implementations, and a hash function similar to that
+ * for our refcounting needs.
+ * Can't help multiprocessors which donot have cmpxchg :(
+ */
+spinlock_t __rcuref_hash[RCUREF_HASH_SIZE];
+
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);
+}
+#else
+#define init_rcurefs()	do { } while (0)
+#endif
+
 #ifndef CONFIG_PREEMPT_RCU
 
 /* Definition for rcupdate control block. */
@@ -123,18 +142,6 @@ DEFINE_PER_CPU(struct rcu_data, rcu_bh_d
 static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL};
 static int maxbatch = 10;
 
-#ifndef __HAVE_ARCH_CMPXCHG
-/*
- * We use an array of spinlocks for the rcurefs -- similar to ones in sparc
- * 32 bit atomic_t implementations, and a hash function similar to that
- * for our refcounting needs.
- * Can't help multiprocessors which donot have cmpxchg :(
- */
-
-spinlock_t __rcuref_hash[RCUREF_HASH_SIZE] = {
-	[0 ... (RCUREF_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
-};
-#endif
 
 /**
  * call_rcu - Queue an RCU callback for invocation after a grace period.
@@ -487,6 +494,7 @@ static struct notifier_block __devinitda
  */
 void __init rcu_init(void)
 {
+	init_rcurefs();
 	rcu_torture_init();
 	rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
 			(void *)(long)smp_processor_id());
@@ -824,6 +832,7 @@ rcu_pending(int cpu)
 
 void __init rcu_init(void)
 {
+	init_rcurefs();
 	rcu_torture_init();
 /*&&&&*/printk("WARNING: experimental RCU implementation.\n");
 	spin_lock_init(&rcu_data.lock);
Applied
#1 lore raw
Quoted 1 line · Daniel Walker

Make rcurefs compatible with RT w/o cmpxchg() .

thanks, applied.

Ingo

#2 lore raw
In reply to Daniel Walker

kernel/rcupdate.c static void rcu_torture_init(void); · line 112

Quoted 7 lines · Daniel Walker

Make rcurefs compatible with RT w/o cmpxchg() .

kernel/rcupdate.c +5 -0
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);

what the heck is this doing??? Patch reverted.

Ingo

#3 lore raw
Quoted 3 lines · Ingo Molnar

Review

Quoted 1 line
(quoted diff) +1 -0
+		SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);

what the heck is this doing??? Patch reverted.

How is this ?

kernel/rcupdate.c +21 -12
Index: linux-2.6.13/kernel/rcupdate.c
===================================================================
@@ -96,6 +96,25 @@ static void rcu_torture_init(void);
 static inline void rcu_torture_init(void) { }
 #endif
 
+#ifndef __HAVE_ARCH_CMPXCHG
+/*
+ * We use an array of spinlocks for the rcurefs -- similar to ones in sparc
+ * 32 bit atomic_t implementations, and a hash function similar to that
+ * for our refcounting needs.
+ * Can't help multiprocessors which donot have cmpxchg :(
+ */
+spinlock_t __rcuref_hash[RCUREF_HASH_SIZE];
+
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		__rcuref_hash[i] = SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);
+}
+#else
+#define init_rcurefs()	do { } while (0)
+#endif
+
 #ifndef CONFIG_PREEMPT_RCU
 
 /* Definition for rcupdate control block. */
@@ -123,18 +142,6 @@ DEFINE_PER_CPU(struct rcu_data, rcu_bh_d
 static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL};
 static int maxbatch = 10;
 
-#ifndef __HAVE_ARCH_CMPXCHG
-/*
- * We use an array of spinlocks for the rcurefs -- similar to ones in sparc
- * 32 bit atomic_t implementations, and a hash function similar to that
- * for our refcounting needs.
- * Can't help multiprocessors which donot have cmpxchg :(
- */
-
-spinlock_t __rcuref_hash[RCUREF_HASH_SIZE] = {
-	[0 ... (RCUREF_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
-};
-#endif
 
 /**
  * call_rcu - Queue an RCU callback for invocation after a grace period.
@@ -487,6 +494,7 @@ static struct notifier_block __devinitda
  */
 void __init rcu_init(void)
 {
+	init_rcurefs();
 	rcu_torture_init();
 	rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
 			(void *)(long)smp_processor_id());
@@ -824,6 +832,7 @@ rcu_pending(int cpu)
 
 void __init rcu_init(void)
 {
+	init_rcurefs();
 	rcu_torture_init();
 /*&&&&*/printk("WARNING: experimental RCU implementation.\n");
 	spin_lock_init(&rcu_data.lock);
#4 lore raw

kernel/rcupdate.c static void rcu_torture_init(void); · line 112

Quoted 5 lines · Daniel Walker
kernel/rcupdate.c +5 -0
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		__rcuref_hash[i] = SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);

Maybe a simple

	spin_lock_init(&__rcuref_hash[i]);

would work all over tha place ?

tglx

#5 lore raw
Quoted 9 lines · Thomas Gleixner

kernel/rcupdate.c static void rcu_torture_init(void); · line 112

Quoted 5 lines · Daniel Walker
kernel/rcupdate.c +5 -0
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		__rcuref_hash[i] = SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);

Maybe a simple

Quoted 3 lines
	spin_lock_init(&__rcuref_hash[i]);

would work all over the place ?

yep.

Ingo

#6 lore raw
Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Thomas Gleixner

kernel/rcupdate.c static void rcu_torture_init(void); · line 112

Quoted 5 lines · Daniel Walker
kernel/rcupdate.c +5 -0
+static inline void init_rcurefs(void)
+{
+	int i;
+	for (i=0; i < RCUREF_HASH_SIZE; i++) 
+		__rcuref_hash[i] = SPIN_LOCK_UNLOCKED(__rcuref_hash[i]);

Maybe a simple

Quoted 5 lines
Quoted 3 lines
	spin_lock_init(&__rcuref_hash[i]);

would work all over the place ?

yep.

The patch isn't needed if you accept Nick's cmpxchg() patches ..

Daniel