mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: "Richard F. Rebel" <rrebel@whenu.com>
Cc: Mauricio Lin <mauriciolin@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: /proc/*/statm, exactly what does "shared" mean?
Date: Sat, 12 Feb 2005 15:42:15 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0502121509170.19562@goblin.wat.veritas.com> (raw)
In-Reply-To: <1108219160.12693.184.camel@blue.obulous.org>

On Sat, 12 Feb 2005, Richard F. Rebel wrote:
> 
> That said, many mod_perl users are *VERY* interested in being able to
> detect and observe how "shared" our forked children are.  Shared meaning
> private pages shared with children (copy on write).  Is it even possible
> to do this in 2.6 kernels?  If so, any pointers would be very helpful.

Not in any of the vanilla kernels.

Mauricio has a /proc/<pid>/smaps patch, in which he returns to looking
at every pte slot of every vma of the process as /proc/<pid>/statm did
in 2.4.  I suggest you ask him offline for his latest version (the last
I saw did not include support for 2.6.11's pud level; and looped in an
inefficient way, repeatedly locating, mapping and unmapping the page
table for each pte slot - needs refactoring into pgd_range, pud_range,
pmd_range, pte_range levels like 2.4's statm).

It wouldn't be hard to take his framework (before or after improvements),
or the 2.4 proc_pid_statm framework, and modify that to give you the
information you're looking for.  But I doubt that the resulting patch
would be accepted into a vanilla kernel - there's no end to the kinds
of numbers that different people might want to see.

I wonder how important swapping is in your case.  If it's an
exceptional case that you can ignore, then a "private shared"
entry would be identified by code something like:

	if (pte_present(pte)) {
		pfn = pte_pfn(pte);
		if (pfn_valid(pfn)) {
			page = pfn_to_page(pfn);
			if (PageAnon(page) && page_mapcount(page) > 1)
				private_shared++;
		}
	}

But if swap use is significant, then it gets rather more complicated:
a present page, even when its mapcount is 1, might still be shared with
other processes, from which which the pte has been unmapped; and where
the pte is not present, there may be a swap entry shared with others.
It can be worked out, but awkward and more than a few lines of code.

Hugh

  reply	other threads:[~2005-02-12 15:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11 22:32 Richard F. Rebel
2005-02-12 13:06 ` Hugh Dickins
2005-02-12 14:39   ` Richard F. Rebel
2005-02-12 15:42     ` Hugh Dickins [this message]
2005-02-16 10:41       ` Mauricio Lin
2005-02-16 12:00         ` Hugh Dickins
2005-02-16 15:02           ` Mauricio Lin
2005-02-16 15:17             ` Richard F. Rebel
2005-02-16 16:10               ` Hugh Dickins
2005-02-17 16:33                 ` Richard F. Rebel
2005-02-16 15:58             ` Hugh Dickins
2005-02-16 14:52     ` Benjamin LaHaise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0502121509170.19562@goblin.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mauriciolin@gmail.com \
    --cc=rrebel@whenu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®