Author: mjg
Date: Thu Nov  5 15:08:56 2020
New Revision: 367384
URL: https://svnweb.freebsd.org/changeset/base/367384

Log:
  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.

Modified:
  head/sys/kern/kern_rmlock.c
  head/sys/kern/subr_counter.c
  head/sys/kern/subr_pcpu.c
  head/sys/kern/vfs_mount.c
  head/sys/sys/param.h
  head/sys/vm/uma.h

Modified: head/sys/kern/kern_rmlock.c
==============================================================================
--- head/sys/kern/kern_rmlock.c Thu Nov  5 14:15:50 2020        (r367383)
+++ head/sys/kern/kern_rmlock.c Thu Nov  5 15:08:56 2020        (r367384)
@@ -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

Modified: head/sys/kern/subr_counter.c
==============================================================================
--- head/sys/kern/subr_counter.c        Thu Nov  5 14:15:50 2020        
(r367383)
+++ head/sys/kern/subr_counter.c        Thu Nov  5 15:08:56 2020        
(r367384)
@@ -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

Modified: head/sys/kern/subr_pcpu.c
==============================================================================
--- head/sys/kern/subr_pcpu.c   Thu Nov  5 14:15:50 2020        (r367383)
+++ head/sys/kern/subr_pcpu.c   Thu Nov  5 15:08:56 2020        (r367384)
@@ -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);

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c   Thu Nov  5 14:15:50 2020        (r367383)
+++ head/sys/kern/vfs_mount.c   Thu Nov  5 15:08:56 2020        (r367384)
@@ -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);

Modified: head/sys/sys/param.h
==============================================================================
--- head/sys/sys/param.h        Thu Nov  5 14:15:50 2020        (r367383)
+++ head/sys/sys/param.h        Thu Nov  5 15:08:56 2020        (r367384)
@@ -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,

Modified: head/sys/vm/uma.h
==============================================================================
--- head/sys/vm/uma.h   Thu Nov  5 14:15:50 2020        (r367383)
+++ head/sys/vm/uma.h   Thu Nov  5 15:08:56 2020        (r367384)
@@ -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.
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to