cvs commit: src/sys/kern kern_fork.c

Julian Elischer julian at elischer.org
Wed Oct 24 22:20:53 PDT 2007


Alfred Perlstein wrote:
> * David Xu <davidxu at FreeBSD.org> [071024 19:32] wrote:
>> Alfred Perlstein wrote:
>>> * David Xu <davidxu at FreeBSD.org> [071024 18:34] wrote:
>>>
>>>> Julian Elischer wrote:
>>>>
>>>>> julian      2007-10-23 17:54:16 UTC
>>>>>
>>>>> FreeBSD src repository
>>>>>
>>>>> Modified files:
>>>>>  sys/kern             kern_fork.c 
>>>>> Log:
>>>>> Take out the single-threading code in fork.
>>>>> After discussions with jeff, alc, (various Ironport people), david Xu,
>>>>> and mostly Alfred (who found the problem) it has been demonstrated that 
>>>>> this
>>>>> is not needed for our implementations of threads and represents a real
>>>>> (as in we've seen it happen a lot) deadlock danger.
>>>>> ...
>>>> I think if process is forking a thread, that says flag RFPROC is not
>>>> set and flags RFCFDG or RFCFDG is set, you still need to call
>>>> thread_single(SINGLE_BOUNDARY), otherwise, for a threaded process,
>>>> the memory pointed by p_fd is freed while other threads are using it,
>>>> it will cause kernel to panic.
>>>
>>> This is unlikely to be fixed by SINGLE_BOUNDARY and will likely require
>>> refcounting to fix.  SINGLE_BOUNDARY will not fix the locations where
>>> this happens:
>>>
>>>        p = td->td_proc;
>>>        fdp = p->p_fd;
>>>        do something that blocks...
>>>        re-use fdp.
>>>
>> thread_suspend_check() with SINGLE_BOUNDARY is used is only called
>> in userret() where I don't think any code is still using the p_fd.
> 
> This is not an acceptable solution as it will deadlock unless all
> threads exit the kernel.
> 
> filedescs can be refcounted per thread I think.

you are both right I think..
David about the theoretical SINGLE_BOUNDARY idea, and Alfred about 
how it's implememted right now.


At the 'boundary' single threading should be safe, if things are at the boundary,
but there is no guarantee that it will get there in finite time.
I'm not convinced from reading the code that the BOUNDARY version of thread_single is implemented
correctly at this time as I think it may have suffered from bit-rot over the years.

> 



More information about the cvs-src mailing list