public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC,PATCH] RCUify single-thread case of clock_gettime()
@ 2005-10-31 17:44 Paul E. McKenney
  2005-10-31 18:08 ` Hugh Dickins
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Paul E. McKenney @ 2005-10-31 17:44 UTC (permalink / raw)
  To: mingo; +Cc: linux-kernel, tytso, sripathi, dipankar, oleg

Hello!

The attached patch uses RCU to avoid the need to acquire tasklist_lock
in the single-thread case of clock_gettime().  Still acquires tasklist_lock
when asking for the time of a (potentially multithreaded) process.

Experimental, has been touch-tested on x86 and POWER.  Requires RCU on
task_struct.  Further more focused testing in progress.

Thoughts?  (Why?  Some off-list users want to be able to monitor CPU
consumption of specific threads.  They need to do so quite frequently,
so acquiring tasklist_lock is inappropriate.)

							Thanx, Paul

diff -urpNa -X dontdiff linux-2.6.14-rc5-rt2/kernel/posix-cpu-timers.c linux-2.6.14-rc5-rt2-RCUgettime/kernel/posix-cpu-timers.c
--- linux-2.6.14-rc5-rt2/kernel/posix-cpu-timers.c	2005-10-22 14:45:56.000000000 -0700
+++ linux-2.6.14-rc5-rt2-RCUgettime/kernel/posix-cpu-timers.c	2005-10-22 15:44:27.000000000 -0700
@@ -302,7 +302,7 @@ int posix_cpu_clock_get(clockid_t which_
 		 * should be able to see it.
 		 */
 		struct task_struct *p;
-		read_lock(&tasklist_lock);
+		rcu_read_lock();
 		p = find_task_by_pid(pid);
 		if (p) {
 			if (CPUCLOCK_PERTHREAD(which_clock)) {
@@ -311,11 +311,13 @@ int posix_cpu_clock_get(clockid_t which_
 								 p, &rtn);
 				}
 			} else if (p->tgid == pid && p->signal) {
+				read_lock(&tasklist_lock);
 				error = cpu_clock_sample_group(which_clock,
 							       p, &rtn);
+				read_unlock(&tasklist_lock);
 			}
 		}
-		read_unlock(&tasklist_lock);
+		rcu_read_unlock();
 	}
 
 	if (error)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-10-31 21:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-31 17:44 [RFC,PATCH] RCUify single-thread case of clock_gettime() Paul E. McKenney
2005-10-31 18:08 ` Hugh Dickins
2005-10-31 19:54   ` Ingo Molnar
2005-10-31 20:07     ` Hugh Dickins
2005-10-31 21:50       ` Ingo Molnar
2005-10-31 19:37 ` Joe Seigh
2005-10-31 21:44 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox