svn commit: r192154 - in stable/7: sys sys/contrib/pf
sys/dev/ath/ath_hal sys/dev/cxgb sys/kern sys/sys sys/ufs/ffs
sys/vm usr.bin/systat usr.bin/top
John Baldwin
jhb at FreeBSD.org
Fri May 15 19:54:21 UTC 2009
Author: jhb
Date: Fri May 15 19:54:19 2009
New Revision: 192154
URL: http://svn.freebsd.org/changeset/base/192154
Log:
MFC: Adjust some variables (mostly related to the buffer cache) that hold
address space sizes to be longs instead of ints. This includes an ABI
compat shim for the kern.bufspace sysctl for old binaries.
Modified:
stable/7/sys/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
stable/7/sys/dev/ath/ath_hal/ (props changed)
stable/7/sys/dev/cxgb/ (props changed)
stable/7/sys/kern/subr_param.c
stable/7/sys/kern/sys_pipe.c
stable/7/sys/kern/vfs_bio.c
stable/7/sys/sys/buf.h
stable/7/sys/sys/pipe.h
stable/7/sys/ufs/ffs/ffs_snapshot.c
stable/7/sys/ufs/ffs/ffs_vfsops.c
stable/7/sys/vm/vm_init.c
stable/7/sys/vm/vnode_pager.c
stable/7/usr.bin/systat/ (props changed)
stable/7/usr.bin/systat/vmstat.c
stable/7/usr.bin/top/ (props changed)
stable/7/usr.bin/top/machine.c
Modified: stable/7/sys/kern/subr_param.c
==============================================================================
--- stable/7/sys/kern/subr_param.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/kern/subr_param.c Fri May 15 19:54:19 2009 (r192154)
@@ -76,9 +76,9 @@ int maxfilesperproc; /* per-proc open f
int ncallout; /* maximum # of timer events */
int nbuf;
int nswbuf;
-int maxswzone; /* max swmeta KVA storage */
-int maxbcache; /* max buffer cache KVA storage */
-int maxpipekva; /* Limit on pipe KVA */
+long maxswzone; /* max swmeta KVA storage */
+long maxbcache; /* max buffer cache KVA storage */
+long maxpipekva; /* Limit on pipe KVA */
u_long maxtsiz; /* max text size */
u_long dfldsiz; /* initial data size limit */
u_long maxdsiz; /* max data size */
@@ -94,9 +94,9 @@ SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLA
"Number of buffers in the buffer cache");
SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0,
"Number of swap buffers");
-SYSCTL_INT(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0,
+SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0,
"Maximum memory for swap metadata");
-SYSCTL_INT(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0,
+SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0,
"Maximum value of vfs.maxbufspace");
SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RDTUN, &maxtsiz, 0,
"Maximum text size");
@@ -132,11 +132,11 @@ init_param1(void)
#ifdef VM_SWZONE_SIZE_MAX
maxswzone = VM_SWZONE_SIZE_MAX;
#endif
- TUNABLE_INT_FETCH("kern.maxswzone", &maxswzone);
+ TUNABLE_LONG_FETCH("kern.maxswzone", &maxswzone);
#ifdef VM_BCACHE_SIZE_MAX
maxbcache = VM_BCACHE_SIZE_MAX;
#endif
- TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache);
+ TUNABLE_LONG_FETCH("kern.maxbcache", &maxbcache);
maxtsiz = MAXTSIZ;
TUNABLE_ULONG_FETCH("kern.maxtsiz", &maxtsiz);
@@ -211,5 +211,5 @@ init_param3(long kmempages)
maxpipekva = (kmempages / 20) * PAGE_SIZE;
if (maxpipekva < 512 * 1024)
maxpipekva = 512 * 1024;
- TUNABLE_INT_FETCH("kern.ipc.maxpipekva", &maxpipekva);
+ TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
}
Modified: stable/7/sys/kern/sys_pipe.c
==============================================================================
--- stable/7/sys/kern/sys_pipe.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/kern/sys_pipe.c Fri May 15 19:54:19 2009 (r192154)
@@ -175,15 +175,15 @@ static struct filterops pipe_wfiltops =
#define MINPIPESIZE (PIPE_SIZE/3)
#define MAXPIPESIZE (2*PIPE_SIZE/3)
-static int amountpipekva;
+static long amountpipekva;
static int pipefragretry;
static int pipeallocfail;
static int piperesizefail;
static int piperesizeallowed = 1;
-SYSCTL_INT(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN,
&maxpipekva, 0, "Pipe KVA limit");
-SYSCTL_INT(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD,
&amountpipekva, 0, "Pipe KVA usage");
SYSCTL_INT(_kern_ipc, OID_AUTO, pipefragretry, CTLFLAG_RD,
&pipefragretry, 0, "Pipe allocation retries due to fragmentation");
@@ -458,7 +458,7 @@ retry:
cpipe->pipe_buffer.in = cnt;
cpipe->pipe_buffer.out = 0;
cpipe->pipe_buffer.cnt = cnt;
- atomic_add_int(&amountpipekva, cpipe->pipe_buffer.size);
+ atomic_add_long(&amountpipekva, cpipe->pipe_buffer.size);
return (0);
}
@@ -1437,7 +1437,7 @@ pipe_free_kmem(cpipe)
("pipe_free_kmem: pipe mutex locked"));
if (cpipe->pipe_buffer.buffer != NULL) {
- atomic_subtract_int(&amountpipekva, cpipe->pipe_buffer.size);
+ atomic_subtract_long(&amountpipekva, cpipe->pipe_buffer.size);
vm_map_remove(pipe_map,
(vm_offset_t)cpipe->pipe_buffer.buffer,
(vm_offset_t)cpipe->pipe_buffer.buffer + cpipe->pipe_buffer.size);
Modified: stable/7/sys/kern/vfs_bio.c
==============================================================================
--- stable/7/sys/kern/vfs_bio.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/kern/vfs_bio.c Fri May 15 19:54:19 2009 (r192154)
@@ -109,30 +109,31 @@ static int buf_do_flush(struct vnode *vp
static int flushbufqueues(struct vnode *, int, int);
static void buf_daemon(void);
static void bremfreel(struct buf *bp);
+static int sysctl_bufspace(SYSCTL_HANDLER_ARGS);
int vmiodirenable = TRUE;
SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0,
"Use the VM system for directory writes");
-int runningbufspace;
-SYSCTL_INT(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0,
+long runningbufspace;
+SYSCTL_LONG(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0,
"Amount of presently outstanding async buffer io");
-static int bufspace;
-SYSCTL_INT(_vfs, OID_AUTO, bufspace, CTLFLAG_RD, &bufspace, 0,
- "Virtual memory used for buffers");
-static int maxbufspace;
-SYSCTL_INT(_vfs, OID_AUTO, maxbufspace, CTLFLAG_RD, &maxbufspace, 0,
+static long bufspace;
+SYSCTL_PROC(_vfs, OID_AUTO, bufspace, CTLTYPE_LONG|CTLFLAG_MPSAFE|CTLFLAG_RD,
+ &bufspace, 0, sysctl_bufspace, "L", "Virtual memory used for buffers");
+static long maxbufspace;
+SYSCTL_LONG(_vfs, OID_AUTO, maxbufspace, CTLFLAG_RD, &maxbufspace, 0,
"Maximum allowed value of bufspace (including buf_daemon)");
-static int bufmallocspace;
-SYSCTL_INT(_vfs, OID_AUTO, bufmallocspace, CTLFLAG_RD, &bufmallocspace, 0,
+static long bufmallocspace;
+SYSCTL_LONG(_vfs, OID_AUTO, bufmallocspace, CTLFLAG_RD, &bufmallocspace, 0,
"Amount of malloced memory for buffers");
-static int maxbufmallocspace;
-SYSCTL_INT(_vfs, OID_AUTO, maxmallocbufspace, CTLFLAG_RW, &maxbufmallocspace, 0,
+static long maxbufmallocspace;
+SYSCTL_LONG(_vfs, OID_AUTO, maxmallocbufspace, CTLFLAG_RW, &maxbufmallocspace, 0,
"Maximum amount of malloced memory for buffers");
-static int lobufspace;
-SYSCTL_INT(_vfs, OID_AUTO, lobufspace, CTLFLAG_RD, &lobufspace, 0,
+static long lobufspace;
+SYSCTL_LONG(_vfs, OID_AUTO, lobufspace, CTLFLAG_RD, &lobufspace, 0,
"Minimum amount of buffers we want to have");
-int hibufspace;
-SYSCTL_INT(_vfs, OID_AUTO, hibufspace, CTLFLAG_RD, &hibufspace, 0,
+long hibufspace;
+SYSCTL_LONG(_vfs, OID_AUTO, hibufspace, CTLFLAG_RD, &hibufspace, 0,
"Maximum allowed value of bufspace (excluding buf_daemon)");
static int bufreusecnt;
SYSCTL_INT(_vfs, OID_AUTO, bufreusecnt, CTLFLAG_RW, &bufreusecnt, 0,
@@ -143,11 +144,11 @@ SYSCTL_INT(_vfs, OID_AUTO, buffreekvacnt
static int bufdefragcnt;
SYSCTL_INT(_vfs, OID_AUTO, bufdefragcnt, CTLFLAG_RW, &bufdefragcnt, 0,
"Number of times we have had to repeat buffer allocation to defragment");
-static int lorunningspace;
-SYSCTL_INT(_vfs, OID_AUTO, lorunningspace, CTLFLAG_RW, &lorunningspace, 0,
+static long lorunningspace;
+SYSCTL_LONG(_vfs, OID_AUTO, lorunningspace, CTLFLAG_RW, &lorunningspace, 0,
"Minimum preferred space used for in-progress I/O");
-static int hirunningspace;
-SYSCTL_INT(_vfs, OID_AUTO, hirunningspace, CTLFLAG_RW, &hirunningspace, 0,
+static long hirunningspace;
+SYSCTL_LONG(_vfs, OID_AUTO, hirunningspace, CTLFLAG_RW, &hirunningspace, 0,
"Maximum amount of space to use for in-progress I/O");
int dirtybufferflushes;
SYSCTL_INT(_vfs, OID_AUTO, dirtybufferflushes, CTLFLAG_RW, &dirtybufferflushes,
@@ -284,6 +285,22 @@ const char *buf_wmesg = BUF_WMESG;
#define VFS_BIO_NEED_FREE 0x04 /* wait for free bufs, hi hysteresis */
#define VFS_BIO_NEED_BUFSPACE 0x08 /* wait for buf space, lo hysteresis */
+static int
+sysctl_bufspace(SYSCTL_HANDLER_ARGS)
+{
+ long lvalue;
+ int ivalue;
+
+ if (sizeof(int) == sizeof(long) || req->oldlen == sizeof(long))
+ return (sysctl_handle_long(oidp, arg1, arg2, req));
+ lvalue = *(long *)arg1;
+ if (lvalue > INT_MAX)
+ /* On overflow, still write out a long to trigger ENOMEM. */
+ return (sysctl_handle_long(oidp, &lvalue, 0, req));
+ ivalue = lvalue;
+ return (sysctl_handle_int(oidp, &ivalue, 0, req));
+}
+
#ifdef DIRECTIO
extern void ffs_rawread_setup(void);
#endif /* DIRECTIO */
@@ -343,7 +360,7 @@ runningbufwakeup(struct buf *bp)
{
if (bp->b_runningbufspace) {
- atomic_subtract_int(&runningbufspace, bp->b_runningbufspace);
+ atomic_subtract_long(&runningbufspace, bp->b_runningbufspace);
bp->b_runningbufspace = 0;
mtx_lock(&rbreqlock);
if (runningbufreq && runningbufspace <= lorunningspace) {
@@ -463,7 +480,8 @@ bd_speedup(void)
caddr_t
kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
{
- int maxbuf;
+ int tuned_nbuf;
+ long maxbuf;
/*
* physmem_est is in pages. Convert it to kilobytes (assumes
@@ -493,11 +511,17 @@ kern_vfs_bio_buffer_alloc(caddr_t v, lon
if (maxbcache && nbuf > maxbcache / BKVASIZE)
nbuf = maxbcache / BKVASIZE;
+ tuned_nbuf = 1;
+ } else
+ tuned_nbuf = 0;
- /* XXX Avoid integer overflows later on with maxbufspace. */
- maxbuf = (INT_MAX / 3) / BKVASIZE;
- if (nbuf > maxbuf)
- nbuf = maxbuf;
+ /* XXX Avoid unsigned long overflows later on with maxbufspace. */
+ maxbuf = (LONG_MAX / 3) / BKVASIZE;
+ if (nbuf > maxbuf) {
+ if (!tuned_nbuf)
+ printf("Warning: nbufs lowered from %d to %ld\n", nbuf,
+ maxbuf);
+ nbuf = maxbuf;
}
#if 0
@@ -582,8 +606,8 @@ bufinit(void)
* this may result in KVM fragmentation which is not handled optimally
* by the system.
*/
- maxbufspace = nbuf * BKVASIZE;
- hibufspace = imax(3 * maxbufspace / 4, maxbufspace - MAXBSIZE * 10);
+ maxbufspace = (long)nbuf * BKVASIZE;
+ hibufspace = lmax(3 * maxbufspace / 4, maxbufspace - MAXBSIZE * 10);
lobufspace = hibufspace - MAXBSIZE;
lorunningspace = 512 * 1024;
@@ -611,7 +635,7 @@ bufinit(void)
* be met. We try to size hidirtybuffers to 3/4 our buffer space assuming
* BKVASIZE'd (8K) buffers.
*/
- while (hidirtybuffers * BKVASIZE > 3 * hibufspace / 4) {
+ while ((long)hidirtybuffers * BKVASIZE > 3 * hibufspace / 4) {
hidirtybuffers >>= 1;
}
lodirtybuffers = hidirtybuffers / 2;
@@ -647,7 +671,7 @@ bfreekva(struct buf *bp)
if (bp->b_kvasize) {
atomic_add_int(&buffreekvacnt, 1);
- atomic_subtract_int(&bufspace, bp->b_kvasize);
+ atomic_subtract_long(&bufspace, bp->b_kvasize);
vm_map_remove(buffer_map, (vm_offset_t) bp->b_kvabase,
(vm_offset_t) bp->b_kvabase + bp->b_kvasize);
bp->b_kvasize = 0;
@@ -872,7 +896,7 @@ bufwrite(struct buf *bp)
* Normal bwrites pipeline writes
*/
bp->b_runningbufspace = bp->b_bufsize;
- atomic_add_int(&runningbufspace, bp->b_runningbufspace);
+ atomic_add_long(&runningbufspace, bp->b_runningbufspace);
if (!TD_IS_IDLETHREAD(curthread))
curthread->td_ru.ru_oublock++;
@@ -2054,7 +2078,7 @@ restart:
bp->b_kvabase = (caddr_t) addr;
bp->b_kvasize = maxsize;
- atomic_add_int(&bufspace, bp->b_kvasize);
+ atomic_add_long(&bufspace, bp->b_kvasize);
atomic_add_int(&bufreusecnt, 1);
}
vm_map_unlock(buffer_map);
@@ -2822,7 +2846,7 @@ allocbuf(struct buf *bp, int size)
} else {
free(bp->b_data, M_BIOBUF);
if (bp->b_bufsize) {
- atomic_subtract_int(
+ atomic_subtract_long(
&bufmallocspace,
bp->b_bufsize);
bufspacewakeup();
@@ -2859,7 +2883,7 @@ allocbuf(struct buf *bp, int size)
bp->b_bufsize = mbsize;
bp->b_bcount = size;
bp->b_flags |= B_MALLOC;
- atomic_add_int(&bufmallocspace, mbsize);
+ atomic_add_long(&bufmallocspace, mbsize);
return 1;
}
origbuf = NULL;
@@ -2873,7 +2897,7 @@ allocbuf(struct buf *bp, int size)
origbufsize = bp->b_bufsize;
bp->b_data = bp->b_kvabase;
if (bp->b_bufsize) {
- atomic_subtract_int(&bufmallocspace,
+ atomic_subtract_long(&bufmallocspace,
bp->b_bufsize);
bufspacewakeup();
bp->b_bufsize = 0;
Modified: stable/7/sys/sys/buf.h
==============================================================================
--- stable/7/sys/sys/buf.h Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/sys/buf.h Fri May 15 19:54:19 2009 (r192154)
@@ -479,10 +479,10 @@ buf_countdeps(struct buf *bp, int i)
#ifdef _KERNEL
extern int nbuf; /* The number of buffer headers */
-extern int maxswzone; /* Max KVA for swap structures */
-extern int maxbcache; /* Max KVA for buffer cache */
-extern int runningbufspace;
-extern int hibufspace;
+extern long maxswzone; /* Max KVA for swap structures */
+extern long maxbcache; /* Max KVA for buffer cache */
+extern long runningbufspace;
+extern long hibufspace;
extern int dirtybufthresh;
extern int bdwriteskip;
extern int dirtybufferflushes;
Modified: stable/7/sys/sys/pipe.h
==============================================================================
--- stable/7/sys/sys/pipe.h Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/sys/pipe.h Fri May 15 19:54:19 2009 (r192154)
@@ -56,7 +56,7 @@
/*
* See sys_pipe.c for info on what these limits mean.
*/
-extern int maxpipekva;
+extern long maxpipekva;
/*
* Pipe buffer information.
Modified: stable/7/sys/ufs/ffs/ffs_snapshot.c
==============================================================================
--- stable/7/sys/ufs/ffs/ffs_snapshot.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/ufs/ffs/ffs_snapshot.c Fri May 15 19:54:19 2009 (r192154)
@@ -2272,7 +2272,7 @@ ffs_copyonwrite(devvp, bp)
VI_UNLOCK(devvp);
if (saved_runningbufspace != 0) {
bp->b_runningbufspace = saved_runningbufspace;
- atomic_add_int(&runningbufspace,
+ atomic_add_long(&runningbufspace,
bp->b_runningbufspace);
}
return (0); /* Snapshot gone */
@@ -2397,7 +2397,7 @@ ffs_copyonwrite(devvp, bp)
*/
if (saved_runningbufspace != 0) {
bp->b_runningbufspace = saved_runningbufspace;
- atomic_add_int(&runningbufspace, bp->b_runningbufspace);
+ atomic_add_long(&runningbufspace, bp->b_runningbufspace);
}
return (error);
}
Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- stable/7/sys/ufs/ffs/ffs_vfsops.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/ufs/ffs/ffs_vfsops.c Fri May 15 19:54:19 2009 (r192154)
@@ -1919,7 +1919,7 @@ ffs_geom_strategy(struct bufobj *bo, str
}
}
bp->b_runningbufspace = bp->b_bufsize;
- atomic_add_int(&runningbufspace,
+ atomic_add_long(&runningbufspace,
bp->b_runningbufspace);
} else {
error = ffs_copyonwrite(vp, bp);
Modified: stable/7/sys/vm/vm_init.c
==============================================================================
--- stable/7/sys/vm/vm_init.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/vm/vm_init.c Fri May 15 19:54:19 2009 (r192154)
@@ -186,12 +186,12 @@ again:
panic("startup: table size inconsistency");
clean_map = kmem_suballoc(kernel_map, &kmi->clean_sva, &kmi->clean_eva,
- nbuf * BKVASIZE + nswbuf * MAXPHYS, FALSE);
+ (long)nbuf * BKVASIZE + (long)nswbuf * MAXPHYS, FALSE);
buffer_map = kmem_suballoc(clean_map, &kmi->buffer_sva,
- &kmi->buffer_eva, nbuf * BKVASIZE, FALSE);
+ &kmi->buffer_eva, (long)nbuf * BKVASIZE, FALSE);
buffer_map->system_map = 1;
pager_map = kmem_suballoc(clean_map, &kmi->pager_sva, &kmi->pager_eva,
- nswbuf * MAXPHYS, FALSE);
+ (long)nswbuf * MAXPHYS, FALSE);
pager_map->system_map = 1;
exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
exec_map_entries * (ARG_MAX + (PAGE_SIZE * 3)), FALSE);
Modified: stable/7/sys/vm/vnode_pager.c
==============================================================================
--- stable/7/sys/vm/vnode_pager.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/sys/vm/vnode_pager.c Fri May 15 19:54:19 2009 (r192154)
@@ -526,7 +526,7 @@ vnode_pager_input_smlfs(object, m)
bp->b_bcount = bsize;
bp->b_bufsize = bsize;
bp->b_runningbufspace = bp->b_bufsize;
- atomic_add_int(&runningbufspace, bp->b_runningbufspace);
+ atomic_add_long(&runningbufspace, bp->b_runningbufspace);
/* do the input */
bp->b_iooffset = dbtob(bp->b_blkno);
@@ -906,7 +906,7 @@ vnode_pager_generic_getpages(vp, m, byte
bp->b_bcount = size;
bp->b_bufsize = size;
bp->b_runningbufspace = bp->b_bufsize;
- atomic_add_int(&runningbufspace, bp->b_runningbufspace);
+ atomic_add_long(&runningbufspace, bp->b_runningbufspace);
PCPU_INC(cnt.v_vnodein);
PCPU_ADD(cnt.v_vnodepgsin, count);
Modified: stable/7/usr.bin/systat/vmstat.c
==============================================================================
--- stable/7/usr.bin/systat/vmstat.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/usr.bin/systat/vmstat.c Fri May 15 19:54:19 2009 (r192154)
@@ -115,7 +115,7 @@ static struct Info {
struct nchstats nchstats;
long nchcount;
long *intrcnt;
- int bufspace;
+ long bufspace;
int desiredvnodes;
long numvnodes;
long freevnodes;
Modified: stable/7/usr.bin/top/machine.c
==============================================================================
--- stable/7/usr.bin/top/machine.c Fri May 15 19:41:10 2009 (r192153)
+++ stable/7/usr.bin/top/machine.c Fri May 15 19:54:19 2009 (r192154)
@@ -433,7 +433,7 @@ get_system_info(struct system_info *si)
static unsigned int swap_delay = 0;
static int swapavail = 0;
static int swapfree = 0;
- static int bufspace = 0;
+ static long bufspace = 0;
static int nspgsin, nspgsout;
GETSYSCTL("vfs.bufspace", bufspace);
More information about the svn-src-stable
mailing list