Rationalize per-cpu zones.

The 2 provided zones had inconsistent naming between each other
("int" and "64") and other allocator zones (which use bytes).

Follow malloc by naming them "pcpu-" + size in bytes.

This is a step towards replacing ad-hoc per-cpu zones with
general slabs.
This commit is contained in:
Mateusz Guzik 2020-11-05 15:08:56 +00:00
parent 9fe896ec79
commit 2dee296a3d
6 changed files with 22 additions and 24 deletions

View File

@ -890,8 +890,8 @@ rms_init(struct rmslock *rms, const char *name)
rms->writers = 0;
rms->readers = 0;
mtx_init(&rms->mtx, name, NULL, MTX_DEF | MTX_NEW);
rms->readers_pcpu = uma_zalloc_pcpu(pcpu_zone_int, M_WAITOK | M_ZERO);
rms->readers_influx = uma_zalloc_pcpu(pcpu_zone_int, M_WAITOK | M_ZERO);
rms->readers_pcpu = uma_zalloc_pcpu(pcpu_zone_4, M_WAITOK | M_ZERO);
rms->readers_influx = uma_zalloc_pcpu(pcpu_zone_4, M_WAITOK | M_ZERO);
}
void
@ -901,8 +901,8 @@ rms_destroy(struct rmslock *rms)
MPASS(rms->writers == 0);
MPASS(rms->readers == 0);
mtx_destroy(&rms->mtx);
uma_zfree_pcpu(pcpu_zone_int, rms->readers_pcpu);
uma_zfree_pcpu(pcpu_zone_int, rms->readers_influx);
uma_zfree_pcpu(pcpu_zone_4, rms->readers_pcpu);
uma_zfree_pcpu(pcpu_zone_4, rms->readers_influx);
}
static void __noinline

View File

@ -61,14 +61,14 @@ counter_u64_t
counter_u64_alloc(int flags)
{
return (uma_zalloc_pcpu(pcpu_zone_64, flags | M_ZERO));
return (uma_zalloc_pcpu(pcpu_zone_8, flags | M_ZERO));
}
void
counter_u64_free(counter_u64_t c)
{
uma_zfree_pcpu(pcpu_zone_64, c);
uma_zfree_pcpu(pcpu_zone_8, c);
}
int

View File

@ -131,21 +131,19 @@ dpcpu_startup(void *dummy __unused)
SYSINIT(dpcpu, SI_SUB_KLD, SI_ORDER_FIRST, dpcpu_startup, NULL);
/*
* UMA_PCPU_ZONE zones, that are available for all kernel
* consumers. Right now 64 bit zone is used for counter(9)
* and int zone is used for mount point counters.
* UMA_ZONE_PCPU zones for general kernel use.
*/
uma_zone_t pcpu_zone_int;
uma_zone_t pcpu_zone_64;
uma_zone_t pcpu_zone_4;
uma_zone_t pcpu_zone_8;
static void
pcpu_zones_startup(void)
{
pcpu_zone_int = uma_zcreate("int pcpu", sizeof(int),
pcpu_zone_4 = uma_zcreate("pcpu-4", sizeof(uint32_t),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
pcpu_zone_64 = uma_zcreate("64 pcpu", sizeof(uint64_t),
pcpu_zone_8 = uma_zcreate("pcpu-8", sizeof(uint64_t),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
}
SYSINIT(pcpu_zones, SI_SUB_COUNTER, SI_ORDER_FIRST, pcpu_zones_startup, NULL);

View File

@ -127,13 +127,13 @@ mount_init(void *mem, int size, int flags)
mtx_init(&mp->mnt_mtx, "struct mount mtx", NULL, MTX_DEF);
mtx_init(&mp->mnt_listmtx, "struct mount vlist mtx", NULL, MTX_DEF);
lockinit(&mp->mnt_explock, PVFS, "explock", 0, 0);
mp->mnt_thread_in_ops_pcpu = uma_zalloc_pcpu(pcpu_zone_int,
mp->mnt_thread_in_ops_pcpu = uma_zalloc_pcpu(pcpu_zone_4,
M_WAITOK | M_ZERO);
mp->mnt_ref_pcpu = uma_zalloc_pcpu(pcpu_zone_int,
mp->mnt_ref_pcpu = uma_zalloc_pcpu(pcpu_zone_4,
M_WAITOK | M_ZERO);
mp->mnt_lockref_pcpu = uma_zalloc_pcpu(pcpu_zone_int,
mp->mnt_lockref_pcpu = uma_zalloc_pcpu(pcpu_zone_4,
M_WAITOK | M_ZERO);
mp->mnt_writeopcount_pcpu = uma_zalloc_pcpu(pcpu_zone_int,
mp->mnt_writeopcount_pcpu = uma_zalloc_pcpu(pcpu_zone_4,
M_WAITOK | M_ZERO);
mp->mnt_ref = 0;
mp->mnt_vfs_ops = 1;
@ -147,10 +147,10 @@ mount_fini(void *mem, int size)
struct mount *mp;
mp = (struct mount *)mem;
uma_zfree_pcpu(pcpu_zone_int, mp->mnt_writeopcount_pcpu);
uma_zfree_pcpu(pcpu_zone_int, mp->mnt_lockref_pcpu);
uma_zfree_pcpu(pcpu_zone_int, mp->mnt_ref_pcpu);
uma_zfree_pcpu(pcpu_zone_int, mp->mnt_thread_in_ops_pcpu);
uma_zfree_pcpu(pcpu_zone_4, mp->mnt_writeopcount_pcpu);
uma_zfree_pcpu(pcpu_zone_4, mp->mnt_lockref_pcpu);
uma_zfree_pcpu(pcpu_zone_4, mp->mnt_ref_pcpu);
uma_zfree_pcpu(pcpu_zone_4, mp->mnt_thread_in_ops_pcpu);
lockdestroy(&mp->mnt_explock);
mtx_destroy(&mp->mnt_listmtx);
mtx_destroy(&mp->mnt_mtx);

View File

@ -60,7 +60,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1300125 /* Master, propagated to newvers */
#define __FreeBSD_version 1300126 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,

View File

@ -666,8 +666,8 @@ size_t uma_zone_memory(uma_zone_t zone);
/*
* Common UMA_ZONE_PCPU zones.
*/
extern uma_zone_t pcpu_zone_int;
extern uma_zone_t pcpu_zone_64;
extern uma_zone_t pcpu_zone_4;
extern uma_zone_t pcpu_zone_8;
/*
* Exported statistics structures to be used by user space monitoring tools.