svn commit: r236380 - head/sys/vm

Konstantin Belousov kostikbel at gmail.com
Fri Jun 1 08:28:27 UTC 2012


On Fri, Jun 01, 2012 at 04:42:52AM +0000, Eitan Adler 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 <hsn at sendmail.cz>
>   Approved by:	cperciva
>   MFC after:	1 week
> 
> Modified:
>   head/sys/vm/swap_pager.c
The commit messages lack any rationale for the change.

The rationale specified in the PR is wrong, there _is_ the sysctl
interface to read the swap use, vm.swap_info.N. It is used by e.g.
swapinfo(8)/libkvm(3) on live system.

> 
> 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));
> +}
This just overflows at swap sizes greater then 2GB.

> +
> +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.");

Please revert the commit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20120601/0fa4a301/attachment.pgp


More information about the svn-src-all mailing list