All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] do_sched_setscheduler: don't take tasklist_lock
Date: Sun, 13 Aug 2006 21:03:40 +0400	[thread overview]
Message-ID: <20060813170340.GA1913@oleg> (raw)

We don't need to take tasklist_lock or disable irqs for
find_task_by_pid() + get_task_struct(). Use RCU locks
instead.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.18-rc3/kernel/sched.c~1_dss	2006-07-16 01:53:08.000000000 +0400
+++ 2.6.18-rc3/kernel/sched.c	2006-08-13 20:19:02.000000000 +0400
@@ -4156,14 +4156,15 @@ do_sched_setscheduler(pid_t pid, int pol
 		return -EINVAL;
 	if (copy_from_user(&lparam, param, sizeof(struct sched_param)))
 		return -EFAULT;
-	read_lock_irq(&tasklist_lock);
+
+	rcu_read_lock();
 	p = find_process_by_pid(pid);
-	if (!p) {
-		read_unlock_irq(&tasklist_lock);
+	if (p)
+		get_task_struct(p);
+	rcu_read_unlock();
+	if (!p)
 		return -ESRCH;
-	}
-	get_task_struct(p);
-	read_unlock_irq(&tasklist_lock);
+
 	retval = sched_setscheduler(p, policy, &lparam);
 	put_task_struct(p);
 


             reply	other threads:[~2006-08-13 12:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-13 17:03 Oleg Nesterov [this message]
2006-08-13 17:21 ` [PATCH] do_sched_setscheduler: don't take tasklist_lock Oleg Nesterov

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=20060813170340.GA1913@oleg \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.