Thread: [lc-devel] CCache work status
Status: Beta
Brought to you by:
nitin_sf
From: Nitin G. <nit...@gm...> - 2006-06-06 02:01:24
|
Hi, This is kind of weekly work summary for ccache work... :) I originally started this project with focus on "general" desktop systems (OpenOffice + KDE/Gnome on 128MB RAM?). But now I'll instead focus it on much more exciting case -- The OLPC systems. This should also bring its applicability to a wide range of Linux based embedded devices. This does not put original goal out of way but it just results in some change of priority - much of things are same for both. The most important things I learnt for OLPC systems w.r.t ccaching are: -- They DO NOT want on-disk compressed swapping (problems: slow speed for writing to flash space, wear leveling). -- For in-memory compression, they have much higher priority for compressing anonymous memory pages instead of filesystem backed (page-cache) pages. I originally started out to handle page-cache pages. Since I'm now focusing on OLPC systems, I'll change gears to anon pages now. This has slowed development for time being as I still have only half-baked roadmap for anon pages, but now design work has progressed nicely and have started its implementation work :) -------------------------------------------------------------------- The approach I've taken is this: * General It creates a virtual swap device (another swap_info_struct in swap_info[]). Its size is set though a /proc entry created by 'cc_control' module (attached). This swap is set to highest priority and is identified in other code paths with SWP_COMPRESSED flag. So, when adding page to swap cache, it is given 'type' no. as for this virt swap until it reaches its max capacity (as set through /proc interface). * Storing page to ccache When swap to disk occurs in pageout(), same things will occur as is done for page-cache pages -- it doesn't need to know if it's anon or fs-backed page. These things are - replace corresponding swapper radix tree node to a 'chunk_head' which then points to the location of 'chunks' in ccache storage structure. * Restoring an anon page from ccache When page fault occurs, handle_pte_fault() first checks swap cache if it already has required page which then calls find_get_page() over swapper space radix tree. Here, a compressed page is handled exactly as for page cache page i.e. checked if looked-up page has PG_compressed set, decompress it and make radix node point back to this uncompressed page. * Notes -- This approach deals easily with case where no real swap devices exist. This virt swap is a separate entity with all separate data structures like swap_map[] as for a normal swap device. -- This only requires working with arch independent swp_entry_t instead of arch dependent representation of it in PTEs. -- More code sharing for handling page-cache and swap-cache pages - much of code wouldn't know if its working with anon or fs-backed page like add_to_swap_cache(), find_get_page() (and friends). * About files attached -- cc_control module: This creates two proc entries: /proc/cc_control/{max_anon_cc_size, max_fs_backed_cc_size}. Write to max_anon_cc_size, the size of ccache for anon pages in units of no. of pages. Writing this value calls set_anon_cc_size() in mm/swapfile.c which creates this virtual swap device with size as passed and highest priority (hard-coded to 100). (max_fs_backed_cc_size is dummy for now). -- patch for 2.6.17-rc5 that has this set_anon_cc_size() with some small misc handling. TODO Next: merge work from prev patches (as on CompressedCaching/Code) with this one to get on with anon page ccache. (I'll try to update CompressedCaching page soon for anon page handling) PS: Marcelo, I'm unable to send mail to marcelo AT kvack DOT org (just get mail delivery failure notice), so sending to mtosatti AT redhat DOT com instead. Anyway, added your kvack address too, to see if I get it this time... :) Cheers, Nitin Gupta |
From: Nitin G. <nit...@gm...> - 2006-06-21 17:33:44
Attachments:
patch-cc-2.6.17.1-vswap-stable.diff
|
Hi, I just took all work upto now to 2.6.17.1 and virtual swap work seems to be gaining some ground now. This patch makes this vswap and system can swap out to this with no problem. Also started work on to replace the page that comes to vswap with chunk_head and restore them when they are looked up in page/swap cache lookup functions (find_get_page() and friends). I hope to post this much in next few days. Following this, I will start actual compression using algos ported and compression structure implementation (as on Wiki). Cheers, Nitin Gupta |
From: Rik v. R. <ri...@re...> - 2006-06-21 23:46:01
|
On Wed, 21 Jun 2006, Nitin Gupta wrote: > This patch makes this vswap and system can swap out to this with no problem. > Also started work on to replace the page that comes to vswap with chunk_head > and restore them when they are looked up in page/swap cache lookup functions > (find_get_page() and friends). I hope to post this much in next few days. Your patch looks like a good start. I'll save the obvious code cleanup patches for later, when it's time to get stuff merged :) -- All Rights Reversed |
From: Marcelo T. <ma...@kv...> - 2006-06-22 01:03:06
|
On Wed, Jun 21, 2006 at 07:45:31PM -0400, Rik van Riel wrote: > On Wed, 21 Jun 2006, Nitin Gupta wrote: > > > This patch makes this vswap and system can swap out to this with no problem. > > Also started work on to replace the page that comes to vswap with chunk_head > > and restore them when they are looked up in page/swap cache lookup functions > > (find_get_page() and friends). I hope to post this much in next few days. > > Your patch looks like a good start. I'll save the > obvious code cleanup patches for later, when it's > time to get stuff merged :) Looks good indeed - Nitin, I guess the harder part of this is getting the compression cost estimation / code actually working ? Need to get the uncompression code working in do_swap_page()... |
From: Rik v. R. <ri...@re...> - 2006-06-06 01:50:25
|
On Mon, 5 Jun 2006, Nitin Gupta wrote: > This is kind of weekly work summary for ccache work... :) Awesome. Let me know if you need any advice, etc... > It creates a virtual swap device (another swap_info_struct in > swap_info[]). Its size is set though a /proc entry created by > 'cc_control' module (attached). Nice. I wonder if this should/could be handled through flags to swapon so we can have this device in /etc/fstab ? Not an immediate concern though - that would be a cleanup for when things actually work ;) > * About files attached > -- cc_control module: This creates two proc entries: > /proc/cc_control/{max_anon_cc_size, max_fs_backed_cc_size}. This should probably be in /proc/sys/vm, which also means you can use the sysctl code and easily read/write ascii numbers into these files. -- All Rights Reversed |
From: Anderson B. <bri...@gm...> - 2006-06-07 20:16:39
|
[RESENDING] Hi Nitin, I'm testing the patch and the module but I got a 'Segmentation Fault' problem when reading /proc/swaps entry after creating the virtual swap area. Is this virtual swap usable? Because when a page will be swapped-out to the virtual swap area I'm getting a Kernel Null pointer reference. Best regards, Anderson Briglia PS: I sent this message yesterday to the linux-compressed mailing list, but it didn't come for some reason. On 6/4/06, Nitin Gupta <nit...@gm...> wrote: > Hi, > > This is kind of weekly work summary for ccache work... :) > > I originally started this project with focus on "general" desktop systems > (OpenOffice + KDE/Gnome on 128MB RAM?). But now I'll instead focus it on much > more exciting case -- The OLPC systems. This should also bring its applicability > to a wide range of Linux based embedded devices. This does not put original goal > out of way but it just results in some change of priority - much of things are > same for both. > > The most important things I learnt for OLPC systems w.r.t ccaching are: > > -- They DO NOT want on-disk compressed swapping (problems: slow speed for > writing to flash space, wear leveling). > -- For in-memory compression, they have much higher priority for compressing > anonymous memory pages instead of filesystem backed (page-cache) pages. > > I originally started out to handle page-cache pages. Since I'm now focusing on > OLPC systems, I'll change gears to anon pages now. This has slowed development > for time being as I still have only half-baked roadmap for anon pages, but now > design work has progressed nicely and have started its implementation work :) > -------------------------------------------------------------------- > > The approach I've taken is this: > > * General > It creates a virtual swap device (another swap_info_struct in swap_info[]). Its > size is set though a /proc entry created by 'cc_control' module (attached). This > swap is set to highest priority and is identified in other code paths with > SWP_COMPRESSED flag. So, when adding page to swap cache, it is given 'type' no. > as for this virt swap until it reaches its max capacity (as set through /proc > interface). > > * Storing page to ccache > When swap to disk occurs in pageout(), same things will occur as is done for > page-cache pages -- it doesn't need to know if it's anon or fs-backed page. > These things are - replace corresponding swapper radix tree node to a > 'chunk_head' which then points to the location of 'chunks' in ccache storage > structure. > > * Restoring an anon page from ccache > When page fault occurs, handle_pte_fault() first checks swap cache if it already > has required page which then calls find_get_page() over swapper space radix > tree. Here, a compressed page is handled exactly as for page cache page i.e. > checked if looked-up page has PG_compressed set, decompress it and make radix > node point back to this uncompressed page. > > * Notes > -- This approach deals easily with case where no real swap devices exist. This > virt swap is a separate entity with all separate data structures like swap_map[] > as for a normal swap device. > -- This only requires working with arch independent swp_entry_t instead of arch > dependent representation of it in PTEs. > -- More code sharing for handling page-cache and swap-cache pages - much of code > wouldn't know if its working with anon or fs-backed page like > add_to_swap_cache(), find_get_page() (and friends). |
From: Anderson B. <bri...@gm...> - 2006-06-08 00:45:05
|
Hi Nitin, > The approach I've taken is this: > > * General > It creates a virtual swap device (another swap_info_struct in swap_info[]). Its > size is set though a /proc entry created by 'cc_control' module (attached). This > swap is set to highest priority and is identified in other code paths with > SWP_COMPRESSED flag. So, when adding page to swap cache, it is given 'type' no. > as for this virt swap until it reaches its max capacity (as set through /proc > interface). > > * Storing page to ccache > When swap to disk occurs in pageout(), same things will occur as is done for > page-cache pages -- it doesn't need to know if it's anon or fs-backed page. > These things are - replace corresponding swapper radix tree node to a > 'chunk_head' which then points to the location of 'chunks' in ccache storage > structure. > > * Restoring an anon page from ccache > When page fault occurs, handle_pte_fault() first checks swap cache if it already > has required page which then calls find_get_page() over swapper space radix > tree. Here, a compressed page is handled exactly as for page cache page i.e. > checked if looked-up page has PG_compressed set, decompress it and make radix > node point back to this uncompressed page. > > * Notes > -- This approach deals easily with case where no real swap devices exist. This > virt swap is a separate entity with all separate data structures like swap_map[] > as for a normal swap device. > -- This only requires working with arch independent swp_entry_t instead of arch > dependent representation of it in PTEs. > -- More code sharing for handling page-cache and swap-cache pages - much of code > wouldn't know if its working with anon or fs-backed page like > add_to_swap_cache(), find_get_page() (and friends). > > * About files attached > -- cc_control module: This creates two proc entries: > /proc/cc_control/{max_anon_cc_size, max_fs_backed_cc_size}. Write to > max_anon_cc_size, the size of ccache for anon pages in units of no. of pages. > Writing this value calls set_anon_cc_size() in mm/swapfile.c which creates this > virtual swap device with size as passed and highest priority (hard-coded to > 100). (max_fs_backed_cc_size is dummy for now). > -- patch for 2.6.17-rc5 that has this set_anon_cc_size() with some small misc > handling. I'm testing the patch and the module but I got a 'Segmentation Fault' problem when reading /proc/swaps entry after creating the virtual swap area. Is this virtual swap usable? Because when a page will be swapped-out to the virtual swap area I'm getting a Kernel Null pointer reference. Best regards, Anderson Briglia |
From: Nitin G. <nit...@gm...> - 2006-06-08 06:36:41
|
Hi Briglia, > > I'm testing the patch and the module but I got a 'Segmentation Fault' > problem when reading /proc/swaps entry after creating the virtual swap > area. > Is this virtual swap usable? Because when a page will be swapped-out > to the virtual swap area I'm getting a Kernel Null pointer reference. > This virtual swap patch is just the beginning point and these seg faults are 'expected' behavior -- nothing is usable now. To make it work, it is required to integrate the work from previous patches (as on CompressedCaching/Code) and this is what is my next TODO.... Currently, just for a bit change of work, I am working on porting LZO (ver 2.02). It should be completed today. Then I will continue to make this virtual swap actually work. Thanks for looking into this work :) Best Regards, Nitin Gupta |