uma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others

Remove mbuf_jumbo_alloc and let large mbuf zones use the new uma default
contig allocator (a copy of mbuf_jumbo_alloc).  Tag other zones which
require contiguous objects, even if they don't use the new default
contig allocator, so that uma knows about their constraints.

Reviewed by:	jeff, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23238
This commit is contained in:
Ryan Libby 2020-02-04 22:40:23 +00:00
parent ec0d828071
commit 10c8fb47d9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357548
3 changed files with 14 additions and 29 deletions

View File

@ -1064,7 +1064,7 @@ __CONCAT(PMTYPE, init)(void)
#ifdef PMAP_PAE_COMP
pdptzone = uma_zcreate("PDPT", NPGPTD * sizeof(pdpt_entry_t), NULL,
NULL, NULL, NULL, (NPGPTD * sizeof(pdpt_entry_t)) - 1,
UMA_ZONE_VM | UMA_ZONE_NOFREE);
UMA_ZONE_CONTIG | UMA_ZONE_VM | UMA_ZONE_NOFREE);
uma_zone_set_allocf(pdptzone, pmap_pdpt_allocf);
#endif

View File

@ -303,7 +303,6 @@ static void mb_dtor_pack(void *, int, void *);
static int mb_zinit_pack(void *, int, int);
static void mb_zfini_pack(void *, int);
static void mb_reclaim(uma_zone_t, int);
static void *mbuf_jumbo_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int);
/* Ensure that MSIZE is a power of 2. */
CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE);
@ -323,7 +322,7 @@ mbuf_init(void *dummy)
*/
zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE,
mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL,
MSIZE - 1, UMA_ZONE_MAXBUCKET);
MSIZE - 1, UMA_ZONE_CONTIG | UMA_ZONE_MAXBUCKET);
if (nmbufs > 0)
nmbufs = uma_zone_set_max(zone_mbuf, nmbufs);
uma_zone_set_warning(zone_mbuf, "kern.ipc.nmbufs limit reached");
@ -331,7 +330,7 @@ mbuf_init(void *dummy)
zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES,
mb_ctor_clust, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
UMA_ALIGN_PTR, UMA_ZONE_CONTIG);
if (nmbclusters > 0)
nmbclusters = uma_zone_set_max(zone_clust, nmbclusters);
uma_zone_set_warning(zone_clust, "kern.ipc.nmbclusters limit reached");
@ -343,7 +342,7 @@ mbuf_init(void *dummy)
/* Make jumbo frame zone too. Page size, 9k and 16k. */
zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE,
mb_ctor_clust, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
UMA_ALIGN_PTR, UMA_ZONE_CONTIG);
if (nmbjumbop > 0)
nmbjumbop = uma_zone_set_max(zone_jumbop, nmbjumbop);
uma_zone_set_warning(zone_jumbop, "kern.ipc.nmbjumbop limit reached");
@ -351,8 +350,7 @@ mbuf_init(void *dummy)
zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES,
mb_ctor_clust, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc);
UMA_ALIGN_PTR, UMA_ZONE_CONTIG);
if (nmbjumbo9 > 0)
nmbjumbo9 = uma_zone_set_max(zone_jumbo9, nmbjumbo9);
uma_zone_set_warning(zone_jumbo9, "kern.ipc.nmbjumbo9 limit reached");
@ -360,8 +358,7 @@ mbuf_init(void *dummy)
zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES,
mb_ctor_clust, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc);
UMA_ALIGN_PTR, UMA_ZONE_CONTIG);
if (nmbjumbo16 > 0)
nmbjumbo16 = uma_zone_set_max(zone_jumbo16, nmbjumbo16);
uma_zone_set_warning(zone_jumbo16, "kern.ipc.nmbjumbo16 limit reached");
@ -614,24 +611,6 @@ debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize)
}
#endif /* DEBUGNET */
/*
* UMA backend page allocator for the jumbo frame zones.
*
* Allocates kernel virtual memory that is backed by contiguous physical
* pages.
*/
static void *
mbuf_jumbo_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *flags,
int wait)
{
/* Inform UMA that this allocator uses kernel_map/object. */
*flags = UMA_SLAB_KERNEL;
return ((void *)kmem_alloc_contig_domainset(DOMAINSET_FIXED(domain),
bytes, wait, (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0,
VM_MEMATTR_DEFAULT));
}
/*
* Constructor for Mbuf master zone.
*

View File

@ -523,12 +523,18 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, int domain,
static void
slb_zone_init(void *dummy)
{
uint32_t allocf_flags;
allocf_flags = 0;
if (platform_real_maxaddr() != VM_MAX_ADDRESS)
allocf_flags = UMA_ZONE_CONTIG;
slbt_zone = uma_zcreate("SLB tree node", sizeof(struct slbtnode),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM);
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR,
allocf_flags | UMA_ZONE_VM);
slb_cache_zone = uma_zcreate("SLB cache",
(n_slbs + 1)*sizeof(struct slb *), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, UMA_ZONE_VM);
UMA_ALIGN_PTR, allocf_flags | UMA_ZONE_VM);
if (platform_real_maxaddr() != VM_MAX_ADDRESS) {
uma_zone_set_allocf(slb_cache_zone, slb_uma_real_alloc);