1/*-
2 * Copyright (c) 2004, 2005,
3 * Bosko Milekic <bmilekic@FreeBSD.org>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 12 unchanged lines hidden (view full) ---
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/kern/kern_mbuf.c 243631 2012-11-27 21:19:58Z andre $");
30
31#include "opt_param.h"
32
33#include <sys/param.h>
34#include <sys/malloc.h>
35#include <sys/systm.h>
36#include <sys/mbuf.h>
37#include <sys/domain.h>
--- 64 unchanged lines hidden (view full) ---
102int nmbjumbo9; /* limits number of 9k jumbo clusters */
103int nmbjumbo16; /* limits number of 16k jumbo clusters */
104struct mbstat mbstat;
105
106/*
107 * tunable_mbinit() has to be run before init_maxsockets() thus
108 * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets()
109 * runs at SI_ORDER_ANY.
110 */
111static void
112tunable_mbinit(void *dummy)
113{
114
115 /* This has to be done before VM init. */
116 TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters);
117 if (nmbclusters == 0) {
118#ifdef VM_AUTOTUNE_NMBCLUSTERS
119 nmbclusters = VM_AUTOTUNE_NMBCLUSTERS;
120#else
121 nmbclusters = 1024 + maxusers * 64;
122#endif
123#ifdef VM_MAX_AUTOTUNE_NMBCLUSTERS
124 if (nmbclusters > VM_MAX_AUTOTUNE_NMBCLUSTERS)
125 nmbclusters = VM_MAX_AUTOTUNE_NMBCLUSTERS;
126#endif
127 }
128
129 TUNABLE_INT_FETCH("kern.ipc.nmbjumbop", &nmbjumbop);
130 if (nmbjumbop == 0)
131 nmbjumbop = nmbclusters / 2;
132
133 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo9", &nmbjumbo9);
134 if (nmbjumbo9 == 0)
135 nmbjumbo9 = nmbclusters / 4;
136
137 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo16", &nmbjumbo16);
138 if (nmbjumbo16 == 0)
139 nmbjumbo16 = nmbclusters / 8;
140}
141SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, NULL);
142
143static int
144sysctl_nmbclusters(SYSCTL_HANDLER_ARGS)
145{
146 int error, newnmbclusters;
147
--- 88 unchanged lines hidden (view full) ---
236 int error, newnmbufs;
237
238 newnmbufs = nmbufs;
239 error = sysctl_handle_int(oidp, &newnmbufs, 0, req);
240 if (error == 0 && req->newptr) {
241 if (newnmbufs > nmbufs) {
242 nmbufs = newnmbufs;
243 uma_zone_set_max(zone_mbuf, nmbufs);
244 nmbclusters = uma_zone_get_max(zone_mbuf);
245 EVENTHANDLER_INVOKE(nmbufs_change);
246 } else
247 error = EINVAL;
248 }
249 return (error);
250}
251SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbuf, CTLTYPE_INT|CTLFLAG_RW,
252&nmbufs, 0, sysctl_nmbufs, "IU",
--- 502 unchanged lines hidden ---
2 * Copyright (c) 2004, 2005,
3 * Bosko Milekic <bmilekic@FreeBSD.org>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 12 unchanged lines hidden (view full) ---
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/kern/kern_mbuf.c 243631 2012-11-27 21:19:58Z andre $");
30
31#include "opt_param.h"
32
33#include <sys/param.h>
34#include <sys/malloc.h>
35#include <sys/systm.h>
36#include <sys/mbuf.h>
37#include <sys/domain.h>
--- 64 unchanged lines hidden (view full) ---
102int nmbjumbo9; /* limits number of 9k jumbo clusters */
103int nmbjumbo16; /* limits number of 16k jumbo clusters */
104struct mbstat mbstat;
105
106/*
107 * tunable_mbinit() has to be run before init_maxsockets() thus
108 * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets()
109 * runs at SI_ORDER_ANY.
110 */
111static void
112tunable_mbinit(void *dummy)
113{
114
115 /* This has to be done before VM init. */
116 TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters);
117 if (nmbclusters == 0) {
118#ifdef VM_AUTOTUNE_NMBCLUSTERS
119 nmbclusters = VM_AUTOTUNE_NMBCLUSTERS;
120#else
121 nmbclusters = 1024 + maxusers * 64;
122#endif
123#ifdef VM_MAX_AUTOTUNE_NMBCLUSTERS
124 if (nmbclusters > VM_MAX_AUTOTUNE_NMBCLUSTERS)
125 nmbclusters = VM_MAX_AUTOTUNE_NMBCLUSTERS;
126#endif
127 }
128
129 TUNABLE_INT_FETCH("kern.ipc.nmbjumbop", &nmbjumbop);
130 if (nmbjumbop == 0)
131 nmbjumbop = nmbclusters / 2;
132
133 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo9", &nmbjumbo9);
134 if (nmbjumbo9 == 0)
135 nmbjumbo9 = nmbclusters / 4;
136
137 TUNABLE_INT_FETCH("kern.ipc.nmbjumbo16", &nmbjumbo16);
138 if (nmbjumbo16 == 0)
139 nmbjumbo16 = nmbclusters / 8;
140}
141SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, NULL);
142
143static int
144sysctl_nmbclusters(SYSCTL_HANDLER_ARGS)
145{
146 int error, newnmbclusters;
147
--- 88 unchanged lines hidden (view full) ---
236 int error, newnmbufs;
237
238 newnmbufs = nmbufs;
239 error = sysctl_handle_int(oidp, &newnmbufs, 0, req);
240 if (error == 0 && req->newptr) {
241 if (newnmbufs > nmbufs) {
242 nmbufs = newnmbufs;
243 uma_zone_set_max(zone_mbuf, nmbufs);
244 nmbclusters = uma_zone_get_max(zone_mbuf);
245 EVENTHANDLER_INVOKE(nmbufs_change);
246 } else
247 error = EINVAL;
248 }
249 return (error);
250}
251SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbuf, CTLTYPE_INT|CTLFLAG_RW,
252&nmbufs, 0, sysctl_nmbufs, "IU",
--- 502 unchanged lines hidden ---