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