* hard question re: swap cache
@ 2003-05-27 21:41 Carl Spalletta
2003-05-28 0:08 ` Hugh Dickins
2003-05-28 14:53 ` Dave McCracken
0 siblings, 2 replies; 5+ messages in thread
From: Carl Spalletta @ 2003-05-27 21:41 UTC (permalink / raw)
To: linux-mm
Assume a shared, anonymous page is referenced by a set of
processes a,b,c,d,e and the page is marked present in the
page tables of each process. Assume then that the page is
marked for swapout in the pagetables of 'a'. A swap slot is
filled with a copy of the page, but it is still present in
memory. As I understand it, it may still possible for b,c,d,e
to modify the page (since it is shared) and this is no problem
since there is no need to co-ordinate with the swapped out
page while the page usage counter is positive(if the system
decides to make the page present for a, it should simply
decrement the page slot counter but not bother with swapping
back since the page in memory is either an exact duplicate
or is newer than what is in the swap slot).
Then say b,c,d and e in that order have the page swapped out.
Either the page is copied to the page slot for each swapout
or it _must_ be copied on the last swap (when the page usage
counter goes to zero) else the modifications made by b,c,d,e
will be lost.
I can't decide which method is used and I can't find where in
the 2.5 code it occurs - can anyone help?
--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hard question re: swap cache
2003-05-27 21:41 hard question re: swap cache Carl Spalletta
@ 2003-05-28 0:08 ` Hugh Dickins
2003-05-28 14:53 ` Dave McCracken
1 sibling, 0 replies; 5+ messages in thread
From: Hugh Dickins @ 2003-05-28 0:08 UTC (permalink / raw)
To: Carl Spalletta; +Cc: linux-mm
On Tue, 27 May 2003, Carl Spalletta wrote:
> Assume a shared, anonymous page is referenced by a set of
> processes a,b,c,d,e and the page is marked present in the
> page tables of each process. Assume then that the page is
> marked for swapout in the pagetables of 'a'. A swap slot is
> filled with a copy of the page, but it is still present in
> memory.
> ....
> Then say b,c,d and e in that order have the page swapped out.
> Either the page is copied to the page slot for each swapout
> or it _must_ be copied on the last swap (when the page usage
> counter goes to zero) else the modifications made by b,c,d,e
> will be lost.
I'm not certain I understand your question (in particular, I don't
understand the page being copied to a page slot), but I might have
your answer.
Observe that mm/mmap.c:do_mmap_pgoff uses mm/shmem.c:shmem_zero_setup
for a shared anonymous mapping. That creates a tmpfs object to back
the mapping, so its pages are not _directly_ backed by swap.
Under memory pressure, shmem_writepage gets called, which translates
(well, akpm's superb technical term for this is "swizzles") the page
to swap, and then later shmem_getpage may bring it back in. Note
the BUG_ON(page_mapped(page)) in shmem_writepage, which gives the
assurance I think you're looking for.
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hard question re: swap cache
2003-05-27 21:41 hard question re: swap cache Carl Spalletta
2003-05-28 0:08 ` Hugh Dickins
@ 2003-05-28 14:53 ` Dave McCracken
1 sibling, 0 replies; 5+ messages in thread
From: Dave McCracken @ 2003-05-28 14:53 UTC (permalink / raw)
To: Carl Spalletta, linux-mm
Your question is a bit ambiguous because in kernel terms there are two
distinct cases.
A shared page, ie one mapped by mmap or shmmap is not anonymous in kernel
terms. It has a temporary file created for the region. A shared page in
this file is tracked through the page cache, so it's trivially found via
either page cache lookup or by pagein through file system calls.
A truly anonymous page is generally either bss space or stack, and can only
become shared through fork. When a page of this type is unmapped, its
address in swap space is written into the page table entry. The page is
also put into the swap cache at this time. When the process tries to map
the page again, it uses the swap address to look first in the swap cache,
or, failing that, read it from swap space.
An additional twist to this is that pages are not unmapped for swapout on a
per-process basis in 2.5. Page stealing is done via the active and
inactive lists, which are by physical page. They are unmapped in all
processes at the same time by using the pte_chain mechanism.
Dave McCracken
======================================================================
Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
dmccr@us.ibm.com T/L 678-3059
--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hard question re: swap cache
@ 2003-05-27 23:04 Carl Spalletta
2003-05-28 10:01 ` Sean Neakums
0 siblings, 1 reply; 5+ messages in thread
From: Carl Spalletta @ 2003-05-27 23:04 UTC (permalink / raw)
To: linux-mm
I thought of a simple example. Suppose processes a,b,c
have a shared, anonymous page. All processes have this page
present. Then the page for a is swapped out. Then b and c
exit unexpectedly, after making changes to the page. When
and if 'a' has the page swapped back in, what mechanism
guarantees that it will see the changes made by b and c?
Where specifically in the code, in what functions, does it
reside for kernel 2.5?
--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hard question re: swap cache
2003-05-27 23:04 Carl Spalletta
@ 2003-05-28 10:01 ` Sean Neakums
0 siblings, 0 replies; 5+ messages in thread
From: Sean Neakums @ 2003-05-28 10:01 UTC (permalink / raw)
To: linux-mm
Carl Spalletta <cspalletta@yahoo.com> writes:
> I thought of a simple example. Suppose processes a,b,c have a
> shared, anonymous page. All processes have this page present. Then
> the page for a is swapped out. Then b and c exit unexpectedly,
> after making changes to the page. When and if 'a' has the page
> swapped back in, what mechanism guarantees that it will see the
> changes made by b and c?
I don't think it makes much sense to say "the page for a" in the case
of a shared page.
--
Sean Neakums - <sneakums@zork.net>
--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-05-28 14:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-27 21:41 hard question re: swap cache Carl Spalletta
2003-05-28 0:08 ` Hugh Dickins
2003-05-28 14:53 ` Dave McCracken
2003-05-27 23:04 Carl Spalletta
2003-05-28 10:01 ` Sean Neakums
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox