From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: Fw: [patch] posix timers: RCU optimization for clock_gettime()
Date: Thu, 1 Feb 2007 16:35:50 -0800 [thread overview]
Message-ID: <20070202003550.GA17012@linux.vnet.ibm.com> (raw)
The attached patch uses RCU to avoid the need to acquire tasklist_lock
in the single-threaded case of clock_gettime(). It still acquires
tasklist_lock when for a (potentially multithreaded) process. This change
allows realtime applications to frequently monitor CPU consumption of
individual tasks, as requested (and now deployed) by some off-list users.
This has been in Ingo Molnar's -rt patchset since late 2005 with no
problems reported, and tests successfully on 2.6.20-rc6, so I believe
that it is long-since ready for mainline adoption.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/posix-cpu-timers.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Index: linux/kernel/posix-cpu-timers.c
===================================================================
--- linux.orig/kernel/posix-cpu-timers.c
+++ linux/kernel/posix-cpu-timers.c
@@ -304,7 +304,7 @@ int posix_cpu_clock_get(const clockid_t
* 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)) {
@@ -313,11 +313,13 @@ int posix_cpu_clock_get(const clockid_t
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)
----- End forwarded message -----
reply other threads:[~2007-02-02 0:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070202003550.GA17012@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox