public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dean Nelson <dcn@sgi.com>
To: Chris Wright <chrisw@osdl.org>
Cc: mingo@elte.hu, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch] export sched_setscheduler() for kernel module use
Date: Thu, 9 Dec 2004 08:36:32 -0600	[thread overview]
Message-ID: <20041209143632.GA6904@sgi.com> (raw)
In-Reply-To: <20041115132749.N2357@build.pdx.osdl.net>

On Mon, Nov 15, 2004 at 01:27:49PM -0800, Chris Wright wrote:
> * Dean Nelson (dcn@sgi.com) wrote:
> > On Mon, Nov 15, 2004 at 10:58:01AM -0800, Chris Wright wrote:
> > > * Dean Nelson (dcn@sgi.com) wrote:
> > > > +int do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
> > > 
> > > this should be static.
> > 
> > You're right. I made another change in that one now passes the task_struct
> > pointer to sched_setscheduler() instead of the pid. This requires that
> > the caller of sched_setscheduler() hold the tasklist_lock. The new patch
> > for people's feedback follows.
> 
> This now means callers of sched_setscheduler hold tasklist_lock, also
> with irq off.  I think it's safer to let the core function do that.
> It's a touchy area that's ripe for deadlock.

After some further investigation, I think I was mistaken in saying that
the caller of sched_setscheduler() must hold the tasklist_lock.

If you look at the example of sys_setpriority() and sys_nice(), both
of which call set_user_nice(), the first one does so via set_one_prio()
while holding the tasklist_lock, the second one does so while not
holding the tasklist_lock. The difference seems to be whether the caller
was operating against a task_struct located by way of pid or uid (like
calling find_task_by_pid()), which is the case for sys_setpriority(),
whereas sys_nice() operates against the current task_struct.

Now my proposed sched_setscheduler() is very similar to set_user_nice().
And sys_sched_setscheduler()/do_sched_setscheduler() is very similar to
sys_setpriority()/set_one_prio(). And the kernel module (XPC) that I'm
attempting to get accepted by the community would be analagous to
sys_nice() in that its call to sched_setscheduler() would be against
the current task.

So if there is a problem with my proposed patch in regards to the
tasklist_lock, then it would seem to me that there is a problem
with the exiting sys_setpriority(), set_one_prio(), sys_nice(),
set_user_nice() code.

Or am I missing something?

Thanks,
Dean


  reply	other threads:[~2004-12-09 14:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-15 18:35 [Patch] export sched_setscheduler() for kernel module use Dean Nelson
2004-11-15 18:58 ` Chris Wright
2004-11-15 20:33   ` Dean Nelson
2004-11-15 20:41     ` Jan Engelhardt
2004-11-15 21:03       ` Dean Nelson
2004-11-15 21:27     ` Chris Wright
2004-12-09 14:36       ` Dean Nelson [this message]
2004-11-16 10:48     ` Ingo Molnar
2004-11-16 18:34       ` pthread_cond_signal not waking thread Andrew A.
2004-11-16 20:31         ` Nikita Danilov
2004-11-16 20:45           ` Andrew A.
2004-11-16 21:00             ` Nikita Danilov
2004-11-16 20:18       ` [Patch] export sched_setscheduler() for kernel module use Dean Nelson
2004-11-16 22:36         ` Ingo Molnar
2004-11-16 22:01           ` Chris Friesen
2004-11-16 23:05             ` Ingo Molnar
2004-12-08 20:34           ` Dean Nelson
2004-12-09 12:46             ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2004-12-13 20:14 [PATCH] " Dean Nelson
2004-12-15  9:49 ` Ingo Molnar

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=20041209143632.GA6904@sgi.com \
    --to=dcn@sgi.com \
    --cc=akpm@osdl.org \
    --cc=chrisw@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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