cvs commit: src/lib/libc/gmon mcount.c

Bruce Evans bde at zeta.org.au
Fri May 6 11:54:53 PDT 2005


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


More information about the cvs-src mailing list