Re: [PATCH] move put_task_struct() reaping into a thread [Re: 2.6.18-rt1]

Esben Nielsen
2006-09-21T12:23:28Z

On Thu, 21 Sep 2006, Bill Huey wrote:

> On Thu, Sep 21, 2006 at 09:56:33AM +0200, Ingo Molnar wrote:
>> * Bill Huey <billh@gnuppy.monkey.org> wrote:
>>
>>> [...] If the upstream kernel used RCU function in a task allocation or
>>> task struct reading in the first place then call_rcu() would be a
>>> clear choice. However, I didn't see it used in that way (I could be
>>> wrong) [...]
>>
>> it was RCU-ified briefly but then it was further improved to direct
>> freeing, because upstream _can_ free it directly.
>
> Unfortunately, this is a problem with -rt patch and the lock ordering
> in this system when you have to call a memory allocator within an atomic
> critical section. I fully accept this as part of what goes into making a
> kernel preemptive and I'm ok with it. Not many folks know about the
> special case locking rules in the -rt kernel so this might be new to
> various folks.
>
> If you're looking for validation of this technique from me and an ego
> stroking, then you have it from me. :)
>
> Fortunately, it's in a non-critical place so this should *not* be too
> much of a problem, but I've already encountered oddies trying to
> allocate a pool of entities for populating a free list under an atomic
> critical section of some sort for some code I've been writing. This is
> a significant problem with kernel coding in -rt, but I can't say what
> the general solution is other than making the memory allocators
> non-preemptible by reverting the locks back to raw spinlocks, etc...
> using lock-break, who knows. I'm ok with the current scenario, but this
> could eventually be a larger problem.
>

The whole point is to defer those frees to a task. In -rt call_rcu() is
abused to do that in the case of put_task_struct(). But it is abuse since
call_rcu() is much more resourcefull than simply defering to a task.

Paul's idea behind de-RCU'ing put_task_struct() is mostly performance and
partly readability because the extra RCU protection isn't needed.

So the answer is:
Make a general softirq to which free's can be defered from atomic regions,
don't abuse call_rcu().

Esben

> bill
>