Deleted Added
full compact
uipc_mbuf.c (77572) uipc_mbuf.c (77843)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. 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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. 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

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

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 77572 2001-06-01 09:51:14Z obrien $
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 77843 2001-06-06 22:17:08Z peter $
35 */
36
37#include "opt_param.h"
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/condvar.h>
41#include <sys/kernel.h>
42#include <sys/lock.h>
43#include <sys/malloc.h>
44#include <sys/mbuf.h>
45#include <sys/mutex.h>
46#include <sys/sysctl.h>
47#include <sys/domain.h>
48#include <sys/protosw.h>
49
50#include <vm/vm.h>
51#include <vm/vm_kern.h>
52#include <vm/vm_extern.h>
53
35 */
36
37#include "opt_param.h"
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/condvar.h>
41#include <sys/kernel.h>
42#include <sys/lock.h>
43#include <sys/malloc.h>
44#include <sys/mbuf.h>
45#include <sys/mutex.h>
46#include <sys/sysctl.h>
47#include <sys/domain.h>
48#include <sys/protosw.h>
49
50#include <vm/vm.h>
51#include <vm/vm_kern.h>
52#include <vm/vm_extern.h>
53
54#ifndef NMBCLUSTERS
55#define NMBCLUSTERS (512 + MAXUSERS * 16)
56#endif
57
54static void mbinit(void *);
55SYSINIT(mbuf, SI_SUB_MBUF, SI_ORDER_FIRST, mbinit, NULL)
56
57struct mbuf *mbutl;
58struct mbstat mbstat;
59u_long mbtypes[MT_NTYPES];
60int max_linkhdr;
61int max_protohdr;
62int max_hdr;
63int max_datalen;
58static void mbinit(void *);
59SYSINIT(mbuf, SI_SUB_MBUF, SI_ORDER_FIRST, mbinit, NULL)
60
61struct mbuf *mbutl;
62struct mbstat mbstat;
63u_long mbtypes[MT_NTYPES];
64int max_linkhdr;
65int max_protohdr;
66int max_hdr;
67int max_datalen;
64int nmbclusters;
65int nmbufs;
68int nmbclusters = NMBCLUSTERS;
69int nmbufs = NMBCLUSTERS * 4;
66int nmbcnt;
67u_long m_mballoc_wid = 0;
68u_long m_clalloc_wid = 0;
69
70/*
71 * freelist header structures...
72 * mbffree_lst, mclfree_lst, mcntfree_lst
73 */

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

94 sizeof(mbtypes), "LU", "");
95SYSCTL_INT(_kern_ipc, KIPC_NMBCLUSTERS, nmbclusters, CTLFLAG_RD,
96 &nmbclusters, 0, "Maximum number of mbuf clusters available");
97SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0,
98 "Maximum number of mbufs available");
99SYSCTL_INT(_kern_ipc, OID_AUTO, nmbcnt, CTLFLAG_RD, &nmbcnt, 0,
100 "Maximum number of ext_buf counters available");
101
70int nmbcnt;
71u_long m_mballoc_wid = 0;
72u_long m_clalloc_wid = 0;
73
74/*
75 * freelist header structures...
76 * mbffree_lst, mclfree_lst, mcntfree_lst
77 */

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

98 sizeof(mbtypes), "LU", "");
99SYSCTL_INT(_kern_ipc, KIPC_NMBCLUSTERS, nmbclusters, CTLFLAG_RD,
100 &nmbclusters, 0, "Maximum number of mbuf clusters available");
101SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0,
102 "Maximum number of mbufs available");
103SYSCTL_INT(_kern_ipc, OID_AUTO, nmbcnt, CTLFLAG_RD, &nmbcnt, 0,
104 "Maximum number of ext_buf counters available");
105
102#ifndef NMBCLUSTERS
103#define NMBCLUSTERS (512 + MAXUSERS * 16)
104#endif
106TUNABLE_INT("kern.ipc.nmbclusters", &nmbclusters);
107TUNABLE_INT("kern.ipc.nmbufs", &nmbufs);
108TUNABLE_INT("kern.ipc.nmbcnt", &nmbcnt);
105
109
106TUNABLE_INT_DECL("kern.ipc.nmbclusters", NMBCLUSTERS, nmbclusters);
107TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs);
108TUNABLE_INT_DECL("kern.ipc.nmbcnt", EXT_COUNTERS, nmbcnt);
109
110static void m_reclaim(void);
111
112/* Initial allocation numbers */
113#define NCL_INIT 2
114#define NMB_INIT 16
115#define REF_INIT NMBCLUSTERS
116
117/*
118 * Full mbuf subsystem initialization done here.
119 *
120 * XXX: If ever we have system specific map setups to do, then move them to
121 * machdep.c - for now, there is no reason for this stuff to go there.
122 */
123static void
124mbinit(void *dummy)
125{
126 vm_offset_t maxaddr;
127 vm_size_t mb_map_size;
128
110static void m_reclaim(void);
111
112/* Initial allocation numbers */
113#define NCL_INIT 2
114#define NMB_INIT 16
115#define REF_INIT NMBCLUSTERS
116
117/*
118 * Full mbuf subsystem initialization done here.
119 *
120 * XXX: If ever we have system specific map setups to do, then move them to
121 * machdep.c - for now, there is no reason for this stuff to go there.
122 */
123static void
124mbinit(void *dummy)
125{
126 vm_offset_t maxaddr;
127 vm_size_t mb_map_size;
128
129 /* Sanity checks and pre-initialization for non-constants */
130 if (nmbufs < nmbclusters * 2)
131 nmbufs = nmbclusters * 2;
132 if (nmbcnt == 0)
133 nmbcnt = EXT_COUNTERS;
134
129 /*
130 * Setup the mb_map, allocate requested VM space.
131 */
132 mb_map_size = (vm_size_t)(nmbufs * MSIZE + nmbclusters * MCLBYTES +
133 nmbcnt * sizeof(union mext_refcnt));
134 mb_map_size = rounddown(mb_map_size, PAGE_SIZE);
135 mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr,
136 mb_map_size);

--- 1068 unchanged lines hidden ---
135 /*
136 * Setup the mb_map, allocate requested VM space.
137 */
138 mb_map_size = (vm_size_t)(nmbufs * MSIZE + nmbclusters * MCLBYTES +
139 nmbcnt * sizeof(union mext_refcnt));
140 mb_map_size = rounddown(mb_map_size, PAGE_SIZE);
141 mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr,
142 mb_map_size);

--- 1068 unchanged lines hidden ---