Subject: Patch for /proc/swaps
From: cryptronic <mail@cryptronic.de>
Date: Thu, 24 May 2012 09:27:23 +0200
Thu, 24 May 2012 09:27:23 +0200
Hi list,
Bertls patch
http://vserver.13thfloor.at/ExperimentalT/delta-swaps-feat01.diff lost
some information in newer kernels. Currently /proc/swaps display an
partition hdv0 and afterwards all other swap partitions/files from host.
So I tried to solve that issue. This is my first linux kernel patch and
i hope to make all right. Any recommendations about that patch?
The attached patch does workaround that and display only the hdv0
partition with the values from the memory swap cgroup controller.
best regards
Oliver
Hi list,
Bertls patch
http://vserver.13thfloor.at/ExperimentalT/delta-swaps-feat01.diff
lost some information in newer kernels. Currently /proc/swaps
display an partition hdv0 and afterwards all other swap
partitions/files from host.
So I tried to solve that issue. This is my first linux kernel patch
and i hope to make all right. Any recommendations about that patch?
The attached patch does workaround that and display only the hdv0
partition with the values from the memory swap cgroup controller.
best regards
Oliver
--- a/mm/swapfile.c 2012-05-24 06:17:06.297437990 +0000
+++ b/mm/swapfile.c 2012-05-24 06:28:45.272471742 +0000
@@ -1753,28 +1753,34 @@ static int swap_show(struct seq_file *sw
if (si == SEQ_START_TOKEN) {
seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
- if (vx_flags(VXF_VIRT_MEM, 0)) {
- struct sysinfo si;
-
- vx_vsi_swapinfo(&si);
- if (si.totalswap < (1 << 10))
- return 0;
- seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
- "hdv0", "partition", si.totalswap >> 10,
- (si.totalswap - si.freeswap) >> 10, -1);
- }
return 0;
}
- file = si->swap_file;
- len = seq_path(swap, &file->f_path, " \t\n\\");
- seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
+ if (vx_flags(VXF_VIRT_MEM, 0)) {
+ if(si->type != 0) {
+ return 0;
+ }
+ struct sysinfo sis;
+
+ vx_vsi_swapinfo(&sis);
+ if (sis.totalswap < (1 << 10))
+ return 0;
+ seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
+ "hdv0", "partition", (sis.totalswap << 2) ,
+ ((sis.totalswap - sis.freeswap) << 2) , -1);
+ }
+ else
+ {
+ file = si->swap_file;
+ len = seq_path(swap, &file->f_path, " \t\n\\");
+ seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
len < 40 ? 40 - len : 1, " ",
S_ISBLK(file->f_path.dentry->d_inode->i_mode) ?
"partition" : "file\t",
si->pages << (PAGE_SHIFT - 10),
si->inuse_pages << (PAGE_SHIFT - 10),
si->prio);
+ }
return 0;
}