Remove free_domain() and uma_zfree_domain().

These functions were introduced before UMA started ensuring that freed
memory gets placed in domain-local caches.  They no longer serve any
purpose since UMA now provides their functionality by default.  Remove
them to simplyify the kernel memory allocator interfaces a bit.

Reviewed by:	cem, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25937
This commit is contained in:
Mark Johnston 2020-08-04 13:58:36 +00:00
parent 3422ca83ba
commit 96ad26eefb
15 changed files with 28 additions and 103 deletions

View File

@ -36,6 +36,10 @@
# xargs -n1 | sort | uniq -d;
# done
# 20200803: remove free_domain(9) and uma_zfree_domain(9)
OLD_FILES+=usr/share/man/man9/free_domain.9.gz
OLD_FILES+=usr/share/man/man9/uma_zfree_domain.9.gz
# 20200729: remove long expired serial drivers
OLD_FILES+=usr/share/man/man4/cy.4.gz
OLD_FILES+=usr/share/man/man4/rc.4.gz

View File

@ -1378,7 +1378,6 @@ MLINKS+=make_dev.9 destroy_dev.9 \
make_dev.9 make_dev_s.9
MLINKS+=malloc.9 free.9 \
malloc.9 malloc_domainset.9 \
malloc.9 free_domain.9 \
malloc.9 mallocarray.9 \
malloc.9 MALLOC_DECLARE.9 \
malloc.9 MALLOC_DEFINE.9 \
@ -2343,7 +2342,6 @@ MLINKS+=zone.9 uma.9 \
zone.9 uma_zdestroy.9 \
zone.9 uma_zfree.9 \
zone.9 uma_zfree_arg.9 \
zone.9 uma_zfree_domain.9 \
zone.9 uma_zfree_pcpu.9 \
zone.9 uma_zfree_pcpu_arg.9 \
zone.9 uma_zone_get_cur.9 \

View File

@ -29,7 +29,7 @@
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
.\" $FreeBSD$
.\"
.Dd October 30, 2018
.Dd August 3, 2020
.Dt MALLOC 9
.Os
.Sh NAME
@ -64,8 +64,6 @@
.In sys/domainset.h
.Ft void *
.Fn malloc_domainset "size_t size" "struct malloc_type *type" "struct domainset *ds" "int flags"
.Ft void
.Fn free_domain "void *addr" "struct malloc_type *type"
.Sh DESCRIPTION
The
.Fn malloc
@ -81,8 +79,6 @@ domain using the specified domain selection policy.
See
.Xr domainset 9
for some example policies.
Memory allocated with this function should be returned with
.Fn free_domain .
.Pp
The
.Fn mallocarray

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 4, 2020
.Dd August 3, 2020
.Dt UMA 9
.Os
.Sh NAME
@ -86,8 +86,6 @@ typedef void (*uma_free)(void *item, vm_size_t size, uint8_t pflag);
.Ft void
.Fn uma_zfree_arg "uma_zone_t zone" "void *item" "void *arg"
.Ft void
.Fn uma_zfree_domain "uma_zone_t zone" "void *item" "void *arg"
.Ft void
.Fn uma_zfree_pcpu "uma_zone_t zone" "void *item"
.Ft void
.Fn uma_zfree_pcpu_arg "uma_zone_t zone" "void *item" "void *arg"
@ -394,11 +392,6 @@ function allows callers to specify a fixed
domain to allocate from.
This uses a guaranteed but slow path in the allocator which reduces
concurrency.
The
.Fn uma_zfree_domain
function should be used to return memory allocated in this fashion.
This function infers the domain from the pointer and does not require it as an
argument.
.Pp
The
.Fn uma_zone_prealloc

View File

@ -5893,13 +5893,13 @@ pmc_cleanup(void)
KASSERT(pmc_pcpu[cpu]->pc_sb[PMC_UR] != NULL,
("[pmc,%d] Null userret cpu sample buffer cpu=%d", __LINE__,
cpu));
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_HR]->ps_callchains, M_PMC);
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_HR], M_PMC);
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_SR]->ps_callchains, M_PMC);
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_SR], M_PMC);
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_UR]->ps_callchains, M_PMC);
free_domain(pmc_pcpu[cpu]->pc_sb[PMC_UR], M_PMC);
free_domain(pmc_pcpu[cpu], M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_HR]->ps_callchains, M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_HR], M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_SR]->ps_callchains, M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_SR], M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_UR]->ps_callchains, M_PMC);
free(pmc_pcpu[cpu]->pc_sb[PMC_UR], M_PMC);
free(pmc_pcpu[cpu], M_PMC);
}
free(pmc_pcpu, M_PMC);

View File

@ -1578,7 +1578,7 @@ ioat_free_ring(struct ioat_softc *ioat, uint32_t size,
struct ioat_descriptor *ring)
{
free_domain(ring, M_IOAT);
free(ring, M_IOAT);
}
static struct ioat_descriptor *

View File

@ -410,7 +410,7 @@ iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1)
1) {
if (dmat == dmat->ctx->tag)
iommu_free_ctx(dmat->ctx);
free_domain(dmat->segments, M_IOMMU_DMAMAP);
free(dmat->segments, M_IOMMU_DMAMAP);
free(dmat, M_DEVBUF);
dmat = parent;
} else
@ -447,7 +447,7 @@ iommu_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
tag->common.nsegments, M_IOMMU_DMAMAP,
DOMAINSET_PREF(tag->common.domain), M_NOWAIT);
if (tag->segments == NULL) {
free_domain(map, M_IOMMU_DMAMAP);
free(map, M_IOMMU_DMAMAP);
*mapp = NULL;
return (ENOMEM);
}
@ -479,7 +479,7 @@ iommu_bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map1)
return (EBUSY);
}
IOMMU_DOMAIN_UNLOCK(domain);
free_domain(map, M_IOMMU_DMAMAP);
free(map, M_IOMMU_DMAMAP);
}
tag->map_count--;
return (0);
@ -537,7 +537,7 @@ iommu_bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map1)
map = (struct bus_dmamap_iommu *)map1;
if ((map->flags & BUS_DMAMAP_IOMMU_MALLOC) != 0) {
free_domain(vaddr, M_DEVBUF);
free(vaddr, M_DEVBUF);
map->flags &= ~BUS_DMAMAP_IOMMU_MALLOC;
} else {
KASSERT((map->flags & BUS_DMAMAP_IOMMU_KMEM_ALLOC) != 0,

View File

@ -819,7 +819,7 @@ nvme_qpair_destroy(struct nvme_qpair *qpair)
}
if (qpair->act_tr) {
free_domain(qpair->act_tr, M_NVME);
free(qpair->act_tr, M_NVME);
qpair->act_tr = NULL;
}
@ -828,7 +828,7 @@ nvme_qpair_destroy(struct nvme_qpair *qpair)
TAILQ_REMOVE(&qpair->free_tr, tr, tailq);
bus_dmamap_destroy(qpair->dma_tag_payload,
tr->payload_dma_map);
free_domain(tr, M_NVME);
free(tr, M_NVME);
}
if (qpair->cmd != NULL) {

View File

@ -862,40 +862,6 @@ zfree(void *addr, struct malloc_type *mtp)
malloc_type_freed(mtp, size);
}
void
free_domain(void *addr, struct malloc_type *mtp)
{
uma_zone_t zone;
uma_slab_t slab;
u_long size;
#ifdef MALLOC_DEBUG
if (free_dbg(&addr, mtp) != 0)
return;
#endif
/* free(NULL, ...) does nothing */
if (addr == NULL)
return;
vtozoneslab((vm_offset_t)addr & (~UMA_SLAB_MASK), &zone, &slab);
if (slab == NULL)
panic("free_domain: address %p(%p) has not been allocated.\n",
addr, (void *)((u_long)addr & (~UMA_SLAB_MASK)));
if (__predict_true(!malloc_large_slab(slab))) {
size = zone->uz_size;
#ifdef INVARIANTS
free_save_type(addr, mtp, size);
#endif
uma_zfree_domain(zone, addr, slab);
} else {
size = malloc_large_size(slab);
free_large(addr, size);
}
malloc_type_freed(mtp, size);
}
/*
* realloc: change the size of a memory block
*/

View File

@ -2542,7 +2542,7 @@ void
device_set_softc(device_t dev, void *softc)
{
if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC))
free_domain(dev->softc, M_BUS_SC);
free(dev->softc, M_BUS_SC);
dev->softc = softc;
if (dev->softc)
dev->flags |= DF_EXTERNALSOFTC;
@ -2559,7 +2559,7 @@ device_set_softc(device_t dev, void *softc)
void
device_free_softc(void *softc)
{
free_domain(softc, M_BUS_SC);
free(softc, M_BUS_SC);
}
/**
@ -2826,7 +2826,7 @@ device_set_driver(device_t dev, driver_t *driver)
return (0);
if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) {
free_domain(dev->softc, M_BUS_SC);
free(dev->softc, M_BUS_SC);
dev->softc = NULL;
}
device_set_desc(dev, NULL);

View File

@ -629,10 +629,7 @@ if_free_internal(struct ifnet *ifp)
free(ifp->if_description, M_IFDESCR);
free(ifp->if_hw_addr, M_IFADDR);
if (ifp->if_numa_domain == IF_NODOM)
free(ifp, M_IFNET);
else
free_domain(ifp, M_IFNET);
free(ifp, M_IFNET);
}
static void

View File

@ -180,7 +180,6 @@ void *contigmalloc_domainset(unsigned long size, struct malloc_type *type,
__malloc_like __result_use_check __alloc_size(1) __alloc_align(7);
void free(void *addr, struct malloc_type *type);
void zfree(void *addr, struct malloc_type *type);
void free_domain(void *addr, struct malloc_type *type);
void *malloc(size_t size, struct malloc_type *type, int flags) __malloc_like
__result_use_check __alloc_size(1);
/*

View File

@ -386,16 +386,6 @@ void uma_zfree_pcpu_arg(uma_zone_t zone, void *item, void *arg);
/* Use with SMR zones. */
void uma_zfree_smr(uma_zone_t zone, void *item);
/*
* Frees an item back to the specified zone's domain specific pool.
*
* Arguments:
* zone The zone the item was originally allocated out of.
* item The memory to be freed.
* arg Argument passed to the destructor
*/
void uma_zfree_domain(uma_zone_t zone, void *item, void *arg);
/*
* Frees an item back to a zone without supplying an argument
*

View File

@ -4338,24 +4338,6 @@ cache_free(uma_zone_t zone, uma_cache_t cache, void *udata, void *item,
return (true);
}
void
uma_zfree_domain(uma_zone_t zone, void *item, void *udata)
{
/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
CTR2(KTR_UMA, "uma_zfree_domain zone %s(%p)", zone->uz_name, zone);
KASSERT(curthread->td_critnest == 0 || SCHEDULER_STOPPED(),
("uma_zfree_domain: called with spinlock or critical section held"));
/* uma_zfree(..., NULL) does nothing, to match free(9). */
if (item == NULL)
return;
zone_free_item(zone, item, udata, SKIP_NONE);
}
static void
slab_free_item(uma_zone_t zone, uma_slab_t slab, void *item)
{

View File

@ -271,7 +271,7 @@ bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat)
atomic_subtract_int(&dmat->common.ref_count, 1);
if (dmat->common.ref_count == 0) {
if (dmat->segments != NULL)
free_domain(dmat->segments, M_DEVBUF);
free(dmat->segments, M_DEVBUF);
free(dmat, M_DEVBUF);
/*
* Last reference count, so
@ -387,7 +387,7 @@ bounce_bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
}
if (dmat->bounce_zone)
dmat->bounce_zone->map_count--;
free_domain(map, M_DEVBUF);
free(map, M_DEVBUF);
}
dmat->map_count--;
CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
@ -504,7 +504,7 @@ bounce_bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
if (map != NULL)
panic("bus_dmamem_free: Invalid map freed\n");
if ((dmat->bounce_flags & BUS_DMA_KMEM_ALLOC) == 0)
free_domain(vaddr, M_DEVBUF);
free(vaddr, M_DEVBUF);
else
kmem_free((vm_offset_t)vaddr, dmat->common.maxsize);
CTR3(KTR_BUSDMA, "%s: tag %p flags 0x%x", __func__, dmat,
@ -1188,7 +1188,7 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
M_DEVBUF, DOMAINSET_PREF(dmat->common.domain), M_NOWAIT,
0ul, bz->lowaddr, PAGE_SIZE, 0);
if (bpage->vaddr == 0) {
free_domain(bpage, M_DEVBUF);
free(bpage, M_DEVBUF);
break;
}
bpage->busaddr = pmap_kextract(bpage->vaddr);