Re: [lc-devel] vswap patch
Status: Beta
Brought to you by:
nitin_sf
From: Nitin G. <nit...@gm...> - 2006-06-24 10:56:46
|
Hi Allan, On 6/24/06, Allan Bezerra <all...@gm...> 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@localhost ~]# cat /proc/swaps [root@localhost ~]# echo "10" > /proc/sys/vm/max_anon_cc_size [root@localhost ~]# cat /proc/swaps [root@localhost ~]# swapon /dev/sda2 [root@localhost ~]# cat /proc/swaps *** no heading *** /dev/sda2 partition 530136 0 -1 [root@localhost ~]# with second patch: [root@localhost ~]# cat /proc/swaps [root@localhost ~]# echo "10" > /proc/sys/vm/max_anon_cc_size [root@localhost ~]# cat /proc/swaps [root@localhost ~]# swapon /dev/sda2 [root@localhost ~]# cat /proc/swaps ** heading back ** Filename Type Size Used Priority/dev/sda2 partition 530136 0 -1 [root@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 |