On 1 June 2012 08:42, Eitan Adler <ead...@freebsd.org> wrote:
> Author: eadler
> Date: Fri Jun  1 04:42:52 2012
> New Revision: 236380
> URL: http://svn.freebsd.org/changeset/base/236380
>
> Log:
>  Add sysctl to query amount of swap space free
>
>  PR:           kern/166780
>  Submitted by: Radim Kolar <h...@sendmail.cz>
>  Approved by:  cperciva
>  MFC after:    1 week

Well, we already have more powerful vm.swap_info, so
I see no reason to add yet another one to do the same thing
(but now with a human interface).
Probably sysctl(8) should be enhanced to parse it instead.

>
> Modified:
>  head/sys/vm/swap_pager.c
>
> Modified: head/sys/vm/swap_pager.c
> ==============================================================================
> --- head/sys/vm/swap_pager.c    Fri Jun  1 04:34:49 2012        (r236379)
> +++ head/sys/vm/swap_pager.c    Fri Jun  1 04:42:52 2012        (r236380)
> @@ -2692,3 +2692,18 @@ swaponvp(struct thread *td, struct vnode
>            NODEV);
>        return (0);
>  }
> +
> +static int
> +sysctl_vm_swap_free(SYSCTL_HANDLER_ARGS) {
> +       int swap_free, used;
> +       int total;
> +
> +       swap_pager_status(&total, &used);
> +
> +       swap_free = (total - used) * PAGE_SIZE;
> +       return SYSCTL_OUT(req, &swap_free, sizeof(swap_free));
> +}
> +
> +SYSCTL_OID(_vm, OID_AUTO, swap_free, CTLTYPE_INT|CTLFLAG_RD|CTLFLAG_MPSAFE,
> +               NULL, 0, sysctl_vm_swap_free, "Q",
> +               "Blocks of free swap storage.");



-- 
wbr,
pluknet
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to