My favorites | Sign in
Logo
                
Search
for
Updated Oct 14, 2009 by nitingupta910
Labels: Phase-Deploy, Featured
CompilingAndUsingNew  
Compiling and Using ramzswap (0.6 or newer)

It requires kernel version 2.6.28 or higher.

Introduction

compcache-0.6 brings some new features which require some changes to the way you use it. Some of the new features include:

Its known to work on x86, x86_64 and ARM.

Details

Compiling

NOTE: ramzswap will work on kernels with or without this patch. Of course, this feature will be disabled if compiled against kernel without this patch.

Using

Above compilation gives following modules:

Following shows a typical sequence of steps for using ramzswap.

This creates 4 (uninitialized) devices: /dev/ramzswap{0,1,2,3}
Use rzscontrol utility to configure and initialize individual ramzswap devices. Example:
rzscontrol /dev/ramzswap0 --init # uses default value of disksize_kb
See
rzscontrol manpage for more details and examples.
  • Activate:
  • swapon /dev/ramzswap2 # or any other initialized ramzswap device
  • Stats:
  • rzscontrol /dev/ramzswap2 --stats
  • Deactivate:
  • swapoff /dev/ramzswap2
  • Reset:
  • rzscontrol /dev/ramzswap2 --reset
  • Unload Modules:
  • ./unload_modules

NOTE: You must issue reset after swapoff for any ramzswap device. The reset causes all the (per-device) memory to be freed and performs lots of cleanups.

(ramzswap module unload calls reset for all initialized devices).

Following state diagram shows various ramzswap device states. The rzscontrol utility sends various ioctls to the ramzswap module to get/set information about individual devices. In the following figure, ioctl(--blah) means action taken when 'rzscontrol /dev/ramzswapX --blah' is done for /dev/ramzswapX device.

Figure 1: ramzswap device states.

* Changing memlimit for an active device is not yet implemented.

Common Problems


The second system is the most dangerous system a man ever designs.... The general tendency is to over-design the second system, using all the ideas and frills that were cautiously sidetracked on the first one.

F.P.Brooks, Jr. The Mythical Man-Month (1975)


Comment by franklintitus, Aug 05, 2009

Per the wiki/manual "insmod ramzswap.ko NUM_DEVICES=4 # creates 4 uninitialized devices: /dev/ramzswap{0,1,2,3}"

Should probably read "insmod ramzswap.ko NUM_DEVICES=4 # creates 4 uninitialized devices: /dev/block/ramzswap{0,1,2,3}"

This is creating confusion for some users. Thanks

Comment by nitingupta910, Aug 05, 2009

franklintitus: The location of these device nodes is somewhat distro dependent. On my fedora system, /dev/ramzswapX nodes are created. Probably I should add a note regarding other possible locations of these nodes like /dev/block/ramzswapX as you pointed out.

Comment by gmatht, Aug 24, 2009

I can't seem to set the size of the compcache device. Is this expected?

$ (MEMLIMIT=55 ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --reset ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --memlimit_kb=$MEMLIMIT ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --init ; sudo swapon /dev/ramzswap1  ; cat /proc/swaps ; sudo swapoff /dev/ramzswap1)
Filename				Type		Size	Used	Priority
/dev/sdb9                               partition	2562328	58356	-1
/dev/ramzswap1                          partition	998172	0	-2
$ (MEMLIMIT=5120000 ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --reset ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --memlimit_kb=$MEMLIMIT ; sudo sub-projects/rzscontrol/rzscontrol /dev/ramzswap1 --init ; sudo swapon /dev/ramzswap1  ; cat /proc/swaps ; sudo swapoff /dev/ramzswap1)
Filename				Type		Size	Used	Priority
/dev/sdb9                               partition	2562328	58356	-1
/dev/ramzswap1                          partition	998172	0	-2
Comment by nitingupta910, Aug 24, 2009

memlimit_kb parameter is used only when backing_swap is used. If you don't want to provide any backing swap, then you must use disksize_kb instead.

BTW, disksize_kb is upper limit on uncompressed worth of data given device can hold. While, memlimit_kb is upper limit on compressed worth of data given device can hold.

I understand that specifying disksize_kb value as upper limit on uncompressed data size seems bit counter-intuitive but this is how it is... We need to present a "fixed-size" disk to kernel.

Comment by MikeTaylor00, Aug 28, 2009

I'm trying to run Compcache with backing swap using a swap file instead of a swap partition. If I use a swap partition it works great. If I use the exact same commands but change the -b paramater to a swap file I am unable to swapon the ramzswap. rzscontrol does not give me an error (it does if I don't use a valid swap file but when I do it is ok). But when I use the swapon command it says "invalid argument". Can anyone help me on this?

Comment by nitingupta910, Aug 28, 2009

MikeTaylor00?: I guess you have not done mkswap on the swapfile. Just fyi, to use 1G swapfile as backing swap, you would do:

dd if=/dev/zero of=swap.dd bs=1M count=1024
mkswap swap.dd
rzscontrol /dev/ramzswap0 --backing_swap=swap.dd --memlimit=40000 --init

(memlimit here ~40MB; shorter options -b, -m, -i will also work).

Comment by MikeTaylor00, Aug 29, 2009

I have done mk swap. Here is what I did

dd if=/dev/zero of=/system/sd/swap.file bs=1024 count=32768 
mkswap /system/sd/swap.file 

insmod ramzswap.ko NUM_DEVICES=1
rzscontrol /dev/block/ramzswap0 --backing_swap=/system/sd/swap.file --
memlimit_kb=18432 --init swapon /dev/block/ramzswap0 
Comment by MikeTaylor00, Aug 29, 2009

If I use the exact same commands that I listed above but I use my linux-swap partition /dev/block/mmcblk0p3 it works like a champ.

Comment by nitingupta910, Aug 29, 2009

I tried again, using file as backing swap works for me. Can you please submit an issue for this? Lets see whats happening in your case.

Comment by MikeTaylor00, Aug 29, 2009

BTW, I am using this with my G1 Phone which is an ARM processor. Could there be something that CC expects differently about the swap file? Maybe the block size is an issue?

Comment by KJackie, Sep 30, 2009

Should the user issue "rzscontrol --init" manually when the module is loaded? I found some comments from Ubuntu wiki and Gentoo bugzilla doesn't mention it.

Comment by nitingupta910, Sep 30, 2009

KJackie: When the module is loaded, all /dev/ramzswapX devices are uninitialized. So, to initialize any device, say ramzswap0, you have to do 'rzscontrol /dev/ramzswap0 --init' for the device while also providing (optional) parameters like backing_swap etc.

Comment by cjhard, Oct 08, 2009

Is there any reason why my swap devices are never used? I have a swappiness of 60 but free always reports 0 used space for Swap. It's not limited to compcache, but now that I got it working here I would like to fix it.

Comment by nitingupta910, Oct 10, 2009

cjhard: Perhaps you are not filling your memory enough. Run memog or something to force system into swapping.


Sign in to add a comment
Hosted by Google Code