9

I created a ramdisk using tmpfs as follows:

sudo mount -t tmpfs -o size=1024m tmpfs /myramdisk

I was looking into cgroup blkio subsystem bandwidth limits "read_bps_device" and "write_bps_device" but they seem to require the major and minor number of your block device that you want to throttle access to.

Is there any way to achieve a similar bandwidth limit to the in-memory tmpfs ramdisk?

UPDATE: I found a roundabout hacky way of accomplishing this. I first nfs export the ramdisk mount. Then nfs mount it over loopback on the same machine. I then use linux network traffic shaping to set bandwidth limits. This seems to provide what I need. I'm in the process of performing some measurements to see the penalty this hideous layering entails. I'll update info on that in a few days.

1
  • Can you write up what you did as an answer so I can award the bounty? Bounty is kind of a "use it or lose it" once it's offered.
    – Bratchley
    Nov 23, 2014 at 19:09

1 Answer 1

1

stat or /proc/[PID]/mountinfo should still tell you what the device numbers are:

[root@XXXlin01 block]# stat --printf="%d" /tmp/mnt; echo
24
[root@XXXlin01 block]# stat --printf="%d" /tmp/mnt2; echo
25
[root@XXXlin01 block]# grep "/tmp/mnt" /proc/22195/mountinfo
40 20 0:24 / /tmp/mnt rw,relatime - tmpfs none rw
41 20 0:25 / /tmp/mnt2 rw,relatime - tmpfs none rw

Both outputs show 0:25 and 0:24 as the device numbers in question. The "0" device number is used for "unnamed" mounts (such as tmpfs, sysfs, nfs, procfs, etc). For example, here is an NFS mount:

[root@XXXlin01 block]# grep "/LinuxHome" /proc/22195/mountinfo
39 36 0:23 / /home/jad87 rw,relatime - nfs duhsnas-xxx:/ifs/Application\040File\040Shares/DUHS/LinuxHomeDir_fs/jad87 rw,vers=3,rsize=4096,wsize=4096,namlen=255,soft,proto=tcp,timeo=14,retrans=2,sec=sys,mountaddr=10.1x.92.106,mountvers=3,mountport=300,mountproto=udp,local_lock=none,addr=10.1x.92.106
42 36 0:26 / /home/tsa20 rw,relatime - nfs 10.1x.92.117:/ifs/Application\040File\040Shares/DUHS/LinuxHomeDir_fs/tsa20 rw,vers=3,rsize=4096,wsize=4096,namlen=255,soft,proto=tcp,timeo=14,retrans=2,sec=sys,mountaddr=10.1x.92.117,mountvers=3,mountport=300,mountproto=udp,local_lock=none,addr=10.1x.92.117

The NFS mounts above are 0:23 and 0:26 respectively.

3
  • Thanks for the info on the major/minor number of the ramdisk. But cgroups blkio subsystem doesn't seem to allow throttling for unnamed devices. echo "0:32 1048576" > /sys/fs/cgroup/blkio/blkio.throttle.write_bps_device gave me an "write error: Invalid argument". May be there is a another way that somebody knows of. Nov 13, 2014 at 14:57
  • Ah sorry, didn't know that. Out of curiosity, what's the goal in shaping tmpfs bandwidth? Just to make room for other work on the FSB or something?
    – Bratchley
    Nov 13, 2014 at 18:38
  • This is for a simulation study for a course project. The goal is to plot an application's performance against a large range of different write/read bandwidths. Nov 14, 2014 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .