Re: [PATCH] RT: Checks for cmpxchg in get_task_struct_rcu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Checks for cmpxchg in get_task_struct_rcu() . No race version.

Signed-Off-By: Daniel Walker <[email protected]>

Index: linux-2.6.13/include/linux/sched.h
===================================================================
--- linux-2.6.13.orig/include/linux/sched.h
+++ linux-2.6.13/include/linux/sched.h
@@ -1026,13 +1026,24 @@ static inline int get_task_struct_rcu(st
 {
 	int oldusage;
 
+#ifdef __HAVE_ARCH_CMPXCHG
 	do {
 		oldusage = atomic_read(&t->usage);
 		if (oldusage == 0) {
 			return 0;
 		}
 	} while (cmpxchg(&t->usage.counter,
-		 oldusage, oldusage + 1) != oldusage);
+				oldusage, oldusage + 1) != oldusage);
+#else
+	raw_local_irq_disable();
+	oldusage = atomic_read(&t->usage);
+	if (oldusage == 0) {
+		raw_local_irq_enable();
+		return 0;
+	}
+	atomic_inc(&t->usage);
+	raw_local_irq_enable();
+#endif
 	return 1;
 }
 


-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux