Deleted Added
full compact
swap_pager.c (223825) swap_pager.c (224582)
1/*-
2 * Copyright (c) 1998 Matthew Dillon,
3 * Copyright (c) 1994 John S. Dyson
4 * Copyright (c) 1990 University of Utah.
5 * Copyright (c) 1982, 1986, 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 53 unchanged lines hidden (view full) ---

62 *
63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
64 *
65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
67 */
68
69#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Matthew Dillon,
3 * Copyright (c) 1994 John S. Dyson
4 * Copyright (c) 1990 University of Utah.
5 * Copyright (c) 1982, 1986, 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 53 unchanged lines hidden (view full) ---

62 *
63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
64 *
65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
67 */
68
69#include <sys/cdefs.h>
70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 223825 2011-07-06 20:06:44Z trasz $");
70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 224582 2011-08-01 19:12:15Z kib $");
71
72#include "opt_swap.h"
73#include "opt_vm.h"
74
75#include <sys/param.h>
76#include <sys/systm.h>
77#include <sys/conf.h>
78#include <sys/kernel.h>

--- 2281 unchanged lines hidden (view full) ---

2360 mtx_lock(&sw_dev_mtx);
2361 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2362 *total += sp->sw_nblks;
2363 *used += sp->sw_used;
2364 }
2365 mtx_unlock(&sw_dev_mtx);
2366}
2367
71
72#include "opt_swap.h"
73#include "opt_vm.h"
74
75#include <sys/param.h>
76#include <sys/systm.h>
77#include <sys/conf.h>
78#include <sys/kernel.h>

--- 2281 unchanged lines hidden (view full) ---

2360 mtx_lock(&sw_dev_mtx);
2361 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2362 *total += sp->sw_nblks;
2363 *used += sp->sw_used;
2364 }
2365 mtx_unlock(&sw_dev_mtx);
2366}
2367
2368static int
2369sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
2368int
2369swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len)
2370{
2370{
2371 int *name = (int *)arg1;
2372 int error, n;
2373 struct xswdev xs;
2374 struct swdevt *sp;
2371 struct swdevt *sp;
2372 char *tmp_devname;
2373 int error, n;
2375
2374
2376 if (arg2 != 1) /* name length */
2377 return (EINVAL);
2378
2379 n = 0;
2375 n = 0;
2376 error = ENOENT;
2380 mtx_lock(&sw_dev_mtx);
2381 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2377 mtx_lock(&sw_dev_mtx);
2378 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2382 if (n == *name) {
2383 mtx_unlock(&sw_dev_mtx);
2384 xs.xsw_version = XSWDEV_VERSION;
2385 xs.xsw_dev = sp->sw_dev;
2386 xs.xsw_flags = sp->sw_flags;
2387 xs.xsw_nblks = sp->sw_nblks;
2388 xs.xsw_used = sp->sw_used;
2389
2390 error = SYSCTL_OUT(req, &xs, sizeof(xs));
2391 return (error);
2379 if (n != name) {
2380 n++;
2381 continue;
2392 }
2382 }
2393 n++;
2383 xs->xsw_version = XSWDEV_VERSION;
2384 xs->xsw_dev = sp->sw_dev;
2385 xs->xsw_flags = sp->sw_flags;
2386 xs->xsw_nblks = sp->sw_nblks;
2387 xs->xsw_used = sp->sw_used;
2388 if (devname != NULL) {
2389 if (vn_isdisk(sp->sw_vp, NULL))
2390 tmp_devname = sp->sw_vp->v_rdev->si_name;
2391 else
2392 tmp_devname = "[file]";
2393 strncpy(devname, tmp_devname, len);
2394 }
2395 error = 0;
2396 break;
2394 }
2395 mtx_unlock(&sw_dev_mtx);
2397 }
2398 mtx_unlock(&sw_dev_mtx);
2396 return (ENOENT);
2399 return (error);
2397}
2398
2400}
2401
2402static int
2403sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
2404{
2405 struct xswdev xs;
2406 int error;
2407
2408 if (arg2 != 1) /* name length */
2409 return (EINVAL);
2410 error = swap_dev_info(*(int *)arg1, &xs, NULL, 0);
2411 if (error != 0)
2412 return (error);
2413 error = SYSCTL_OUT(req, &xs, sizeof(xs));
2414 return (error);
2415}
2416
2399SYSCTL_INT(_vm, OID_AUTO, nswapdev, CTLFLAG_RD, &nswapdev, 0,
2400 "Number of swap devices");
2401SYSCTL_NODE(_vm, OID_AUTO, swap_info, CTLFLAG_RD, sysctl_vm_swap_info,
2402 "Swap statistics by device");
2403
2404/*
2405 * vmspace_swap_count() - count the approximate swap usage in pages for a
2406 * vmspace.

--- 281 unchanged lines hidden ---
2417SYSCTL_INT(_vm, OID_AUTO, nswapdev, CTLFLAG_RD, &nswapdev, 0,
2418 "Number of swap devices");
2419SYSCTL_NODE(_vm, OID_AUTO, swap_info, CTLFLAG_RD, sysctl_vm_swap_info,
2420 "Swap statistics by device");
2421
2422/*
2423 * vmspace_swap_count() - count the approximate swap usage in pages for a
2424 * vmspace.

--- 281 unchanged lines hidden ---