Skip to contentSkip to conversation

POSIX timers RCU optimization fix for clock_gettime

PATCH New Paul E. McKenney 1 participant 1 message Feb 4, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 POSIX timers RCU optimization fix for clock_gettime

Fixes an exit()/posix_cpu_clock_get() race spotted by Oleg Nesterov. Solution is to move the p->signal check under the tasklist_lock.

---

 posix-cpu-timers.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/posix-cpu-timers.c +6 -3
diff -urpNa -X dontdiff linux-2.6.20-rc6-clockrcu/kernel/posix-cpu-timers.c linux-2.6.20-rc6-clockrcu-fixes/kernel/posix-cpu-timers.c
@@ -312,10 +312,13 @@ int posix_cpu_clock_get(const clockid_t 
 					error = cpu_clock_sample(which_clock,
 								 p, &rtn);
 				}
-			} else if (p->tgid == pid && p->signal) {
+			} else {
 				read_lock(&tasklist_lock);
-				error = cpu_clock_sample_group(which_clock,
-							       p, &rtn);
+				if (p->tgid == pid && p->signal) {
+					error =
+					    cpu_clock_sample_group(which_clock,
+							           p, &rtn);
+				}
 				read_unlock(&tasklist_lock);
 			}
 		}