* swap out memory
@ 2007-08-06 12:53 Shaohua Li
2007-08-08 12:03 ` Shaohua Li
0 siblings, 1 reply; 2+ messages in thread
From: Shaohua Li @ 2007-08-06 12:53 UTC (permalink / raw)
To: linux-fsdevel, linux-mm; +Cc: hch
Hi,
I'm trying to swap out kvm guest pages. The idea is to free some pages
when memory pressure is high. kvm has special things to handle like
shadow page tables. Before guest page is released, we need free some
data, that is guest page has 'private' data, so we can't directly make
the guest page swapout with Linux swapout mechanism. I'd like write
guest pages to a file or swap. kvm guest pages are in its address
space and added into lru list like normal page (the address space is
very like a shmem file's, kvm has a memory based file system). When
vmscan decided to free one guest page, kvm guest pages's
aops.writepage will free the private data and then write it out to
block device. The problem is how to write guest pages. I thought we
have some choices:
1. swap it to swapfile. Like shmem does, using move_to_swap_cache to
move guest page from its address space to swap address space, and
finally it's written to swapfile. This method works well, but as kvm
is a module, I must export some swap relelated APIs, which Christoph
Hellwig dislike.
2. write it to a file. Just like the stack fs does, in kvm address
space's .writepage, let low fs's aops write the page. This involves
allocating a new page for low fs file and copy kvm page to the new
page. As this (doing swap) is done when memory is tight, allocating
new page isn't good. The copy isn't good too.
3.write it to a file. Using bmap to get file's block info and using
low level sumbit_bio for read/write. This is like what swapfile does,
but we do it by ourselves, so don't need use swap symbols.
Do you have any suggestion which method is good, or if you have better
choice I could try?
Thanks,
Shaohua
--
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:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: swap out memory
2007-08-06 12:53 swap out memory Shaohua Li
@ 2007-08-08 12:03 ` Shaohua Li
0 siblings, 0 replies; 2+ messages in thread
From: Shaohua Li @ 2007-08-08 12:03 UTC (permalink / raw)
To: linux-fsdevel, linux-mm; +Cc: hch, Avi Kivity
2007/8/6, Shaohua Li <shaoh.li@gmail.com>:
> Hi,
> I'm trying to swap out kvm guest pages. The idea is to free some pages
> when memory pressure is high. kvm has special things to handle like
> shadow page tables. Before guest page is released, we need free some
> data, that is guest page has 'private' data, so we can't directly make
> the guest page swapout with Linux swapout mechanism. I'd like write
> guest pages to a file or swap. kvm guest pages are in its address
> space and added into lru list like normal page (the address space is
> very like a shmem file's, kvm has a memory based file system). When
> vmscan decided to free one guest page, kvm guest pages's
> aops.writepage will free the private data and then write it out to
> block device. The problem is how to write guest pages. I thought we
> have some choices:
>
> 1. swap it to swapfile. Like shmem does, using move_to_swap_cache to
> move guest page from its address space to swap address space, and
> finally it's written to swapfile. This method works well, but as kvm
> is a module, I must export some swap relelated APIs, which Christoph
> Hellwig dislike.
>
> 2. write it to a file. Just like the stack fs does, in kvm address
> space's .writepage, let low fs's aops write the page. This involves
> allocating a new page for low fs file and copy kvm page to the new
> page. As this (doing swap) is done when memory is tight, allocating
> new page isn't good. The copy isn't good too.
>
> 3.write it to a file. Using bmap to get file's block info and using
> low level sumbit_bio for read/write. This is like what swapfile does,
> but we do it by ourselves, so don't need use swap symbols.
>
> Do you have any suggestion which method is good, or if you have better
> choice I could try?
Can anybody share some hints? I really apprecate any comments.
Thanks,
Shaohua
--
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:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-08 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06 12:53 swap out memory Shaohua Li
2007-08-08 12:03 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox