mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bill Huey (hui) <billh@gnuppy.monkey.org>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <johnstul@us.ibm.com>,
	"Paul E. McKenney" <paulmck@us.ibm.com>,
	Dipankar Sarma <dipankar@in.ibm.com>,
	Arjan van de Ven <arjan@infradead.org>,
	"Bill Huey (hui)" <billh@gnuppy.monkey.org>
Subject: Re: [PATCH] move put_task_struct() reaping into a thread [Re: 2.6.18-rt1]
Date: Tue, 26 Sep 2006 23:34:15 -0700	[thread overview]
Message-ID: <20060927063415.GB16140@gnuppy.monkey.org> (raw)
In-Reply-To: <m11wpxrgnm.fsf@ebiederm.dsl.xmission.com>

On Wed, Sep 27, 2006 at 12:02:21AM -0600, Eric W. Biederman wrote:
> Bill Huey (hui) <billh@gnuppy.monkey.org> writes:
> > Because the conversion of memory allocation routines like kmalloc and kfree aren't
> > safely callable within a preempt_disable critical section since they were incompletely
> > converted in the -rt. It can run into the sleeping in atomic scenario which can result
> > in a deadlock since those routines use blocking locks internally in the implementation
> > now as a result of the spinlock_t conversion to blocking locks.
> 
> Interesting.  I think the easy solution would just be to assert that put_task_struct
> can sleep and to fix any callers that expect differently.  I haven't looked very
> closely but I don't recall anything that needs put_task_struct to be atomic.
> With a function that complex I certainly would not expect it to never sleep unless
> it had a big fat comment.

One of the main claims about the -rt patch is that the kernel is basically
conversion of the current locking semantics in the kernel. What you mentioned
above would deviate from that and and clutter non-preemptive kernel maintenance.
If you're suggesting a more general change to that function, then it wouldn't
violate that.

> Well I did find an instance where we call put_task_struct with a
> spinlock held.  Inside of lib/rwsem.c:rwsem_down_failed_common(). 
> 
> Still that may be the only user that cares.  I suspect with a little
> code rearrangement that case is fixable.  It's not like that code is a
> fast path or anything.  It should just be a matter of passing the 
> task struct outside of the spinlock before calling put_task_struct.

Yeah, that's what the small patch of mine does outside of doing an RCU
callback.

> > Right, blame it on the incomplete conversion of the kmalloc and friends. GFP_ATOMIC is
> > is kind of meaningless in the -rt tree and it might be a good thing to add something
> > like GFP_RT_ATOMIC for cases like this to be handled properly and restore that
> > particular semantic in a more meaningful way.
> 
> But this is a path where we are freeing data, so GFP_ATOMIC should not come
> into it.  I just read through the code and there are not allocations
> there.

Correct, I see it as a possibly bigger problem since memory allocators and
destructors aren't available readily in preempt_disable critical sections.
It's not the case in the regular kernel which could be a significant concern.

> > I'm not sure what mean here, but if you mean that you don't like the RCU API abuse then
> > I agree with you on that. However, Ingo disagrees and I'm not going to argue it with him.
> > Although, I'm not going stop you if you do. :)
> 
> What I was thinking is that rcu isn't terribly friendly to realtime
> activities because it postpones work and can wind up with a lot of
> work to do at some random time later which can be bad for latencies. 
> 
> So I was very surprised to see an rt patch making more things under
> rcu protection.  Especially as I have heard other developers worried
> about rt issues discussing removing the rcu functionality.

There are a couple of issues here.

(1) The RCU callback isn't used in this case to back other RCU read critical
sections. It's just used as a generic callback mechanism in this case. Some
consider it a hack.

(2) RCU isn't necessarily bad for -rt since Paul McKenney and folks are
working on making it preempt friendly. Any talk of removing the use RCU in -rt
is premature and probably unlikely because of this work. There are many options
here. RCU very useful for scalability so seeing it go away in -rt would be
generally a bad thing IMO.

The use of lock-free techinques is something that could eventually be more
widely used in -rt since it'll make kernel call paths potentially more
deterministic without worrying about hitting a contending mutex and that can
effect determinism. It's not expect to be the case where calls into the kernel
are going to be deterministic but to extend the basic idea of determinism into
certain critical kernel paths like a read() to a special device driver, etc...

Route table look up also comes to mind here that benefits from this case if
there's a need for real time facilities in networking.

Just some ideas here.

> My gut feel now that I understand the pieces is that this approach has
> all of the hallmarks of a hack, both the kmalloc/kfree thing and even
> more calling put_task_struct in an atomic context.  If the callers
> were fixed put_task_struct could safely sleep so kmalloc/kfree
> sleeping would not be a problem.

I can't say. The current logic just queues the request into a list and a
thread wakes to reap that task_struct. It's sufficient and the need to
convert put_task_struct so that it can block.

bill


  reply	other threads:[~2006-09-27  6:34 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20 14:19 2.6.18-rt1 Ingo Molnar
2006-09-20 16:50 ` 2.6.18-rt1 Gene Heskett
2006-09-20 16:58   ` 2.6.18-rt1 Ingo Molnar
2006-09-20 17:33     ` 2.6.18-rt1 Gene Heskett
2006-09-20 18:34     ` 2.6.18-rt1 Gene Heskett
2006-09-20 17:00   ` 2.6.18-rt1 Daniel Walker
2006-09-20 17:38     ` 2.6.18-rt1 Paul E. McKenney
2006-09-20 17:41       ` 2.6.18-rt1 Daniel Walker
2006-09-20 18:23         ` 2.6.18-rt1 Gene Heskett
2006-09-20 18:25         ` 2.6.18-rt1 Paul E. McKenney
2006-09-20 18:34           ` 2.6.18-rt1 Daniel Walker
2006-09-20 20:06             ` 2.6.18-rt1 Paul E. McKenney
2006-09-20 21:38               ` 2.6.18-rt1 Gene Heskett
2006-09-20 20:17             ` 2.6.18-rt1 Gene Heskett
2006-09-20 18:36           ` 2.6.18-rt1 Gene Heskett
2006-09-20 18:47             ` 2.6.18-rt1 Thomas Gleixner
2006-09-20 19:20               ` 2.6.18-rt1 Thomas Gleixner
2006-09-20 19:46             ` 2.6.18-rt1 Ingo Molnar
2006-09-20 20:19               ` 2.6.18-rt1 Daniel Walker
2006-09-20 20:14                 ` 2.6.18-rt1 Ingo Molnar
2006-09-20 20:31                   ` 2.6.18-rt1 Daniel Walker
2006-09-21 19:02                     ` 2.6.18-rt1 Ingo Molnar
2006-09-21 19:18                       ` 2.6.18-rt1 Daniel Walker
2006-09-22 14:42                       ` 2.6.18-rt1 Daniel Walker
2006-09-27  8:36                         ` 2.6.18-rt1 Ingo Molnar
2006-09-21  8:04               ` 2.6.18-rt1 Deepak Saxena
2006-09-21  8:04                 ` 2.6.18-rt1 Ingo Molnar
2006-09-21  8:24                   ` 2.6.18-rt1 Deepak Saxena
2006-09-22  2:19               ` 2.6.18-rt1 john cooper
2006-09-22  6:36                 ` 2.6.18-rt1 Lennert Buytenhek
2006-09-22 11:56                   ` 2.6.18-rt1 Ingo Molnar
2006-09-27 13:10                     ` 2.6.18-rt4 john cooper
2006-09-27 13:09                       ` 2.6.18-rt4 Ingo Molnar
2006-09-20 18:56 ` 2.6.18-rt1 K.R. Foley
2006-09-20 19:49   ` 2.6.18-rt1 Ingo Molnar
2006-09-20 20:33     ` 2.6.18-rt1 K.R. Foley
2006-09-20 20:41       ` 2.6.18-rt1 Thomas Gleixner
2006-09-20 20:50         ` 2.6.18-rt1 K.R. Foley
2006-09-21 19:16           ` 2.6.18-rt1 john stultz
2006-09-22  2:18             ` 2.6.18-rt1 K.R. Foley
2006-09-22 11:58             ` 2.6.18-rt1 Ingo Molnar
2006-09-28  0:42               ` 2.6.18-rt1 john stultz
2006-09-28 22:48                 ` 2.6.18-rt1 john stultz
2006-09-29  2:09                   ` 2.6.18-rt1 K.R. Foley
2006-09-29 12:24                   ` 2.6.18-rt1 Ingo Molnar
2006-09-29 12:40                   ` 2.6.18-rt1 Ingo Molnar
2006-09-20 19:58   ` 2.6.18-rt1 Thomas Gleixner
2006-09-20 20:34     ` 2.6.18-rt1 K.R. Foley
2006-09-20 19:38 ` 2.6.18-rt1 Mark Knecht
2006-09-20 20:27   ` 2.6.18-rt1 Mark Knecht
2006-09-22 14:14   ` 2.6.18-rt1 Lee Revell
2006-09-20 20:54 ` 2.6.18-rt1 Michal Piotrowski
2006-09-20 22:07 ` 2.6.18-rt1 Michal Piotrowski
2006-09-20 22:26 ` 2.6.18-rt1 Michal Piotrowski
2006-09-21  6:56 ` [PATCH] move put_task_struct() reaping into a thread [Re: 2.6.18-rt1] Bill Huey
2006-09-21  6:54   ` Ingo Molnar
2006-09-21  7:18     ` Bill Huey
2006-09-21  7:16       ` Ingo Molnar
2006-09-21  7:32         ` Bill Huey
2006-09-21  7:29           ` Ingo Molnar
2006-09-21  7:48             ` Bill Huey
2006-09-21  7:56               ` Ingo Molnar
2006-09-21  8:13                 ` Bill Huey
2006-09-21 12:23                   ` Esben Nielsen
2006-09-21 12:56                     ` Ingo Molnar
2006-09-21  7:27       ` Bill Huey
2006-09-21  7:22         ` Ingo Molnar
2006-09-21  7:35           ` Bill Huey
2006-09-21  7:31             ` Ingo Molnar
2006-09-21  7:52               ` Bill Huey
2006-09-27  2:55   ` Eric W. Biederman
2006-09-27  5:08     ` Bill Huey
2006-09-27  6:02       ` Eric W. Biederman
2006-09-27  6:34         ` Bill Huey [this message]
2006-09-27  7:29           ` Eric W. Biederman
2006-09-27  9:01             ` Ingo Molnar
2006-09-27 13:59               ` Eric W. Biederman
2006-09-27 14:06                 ` Ingo Molnar
2006-09-27 16:18                   ` Paul E. McKenney
2006-09-27  9:08             ` Ingo Molnar
2006-09-27  9:09             ` Bill Huey
2006-09-27  9:05               ` Ingo Molnar
2006-09-27 20:28         ` Esben Nielsen
2006-09-27  8:57       ` Ingo Molnar
2006-09-27  9:14         ` Bill Huey
2006-09-27  9:15           ` Ingo Molnar
2006-09-25  9:53 ` 2.6.18-rt1 Florian Schmidt
2006-09-26  7:57   ` 2.6.18-rt1 Florian Schmidt
2006-09-25 16:12 ` 2.6.18-rt1 Mike Kravetz
2006-09-27  8:34   ` 2.6.18-rt1 Ingo Molnar
2006-09-30 18:06 ` 2.6.18-rt1 Lee Revell
2006-09-30 18:18   ` 2.6.18-rt1 Dipankar Sarma
2006-09-30 18:25     ` 2.6.18-rt1 Lee Revell
2006-10-13 21:18     ` 2.6.18-rt1 Karsten Wiese
2006-10-13 21:20       ` 2.6.18-rt1 Lee Revell
2006-10-13 21:24       ` 2.6.18-rt1 Dipankar Sarma
2006-10-13 22:12         ` 2.6.18-rt1 Lee Revell
2006-10-13 22:16           ` 2.6.18-rt1 Dipankar Sarma
2006-10-17 14:46             ` 2.6.18-rt1 Lee Revell
2006-10-18  8:34               ` 2.6.18-rt1 Ingo Molnar
2006-10-18  7:12         ` 2.6.18-rt1 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=20060927063415.GB16140@gnuppy.monkey.org \
    --to=billh@gnuppy.monkey.org \
    --cc=arjan@infradead.org \
    --cc=dipankar@in.ibm.com \
    --cc=ebiederm@xmission.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@us.ibm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®