Subject: Re: SA, libpthread and page faults
To: Christian Limpach <chris@pin.lu>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 08/18/2003 09:23:24
On Mon, 18 Aug 2003, Christian Limpach wrote:

> On Wed, 13 Aug 2003 14:30:25 -0400 Stephan Uphoff <ups@stups.com> wrote:
>
> > Right now the only idea I have is normal sleeping (no upcalls) on page
> > faults.
> >
> > Perhaps by stealing the PC trick from restartable atomic sequences we can
> > limit disabling upcalls to the thread being active in libpthread ?
> > ( Requires some ugly linking tricks to combine object files ? )
> >
> > Any ideas on how to solve these problems would be appreciated.
>
> How about checking if the stack that the lwp which page faulted ran on is
> an upcall stack?  I have implemented this and it seems to work.  At least it
> manages to avoid the pagefault/upcall horde at program startup when
> libpthread.so isn't in memory yet and thus avoid running out of stacks (see
> also kern/22490).
>
> It goes like this:
> - pagefault trap handler sets L_SA_PAGEFAULT.
> - sa_switch checks for case 1 if L_SA_PAGEFAULT is set and if the lwp's
> user stack is an upcall stack and doesn't make a SA_UPCALL_BLOCKED upcall
> in this case.

I think the problem with this is that there are times when the page fault
happens in code that is not on an upcall stak yet has locks held such that
an upcall will block.

Take care,

Bill