cvs commit: src/lib/libc/gmon mcount.c
David Xu
davidxu at freebsd.org
Fri May 6 17:50:22 PDT 2005
Bruce Evans wrote:
> On Fri, 6 May 2005, David Xu wrote:
>
>> davidxu 2005-05-06 07:37:01 UTC
>>
>> FreeBSD src repository
>>
>> Modified files:
>> lib/libc/gmon mcount.c
>> Log:
>> Fix race by using atomic operation, with this change, both libpthread
>> and libthr now can run profiling on SMP.
>>
>> Revision Changes Path
>> 1.21 +5 -3 src/lib/libc/gmon/mcount.c
>
>
> Doesn't userland need to wait for mcount() to become unbusy, like the
> kernel
> does? Just returning gives broken profiling. mcount() takes a long
> time,
> so there is a good chance of a thread being preempted while in mcount().
> Then I think profiling is effectively turned off until the thread in
> mcount() is rescheduled and leaves mcount().
>
> I don't know exactly how to avoid deadlock in userland. The kernel
> just disables interrupts. Userland would have to stop rescheduling,
> and do this without calling mcount() or dding much overhead. Note
> that the kernel must disable interrupts and not just use
> critical_enter(),
> since if it used the latter then low level interrupt handling would
> be complicated and broken by not being able to call mcount().
>
> Bruce
>
>
First, this is a bandaid to avoid deadlock, the deadlock is easy
to be reproduced.
Also, userland is different with kernel on profiling. if I understand
it correctly, I can not call other functions in mcount(), otherwise,
the cputime of those functions will be at top of gprof result, for
system scope thread, we can not disable rescheduling, only kernel
can do this. Also, signal handler will cause mcount to be reentered
with same thread, so we have to disable signal, but you know I can
not call other functions to disable signal(I don't know how to
handle this for M:N threads). so I don't know how to fix all these
problems.
David Xu
More information about the cvs-src
mailing list