m_uiotombuf: write total memory length of the allocated chain in pkthdr
Data allocated by m_uiotombuf() usually goes into a socket buffer. We are interested in the length of useful data to be added to sb_acc, as well as total memory used by mbufs. The later would be added to sb_mbcnt. Calculating this value at allocation time allows to save on extra traversal of the mbuf chain. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35301
This commit is contained in:
parent
a7444f807e
commit
9b841b0e23
@ -1899,8 +1899,12 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags)
|
||||
|
||||
mb->m_len = length;
|
||||
progress += length;
|
||||
if (flags & M_PKTHDR)
|
||||
if (flags & M_PKTHDR) {
|
||||
m->m_pkthdr.len += length;
|
||||
m->m_pkthdr.memlen += MSIZE;
|
||||
if (mb->m_flags & M_EXT)
|
||||
m->m_pkthdr.memlen += mb->m_ext.ext_size;
|
||||
}
|
||||
}
|
||||
KASSERT(progress == total, ("%s: progress != total", __func__));
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ uipc_sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio,
|
||||
if (cc <= sbspace(sb)) {
|
||||
STAILQ_INSERT_TAIL(&sb->uxdg_mb, f, m_stailqpkt);
|
||||
/* XXX: would be nice if m_uiotombuf() returns count. */
|
||||
for (; f != NULL ; f = f->m_next) {
|
||||
for (; f != NULL; f = f->m_next) {
|
||||
if (f->m_type != MT_DATA)
|
||||
sb->sb_ctl += f->m_len;
|
||||
sb->sb_mbcnt += MSIZE;
|
||||
|
@ -207,13 +207,17 @@ struct pkthdr {
|
||||
|
||||
/* Layer specific non-persistent local storage for reassembly, etc. */
|
||||
union {
|
||||
uint8_t eight[8];
|
||||
uint16_t sixteen[4];
|
||||
uint32_t thirtytwo[2];
|
||||
uint64_t sixtyfour[1];
|
||||
uintptr_t unintptr[1];
|
||||
void *ptr;
|
||||
} PH_loc;
|
||||
union {
|
||||
uint8_t eight[8];
|
||||
uint16_t sixteen[4];
|
||||
uint32_t thirtytwo[2];
|
||||
uint64_t sixtyfour[1];
|
||||
uintptr_t unintptr[1];
|
||||
void *ptr;
|
||||
} PH_loc;
|
||||
/* Upon allocation: total packet memory consumption. */
|
||||
u_int memlen;
|
||||
};
|
||||
};
|
||||
#define ether_vtag PH_per.sixteen[0]
|
||||
#define tcp_tun_port PH_per.sixteen[0] /* outbound */
|
||||
|
Loading…
x
Reference in New Issue
Block a user