* SWAP_MAP_MAX: How?
@ 2001-08-24 11:16 Hugh Dickins
2001-08-24 11:19 ` Stephen C. Tweedie
0 siblings, 1 reply; 5+ messages in thread
From: Hugh Dickins @ 2001-08-24 11:16 UTC (permalink / raw)
To: Andrea Arcangeli, Ben LaHaise, Marcelo Tosatti, Rik van Riel,
Stephen Tweedie
Cc: linux-mm
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?
Thanks,
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: SWAP_MAP_MAX: How?
2001-08-24 11:16 SWAP_MAP_MAX: How? Hugh Dickins
@ 2001-08-24 11:19 ` Stephen C. Tweedie
2001-08-24 12:42 ` Hugh Dickins
0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 2001-08-24 11:19 UTC (permalink / raw)
To: Hugh Dickins
Cc: Andrea Arcangeli, Ben LaHaise, Marcelo Tosatti, Rik van Riel,
Stephen Tweedie, linux-mm
Hi,
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.
Cheers,
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-mm.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: SWAP_MAP_MAX: How?
2001-08-24 11:19 ` Stephen C. Tweedie
@ 2001-08-24 12:42 ` Hugh Dickins
2001-08-24 13:07 ` Stephen C. Tweedie
0 siblings, 1 reply; 5+ messages in thread
From: Hugh Dickins @ 2001-08-24 12:42 UTC (permalink / raw)
To: Stephen C. Tweedie
Cc: Andrea Arcangeli, Ben LaHaise, Marcelo Tosatti, Rik van Riel, linux-mm
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: SWAP_MAP_MAX: How?
2001-08-24 12:42 ` Hugh Dickins
@ 2001-08-24 13:07 ` Stephen C. Tweedie
2001-08-25 10:35 ` Hugh Dickins
0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 2001-08-24 13:07 UTC (permalink / raw)
To: Hugh Dickins
Cc: Stephen C. Tweedie, Andrea Arcangeli, Ben LaHaise,
Marcelo Tosatti, Rik van Riel, linux-mm
Hi,
On Fri, Aug 24, 2001 at 01:42:59PM +0100, Hugh Dickins wrote:
> Doesn't it need an anonymous page mapped multiple (e.g. 256) times
> into multiple (e.g. 256) mms to reach the limit?
That would do it, yes.
> 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.
Indeed --- sysV shm swapping is eccentric. :-)
There _was_ once a way to do this --- mmap()ing another process's
/proc/*/mem would allow you to get a swap page mapped into memory
multiple times, but we removed support for that way back in pre-2.2
days. I don't think we allow that any more, unless it's been
reenabled again.
Cheers,
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-mm.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: SWAP_MAP_MAX: How?
2001-08-24 13:07 ` Stephen C. Tweedie
@ 2001-08-25 10:35 ` Hugh Dickins
0 siblings, 0 replies; 5+ messages in thread
From: Hugh Dickins @ 2001-08-25 10:35 UTC (permalink / raw)
To: Stephen C. Tweedie
Cc: Andrea Arcangeli, Ben LaHaise, Marcelo Tosatti, Rik van Riel, linux-mm
On Fri, 24 Aug 2001, Stephen C. Tweedie wrote:
>
> There _was_ once a way to do this --- mmap()ing another process's
> /proc/*/mem would allow you to get a swap page mapped into memory
> multiple times, but we removed support for that way back in pre-2.2
> days. I don't think we allow that any more, unless it's been
> reenabled again.
(Apologies if I've taken too much context away there - I'd
like to force a rebuttal if any, flames to me not to Stephen.)
Thanks a lot, Stephen. I've waited awhile to see whether anyone else
dissents, but silence. I'm going to assume that SWAP_MAP_MAX cannot
actually happen in 2.4 at present. I'm not going to remove any code
that relates to it (unless asked to), it might be needed again the
day after tomorrow or whenever. But I shall not put any more effort
into handling that case correctly in try_to_unuse(),
beyond commenting the issues related to it.
Thanks again,
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-08-25 10:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-24 11:16 SWAP_MAP_MAX: How? Hugh Dickins
2001-08-24 11:19 ` Stephen C. Tweedie
2001-08-24 12:42 ` Hugh Dickins
2001-08-24 13:07 ` Stephen C. Tweedie
2001-08-25 10:35 ` Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox