[linux-mm-cc] Re: vswap patch
Nitin Gupta
nitingupta.mail at gmail.com
Sat Jun 24 05:21:42 EDT 2006
Hi Allan,
On 6/24/06, Allan Bezerra <allan.bezerra at gmail.com> wrote:
>
> > I didn't let print anything for vswap when reading /proc/swaps (please
> see: swap_show() in swapfile.c).
>
> Cool! Now, I understanding that. However, I think that show only summary
> line isn't good. Therefore, we can change the summary print order seq_puts(swap,
> "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n") to after SWP_COMPRESSED
> check. See the patch attached.
>
> Please, feel free to accept this suggestion.
>
diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 2c439eb..a43bb9f 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1269,14 +1269,14 @@ static int swap_show(struct seq_file *sw
> struct file *file;
> int len;
>
> - if (v == swap_info)
> - seq_puts(swap,
> "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
> -
> if (ptr->flags & SWP_COMPRESSED) {
> pr_info("vswap to be printed\n");
> return 0;
> }
>
> + if (v == swap_info)
> + seq_puts(swap,
> "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
> +
> file = ptr->swap_file;
> len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
> seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
>
This patch has a problem. It will not print heading if vswap is enabled
before any other swap. So, patch will be:
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a5461ef..a1d4af6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1329,13 +1329,15 @@ static int swap_show(struct seq_file *sw
struct file *file;
int len;
+ if (ptr->flags & SWP_COMPRESSED) {
+ pr_info("swap_show: vswap to be printed\n");
+ if (ptr->next == -1) return 0;
+ }
+
if (v == swap_info)
seq_puts(swap,
"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
- if (ptr->flags & SWP_COMPRESSED) {
- pr_info("vswap to be printed\n");
- return 0;
- }
+ if (ptr->flags & SWP_COMPRESSED) return 0;
file = ptr->swap_file;
len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
Outputs:
problem with your patch:
[root at localhost ~]# cat /proc/swaps
[root at localhost ~]# echo "10" > /proc/sys/vm/max_anon_cc_size
[root at localhost ~]# cat /proc/swaps
[root at localhost ~]# swapon /dev/sda2
[root at localhost ~]# cat /proc/swaps *** no heading ***
/dev/sda2 partition 530136 0 -1
[root at localhost ~]#
with second patch:
[root at localhost ~]# cat /proc/swaps
[root at localhost ~]# echo "10" > /proc/sys/vm/max_anon_cc_size
[root at localhost ~]# cat /proc/swaps
[root at localhost ~]# swapon /dev/sda2
[root at localhost ~]# cat /proc/swaps ** heading back **
Filename Type Size Used
Priority/dev/sda2 partition 530136
0 -1
[root at localhost ~]#
and it does't print anything when there's only vswap enabled (as expected).
I will soon push this in master branch...
Thanks for making me aware of this problem :)
Cheers,
Nitin Gupta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.laptop.org/pipermail/linux-mm-cc/attachments/20060624/2c462b23/attachment.html
More information about the linux-mm-cc
mailing list