My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Scalability  
Handling multiple cores
Featured, Phase-Deploy
Updated Nov 20, 2011 by nitingupta910@gmail.com

Introduction

Each ramzswap device has its own compression buffer, memory pools and other metadata. All these buffers are protected by a per-device lock which are serious bottlenecks on multi-core machines.

Starting with compcache-0.6, we have support for creating multiple ramzswap devices, primarily to overcome this scalability problem. Divide and Conquer!

Details

If you have multiple cores, then using a single ramzswap can be a bottleneck. To avoid this problem, following configuration is recommended:

  • Check no. of cores you have and create equal number of ramzswap devices during module load. For quad core machine, you would do:
  • modprobe ramzswap num_devices=4
  • Initialize all of these devices. For example above:
  • # Assuming you need total disksize of 256MB.
    # So, per-device size would be 256/4=64MB.
    rzscontrol /dev/ramzswap0 -i --disksize_kb=65536
    rzscontrol /dev/ramzswap1 -i --disksize_kb=65536
    rzscontrol /dev/ramzswap2 -i --disksize_kb=65536
    rzscontrol /dev/ramzswap3 -i --disksize_kb=65536

(you can add backing swap disk/files to any/all of above devices. See rzscontrol manpage for more information).

  • swapon all these devices with the SAME PRIORITY. This priority must be higher than any of the disk based swap devices, if present. For example above:
  • swapon /dev/ramzswap0 -p 10
    swapon /dev/ramzswap1 -p 10
    swapon /dev/ramzswap2 -p 10
    swapon /dev/ramzswap3 -p 10

This kind of split setup should give you much better performance on multi-cores than a single giant ramzswap device.

Comment by KJac...@gmail.com, Jan 20, 2010

num_devices doesn't work (ramzswap: Unknown parameter `num_devices'). It should be NUM_DEVICES as rzscontrol(1) says. On the other hand, why not use lowercase letters like other kernel arguments.

Comment by project member nitingupta910@gmail.com, Jan 24, 2010

KJackie: compcache-0.6.1 uses lower case parameter num_devices.

Comment by oia...@gmail.com, Feb 17, 2010

Any future plans to move to per cpu locks. So making the locking auto spliting and only a single device entry required.

Really if per cpu locks can be used inside ramzswap0. The device lock can be used to search the swap for duplicated pages between cpu zones. Basically a split and merge system.

What I am thing is more a auto pool system. On device init ramzswap detects numbers of cpu's and might create like number cpu + 1 memory pools out of the total disk size.

In idle time ramzswap can compare the pools and merge as required. No point having like 3 copies of the same data in different ramzswaps due to not being able to compare because it was locked at the time.

Even if they stay as independent devices a way to merging there stored data has added.

On livecd and the like it being auto would be great.

Comment by project member nitingupta910@gmail.com, Mar 19, 2010

@pedretti.fabio: Fixed in repository. Thanks for pointing it out.

Comment by aav...@gmail.com, Aug 10, 2010

Hi all,

I am trying to implement two ramzswap area for a dual core(arm core) board.I first did a insmod with 2 devices.

insmod ./ramzswap.ko num_devices=2 ramzswap: Creating 2 devices ...
successfully creating two devics under the /dev directory. Next using rzscontrol utility I initialized the first devices viz ramzswap0
./rzscontrol /dev/ramzswap0 -i --disksize_kb=10000 ramzswap: Disk size set to 10000 kB
Now when i tried to initialize the second device simultaneously I got resource busy notification
./rzscontrol /dev/ramzswap1 -i --disksize_kb=10000 disksize_kb: Device or resource busy
How to over come this? Please give me some suggestion

One more clarification while testing for ramzswap I got a error for allocating memory.Is the ramzswap area getting completely filled the reason for such a error?

ramzswap: Error allocating memory for compressed page: 2270, size=0 Write-error on swap-device (254:0:18160)
Thank you in advance
Comment by empee584, Nov 27, 2011

On July 20th 2011, the zram driver in the linux 3.1 staging area was modified to use zram_num_devices as modprobe parameter - so if you use a recent kernel, update your init scripts!

commit efd54f4375982a3f8bef3cce610955f4cc37d5cb
Author: Noah Watkins <noahwatkins@gmail.com>
Date:   Wed Jul 20 17:06:08 2011 -0600

    staging: zram: make global var "num_devices" use unique name
    
    The global variable "num_devices" is too general to be
    global. This patch switches the name to be "zram_num_devices".

Sign in to add a comment
Powered by Google Project Hosting