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

Re: Resident memory set size



Thanks for the detailed response which makes sense.

On 12/05/2025 18:47, Samuel Thibault wrote:
Ok. I'm wondering if it's not just a side effect that only _looks_
odd.  It is expected that the balancing code unmaps the page from the
process.  Possibly gnumach doesn't bother with remapping it, because it
does not really *have* to, it can as well just defer that until the page
is really needed again. And thus the RSS of the process stays lower in
the meanwhile. Reading the pages again from userland would make gnumach
have to remap them. Normally it will be able to find them in the memory
object.

*) The page data is then copied from old to new. There is a call to
pmap_clear_modify for the new page if the old page wasn't 'dirty'
Yes, because have have just written to the new page, so of course the
hardware dirty flag is set, but we don't want to infer from that that
the page is dirty if it wasn't already, so we clear the hardware flag.

but what about the case where the old page was dirty?
In that case the memcpy(&dest->vm_page_header, &src->vm_page_header)
will have copied the dirtiness information. The hardware page flag will
also have a modified bit from the memcpy, but that's fine since the page
was already marked dirty.
Some of these things I had thought of as possibilities and some I hadn't although I should have (for example that the vm_page_copy would set the hardware dirty flag). It is seems misleading to report the RSS as being those just mapped when the memory is really still in use (although not mapped) to preserve the dirty information but I suppose it doesn't affect much.

     Your test case is valid, it'll be useful to investigate further.

I'm spending a lot of time trying to unravel the workings of the memory
management.
Just making sure: have you studied memory management from some book
already? Code comments don't usually repeat what is written there.

I am familiar with aspects of memory management from experience as a developer. That was however some years ago, and in any case, familiarity with the concepts does not immediately translate to the specifics of an implementation.

All the best,

Mike.


Reply to: