linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Andrea Arcangeli <andrea@suse.de>, Ben LaHaise <bcrl@redhat.com>,
	Marcelo Tosatti <marcelo@conectiva.com.br>,
	Rik van Riel <riel@conectiva.com.br>,
	linux-mm@kvack.org
Subject: Re: SWAP_MAP_MAX: How?
Date: Fri, 24 Aug 2001 13:42:59 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.21.0108241323280.1044-100000@localhost.localdomain> (raw)
In-Reply-To: <20010824121951.A4389@redhat.com>

On Fri, 24 Aug 2001, Stephen C. Tweedie wrote:
> On Fri, Aug 24, 2001 at 12:16:12PM +0100, Hugh Dickins wrote:
> > The SWAP_MAP_MAX case imposes a severe constraint on how swapoff
> > may be implemented correctly.  I am still struggling to understand
> > how a swap count might reach SWAP_MAP_MAX 0x7fff on 2.4.  Please,
> > can someone enlighten me?
> 
> The swap count is incremented for every separate mm which references a
> page.  That basically means that demand-zero (heap and anon mmap)
> pages which get created by a parent process and then shared by a
> forked child process will get the swap count bumped on that page
> whenever it gets swapped.  The raised count only survives as long as
> neither parent nor child modifies the page --- as soon as
> copy-on-write occurs, the process which modified the page gets a new
> copy and the reference count on the original page gets decremented.
> 
> Of course, any one process can fork as many times as it likes, leading
> to multiply-raised swap counts.

Many thanks for the reply.  That much I understand, but with PID_MAX
0x8000 (and CLONE_PID disallowed on user processes), I don't see how
any one swap entry could reach a count of 0x7fff - each fork raises
the count, but each exit lowers it.

I can imagine approaching 0x7fff with an anonymous page somehow mapped
into every user process, and temporary incrementations, e.g. from
valid_swaphandles(), perhaps taking it over the edge; but if that's
what it's about, well, it's easier to avoid such cases than to handle
SWAP_MAP_MAX in swapoff (the temporary incrementations are all about
trying to avoid a worrying message which simply should not be shown).

Doesn't it need an anonymous page mapped multiple (e.g. 256) times
into multiple (e.g. 256) mms to reach the limit?  And there's an obvious
way that can happen, by multiply attaching a piece of IPC Shared Memory,
and multiply forking.  But in that case it's the shared memory object
which gets the large number of references, and the swap counts stay 1.

So: I still don't get it.
Hugh

--
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-mm.org/

  reply	other threads:[~2001-08-24 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-24 11:16 Hugh Dickins
2001-08-24 11:19 ` Stephen C. Tweedie
2001-08-24 12:42   ` Hugh Dickins [this message]
2001-08-24 13:07     ` Stephen C. Tweedie
2001-08-25 10:35       ` Hugh Dickins

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.21.0108241323280.1044-100000@localhost.localdomain \
    --to=hugh@veritas.com \
    --cc=andrea@suse.de \
    --cc=bcrl@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=marcelo@conectiva.com.br \
    --cc=riel@conectiva.com.br \
    --cc=sct@redhat.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