Date: Sat, 7 May 2005 04:54:51 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: David Xu <davidxu@FreeBSD.org> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libc/gmon mcount.c Message-ID: <20050507043824.P12302@delplex.bde.org> In-Reply-To: <200505060737.j467b2R4041476@repoman.freebsd.org> References: <200505060737.j467b2R4041476@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050507043824.P12302>