[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] mprotect question

From: Aurelien Chanudet
Subject: Re: [Gcl-devel] mprotect question
Date: Thu, 4 Sep 2003 16:54:37 +0200 (CEST)

> OK, last question first, PROT_EXEC is needed to
> execute compiled object files loaded into GCL's
> data core.  As you are using dlopen, you don't
> strictly need this, but GCL currently uses
> PROT_EXEC everywhere for simplicity.

OK, that's what I had thought.

> The new page procedure goes like this, at least
> on linux:
> sbrk
> if (sgc_enabled)
> My guess is that the default permissions returned
> by sbrk on your system are different from those on
> linux.

What you should know is that I'm not using the system
sbrk. The reason for this is that darwin (Mac OS X
core) has a fairly sophisticated memory management
scheme, and that sbrk does not fit well into this
scheme. It is just provided for compatibility. To work
around this, I've implemented my own sbrk. Upon
initialisation, a big vm area is allocated. Then, all
memory allocation goes through gcl's own
malloc/realloc/free which in turn ends up calling
alloc_page (this way, the Mac OS X behavior is as
close as possible to the Linux behavior). Therefore, I
have fine grain control over the initial protection of
the pages. 

> If sgc_enabled is false,
> pages will just go through the sbrk, and then will
> be mprotected
> PROT_READ when sgc_start is called (as they would be
> old pages).  Then
> a write happens to the page, a SEGV is raised, and
> the attempted
> promotion mprotect is called.  I don't know why sbrk
> -> PROT_READ ->
> PROT_READ_WRITE_EXEC would fail if sbrk ->
> succeeds, but if this is the case for some reason,
> you could try
> adding an explicit mprotect READ_WRITE_EXEC after
> the sbrk and before
> the if(sgc_enabled) in alloc_page.

Ok, thanks for this. I've got several ideas as to what
may be going wrong. Let me try them out. Be that as it
may, my understanding is that SGC is an optional
figure, that may or may not be enabled. However, I
fail to understand how the pagefault handling
mechanism can deliver performance improvement for
garbage collecting. Out of curiosity, how does this
work ?

> Please keep me posted, and thanks as always for your
> work on this!

My pleasure. What version should I be working on
(2.5.4, 2.6.0, ...) ? I've tried to add some files to
the repository, but those files don't appear at the
right place, because they are probably incorrectly
tagged. What cvs command should I use to add files ?


Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran├žais !
Yahoo! Mail : http://fr.mail.yahoo.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]