Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_mbuf.c
Show All 25 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_param.h" | #include "opt_param.h" | ||||
#include "opt_kern_tls.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/domainset.h> | #include <sys/domainset.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/domain.h> | #include <sys/domain.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktls.h> | |||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
#include <sys/refcount.h> | |||||
#include <sys/sf_buf.h> | #include <sys/sf_buf.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
int nmbufs; /* limits number of mbufs */ | int nmbufs; /* limits number of mbufs */ | ||||
int nmbclusters; /* limits number of mbuf clusters */ | int nmbclusters; /* limits number of mbuf clusters */ | ||||
int nmbjumbop; /* limits number of page size jumbo clusters */ | int nmbjumbop; /* limits number of page size jumbo clusters */ | ||||
int nmbjumbo9; /* limits number of 9k jumbo clusters */ | int nmbjumbo9; /* limits number of 9k jumbo clusters */ | ||||
int nmbjumbo16; /* limits number of 16k jumbo clusters */ | int nmbjumbo16; /* limits number of 16k jumbo clusters */ | ||||
bool mb_use_ext_pgs; /* use EXT_PGS mbufs for sendfile */ | bool mb_use_ext_pgs; /* use EXT_PGS mbufs for sendfile & TLS */ | ||||
SYSCTL_BOOL(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLFLAG_RWTUN, | SYSCTL_BOOL(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLFLAG_RWTUN, | ||||
&mb_use_ext_pgs, 0, | &mb_use_ext_pgs, 0, | ||||
"Use unmapped mbufs for sendfile(2)"); | "Use unmapped mbufs for sendfile(2) and TLS offload"); | ||||
static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ | static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ | ||||
SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, | SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, | ||||
"Maximum real memory allocatable to various mbuf types"); | "Maximum real memory allocatable to various mbuf types"); | ||||
static counter_u64_t snd_tag_count; | static counter_u64_t snd_tag_count; | ||||
SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, num_snd_tags, CTLFLAG_RW, | SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, num_snd_tags, CTLFLAG_RW, | ||||
▲ Show 20 Lines • Show All 1,149 Lines • ▼ Show 20 Lines | if (*refcnt == 1 || atomic_fetchadd_int(refcnt, -1) == 1) { | ||||
case EXT_JUMBO9: | case EXT_JUMBO9: | ||||
uma_zfree(zone_jumbo9, m->m_ext.ext_buf); | uma_zfree(zone_jumbo9, m->m_ext.ext_buf); | ||||
uma_zfree(zone_mbuf, mref); | uma_zfree(zone_mbuf, mref); | ||||
break; | break; | ||||
case EXT_JUMBO16: | case EXT_JUMBO16: | ||||
uma_zfree(zone_jumbo16, m->m_ext.ext_buf); | uma_zfree(zone_jumbo16, m->m_ext.ext_buf); | ||||
uma_zfree(zone_mbuf, mref); | uma_zfree(zone_mbuf, mref); | ||||
break; | break; | ||||
case EXT_PGS: | case EXT_PGS: { | ||||
#ifdef KERN_TLS | |||||
struct mbuf_ext_pgs *pgs; | |||||
struct ktls_session *tls; | |||||
#endif | |||||
KASSERT(mref->m_ext.ext_free != NULL, | KASSERT(mref->m_ext.ext_free != NULL, | ||||
("%s: ext_free not set", __func__)); | ("%s: ext_free not set", __func__)); | ||||
mref->m_ext.ext_free(mref); | mref->m_ext.ext_free(mref); | ||||
#ifdef KERN_TLS | |||||
pgs = mref->m_ext.ext_pgs; | |||||
tls = pgs->tls; | |||||
if (tls != NULL && | |||||
!refcount_release_if_not_last(&tls->refcount)) | |||||
ktls_enqueue_to_free(pgs); | |||||
else | |||||
#endif | |||||
uma_zfree(zone_extpgs, mref->m_ext.ext_pgs); | uma_zfree(zone_extpgs, mref->m_ext.ext_pgs); | ||||
uma_zfree(zone_mbuf, mref); | uma_zfree(zone_mbuf, mref); | ||||
break; | break; | ||||
} | |||||
case EXT_SFBUF: | case EXT_SFBUF: | ||||
case EXT_NET_DRV: | case EXT_NET_DRV: | ||||
case EXT_MOD_TYPE: | case EXT_MOD_TYPE: | ||||
case EXT_DISPOSABLE: | case EXT_DISPOSABLE: | ||||
KASSERT(mref->m_ext.ext_free != NULL, | KASSERT(mref->m_ext.ext_free != NULL, | ||||
("%s: ext_free not set", __func__)); | ("%s: ext_free not set", __func__)); | ||||
mref->m_ext.ext_free(mref); | mref->m_ext.ext_free(mref); | ||||
uma_zfree(zone_mbuf, mref); | uma_zfree(zone_mbuf, mref); | ||||
▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines |