linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: how text page of executable are shared ?
@ 2000-03-29  7:46 pnilesh
  2000-03-29 13:49 ` Stephen C. Tweedie
  0 siblings, 1 reply; 10+ messages in thread
From: pnilesh @ 2000-03-29  7:46 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-mm


Hi,

No, the page count will be three at least.  The presence of the page
in the page cache counts as one, and both of the page-table mappings of
the page each count as a further reference.

So when no process is pointing to a page in page cache the count will be
one.
But what is the difference if we have this to zero any way it is not being
refernced by any process.
Or can we have a page cache entry with page count as zero ?

Also all the pages which are present in the memory for any process will
also be part of the page hash queue and if they belong to a file then they
will also be on the inode queue.
Am I right.




Yes.  swap_out() is responsible for unlinking pages from process page
tables.  In the case you describe, the page will still have outstanding
references, from the other process and from the page cache.  Only when
the page cache cleanup function (shrink_mmap) gets called, after all of
the ptes to the page have been cleared, will the page be freed.

If you think about it, this is natural: when a process pages in a binary
and then exits, we really want the pages still to remain in memory so
that if you immediately rerun the program, we don't have to go back to
disk for the pages.  The process exiting acts a bit like a complete
swap_out, freeing up the pte reference to the page, but the page still
remains in the page cache until the memory is needed for something else.

> Q    When a page of a file is in page hash queue, does this page have
page
> table entry in any process ?

It may have, but it doesn't have to.

> Q     Can this be discarded right away , if the need arises?

Not without first doing a swap_out() on all the references to the page.
The Linux VM does its swapout based on virtual, not physical, page
scanning (although shrink_mmap() is physical).

--Stephen



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* how text page of executable are shared ?
@ 2000-03-28  3:51 pnilesh
  2000-03-28 13:22 ` Stephen C. Tweedie
  0 siblings, 1 reply; 10+ messages in thread
From: pnilesh @ 2000-03-28  3:51 UTC (permalink / raw)
  To: linux-mm

     When a executable file runs there is only one copy of the text part in
the memory. But I have some doubts as I am not able to figure how exactly
this is done.

Suppose a text page of an executable is mapped in the address space of 2
processes. The page count will be one.
The page table entries of both the process will have entry for this page.
But when the page is discarded only the page entry of only one process get
cleared , this is what I have understood from the swap_out () function .
But the page table entry of the other process is still pointing to the page
which has been discarded.


Can any body please clear my doubt.


Q    When a page of a file is in page hash queue, does this page have page
table entry in any process ?
Q     Can this be discarded right away , if the need arises?


Nilesh Patel



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-03-29 13:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-29  7:46 how text page of executable are shared ? pnilesh
2000-03-29 13:49 ` Stephen C. Tweedie
  -- strict thread matches above, loose matches on Subject: below --
2000-03-28  3:51 pnilesh
2000-03-28 13:22 ` Stephen C. Tweedie
2000-03-28 15:58   ` Mark Hahn
2000-03-28 18:10     ` Andrea Arcangeli
2000-03-29  1:01     ` Stephen C. Tweedie
2000-03-29  1:59       ` Kanoj Sarcar
2000-03-29  5:21       ` Andrew Morton
2000-03-29 13:45         ` Stephen C. Tweedie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox