[Xen-devel] [PATCH][Take 3] Sysfs Interface for balloon driver

Satoshi Uchida
2006-10-02T11:21:20Z

Hi.

This patch provides a sysfs interface for the balloon driver (Take 3).

Currently, the interface for the balloon driver is provided by procfs.
However, I was suggested by Kier and Anthony that procfs should handle  only
process information and other information should be located in sysfs,
  when I made the interface for virtual block devices.

The information for the balloon driver also should be moved to sysfs.
So, I have made a sysfs interface for the balloon driver.

The information for balloon driver is placed in /sys/devices/system/memory/.

For Take 2 patch, this patch modifies only target_kB is kept in
/sys/devices/system/memory/memory0 as parameter,
and other information (ex. current_KB) is moved to info sub directory.

The hard limit is remained for the present.
Perhaps, anyone maybe used at someday, and it may be useful now.


Example outputs of the sysfs interface of the balloon driver are as follows:

 Example 1.  Show each information

[root@Dom0 ~]# ls -al /sys/devices/system/memory/memory0/
total 0
drwxr-xr-x 3 root root    0 Oct  2 20:13 .
drwxr-xr-x 3 root root    0 Oct  3  2006 ..
drwxr-xr-x 2 root root    0 Oct  2 20:11 info
-rw-r--r-- 1 root root 4096 Oct  2 20:13 target_kB
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/target_kB
262144
[root@noir ~]# ls -al /sys/devices/system/memory/memory0/info/
total 0
drwxr-xr-x 2 root root    0 Oct  2 20:11 .
drwxr-xr-x 3 root root    0 Oct  2 20:13 ..
-r--r--r-- 1 root root 4096 Oct  2 20:14 current_kB
-r--r--r-- 1 root root 4096 Oct  2 20:14 driver_kB
-r--r--r-- 1 root root 4096 Oct  2 20:14 hard_limit_kB
-r--r--r-- 1 root root 4096 Oct  2 20:14 high_kB
-r--r--r-- 1 root root 4096 Oct  2 20:14 low_kB
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/current_kB
262144
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/driver_kB
1024
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/hard_limit_kB
???
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/high_kB
0
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/low_kB
509952


 Example 2. Set memory size of a domain

[root@Dom0 ~]# echo 1024M > /sys/devices/system/memory/memory0/target_kB
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/target_kB
1048576
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/current_kB
758192
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/hard_limit_kB
758192
[root@Dom0 ~]# cat /sys/devices/system/memory/memory0/info/driver_kB
1024



Regards
Satoshi UCHIDA
   NEC Corporation, Japan