diff options
author | bmilekic <bmilekic@FreeBSD.org> | 2002-07-15 15:32:59 +0000 |
---|---|---|
committer | bmilekic <bmilekic@FreeBSD.org> | 2002-07-15 15:32:59 +0000 |
commit | a574df824166a2af25a889070dfafea1052e160f (patch) | |
tree | 84c22c06833bf5944779340cbce44502ffb2413a /sys/kern/uipc_mbuf.c | |
parent | b5e51becccb11f99b69923a0cb10669844b18f01 (diff) | |
download | FreeBSD-src-a574df824166a2af25a889070dfafea1052e160f.zip FreeBSD-src-a574df824166a2af25a889070dfafea1052e160f.tar.gz |
o Introduce new m_getcl() interface routine that allocates an mbuf
and a cluster in one shot.
o Introduce MBP_PERSIST and MBP_PERSISTENT control bits to mb_alloc();
MBP_PERSIST means "if you can allocate, then keep the cache lock
held on exit," and MBP_PERSISTENT means "a cache lock is alredy held
on entry, so allocate from the specified (already locked) cache."
They may be used in combination.
o m_getcl() uses the MBP_PERSIST/MBP_PERSISTENT interface so that it
doesn't drop the cache lock in between the mbuf and cluster allocations.
o m_getm(), which takes a size and allocates an mbuf + cluster "best fit"
chain, has been moved from uipc_mbuf.c to subr_mbuf.c and shown how to
use MBP_PERSIST/MBP_PERSISTENT to attempt to do a grouped allocation
without dropping the cache lock in between.
Why this is good: much less bus-locked lock acquires/drops when they're
not needed. Also, prototype for m_getcl():
struct mbuf * m_getcl(int how, short type, int flags);
"how" and "type" are self-explanatory. "flags" may be M_PKTHDR, in
which case m_getcl() will make the mbuf a pkthdr-mbuf.
While I'm in subr_mbuf.c:
o Every exported routine now has a nice comment with a description of
the expected arguments. Eventually, mbuf(9) needs to be re-vamped
but there's still more code to write/finalize before I get to that.
o internal macros have been changed a bit.
o consistently use 'short' for "type." This somehow slipped through
before (that 'type' was sometimes declared as int).
Alfred has been pushing for the MBP_PERSIST{,ENT} thing for almost a
year now. Luigi asked for m_getcl(), and will probably MFC that
part of this commit.
TODO [Related]: teach mb_free() about MBP_PERSIST{, ENT}.
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 27ca156..ea8f16d 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -62,72 +62,6 @@ SYSCTL_INT(_kern_ipc, KIPC_MAX_HDR, max_hdr, CTLFLAG_RW, &max_hdr, 0, ""); SYSCTL_INT(_kern_ipc, KIPC_MAX_DATALEN, max_datalen, CTLFLAG_RW, &max_datalen, 0, ""); -/* - * struct mbuf * - * m_getm(m, len, how, type) - * - * This will allocate len-worth of mbufs and/or mbuf clusters (whatever fits - * best) and return a pointer to the top of the allocated chain. If m is - * non-null, then we assume that it is a single mbuf or an mbuf chain to - * which we want len bytes worth of mbufs and/or clusters attached, and so - * if we succeed in allocating it, we will just return a pointer to m. - * - * If we happen to fail at any point during the allocation, we will free - * up everything we have already allocated and return NULL. - * - */ -struct mbuf * -m_getm(struct mbuf *m, int len, int how, int type) -{ - struct mbuf *top, *tail, *mp, *mtail = NULL; - - KASSERT(len >= 0, ("len is < 0 in m_getm")); - - MGET(mp, how, type); - if (mp == NULL) - return (NULL); - else if (len > MINCLSIZE) { - MCLGET(mp, how); - if ((mp->m_flags & M_EXT) == 0) { - m_free(mp); - return (NULL); - } - } - mp->m_len = 0; - len -= M_TRAILINGSPACE(mp); - - if (m != NULL) - for (mtail = m; mtail->m_next != NULL; mtail = mtail->m_next); - else - m = mp; - - top = tail = mp; - while (len > 0) { - MGET(mp, how, type); - if (mp == NULL) - goto failed; - - tail->m_next = mp; - tail = mp; - if (len > MINCLSIZE) { - MCLGET(mp, how); - if ((mp->m_flags & M_EXT) == 0) - goto failed; - } - - mp->m_len = 0; - len -= M_TRAILINGSPACE(mp); - } - - if (mtail != NULL) - mtail->m_next = top; - return (m); - -failed: - m_freem(top); - return (NULL); -} - void m_freem(struct mbuf *m) { |