aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2014-02-10 19:59:46 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2014-02-10 19:59:46 +0000
commit49fef6a202a5c2f4113940f87de5d8765897ab3b (patch)
tree4240e3275181ee53a1a8927c8ca9199e8ea5e403 /sys
parentf947570e3532e0545146fa8abd7d4366151eb282 (diff)
downloadsrc-49fef6a202a5c2f4113940f87de5d8765897ab3b.tar.gz
src-49fef6a202a5c2f4113940f87de5d8765897ab3b.zip
Create two public UMA_ZONE_PCPU zones: 64 bit sized and pointer sized.
Sponsored by: Nginx, Inc.
Notes
Notes: svn path=/head/; revision=261725
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_counter.c15
-rw-r--r--sys/kern/subr_pcpu.c25
-rw-r--r--sys/vm/uma.h6
3 files changed, 33 insertions, 13 deletions
diff --git a/sys/kern/subr_counter.c b/sys/kern/subr_counter.c
index b3ddc7adc35f..ea2759c959c8 100644
--- a/sys/kern/subr_counter.c
+++ b/sys/kern/subr_counter.c
@@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$");
#define IN_SUBR_COUNTER_C
#include <sys/counter.h>
-static uma_zone_t uint64_pcpu_zone;
-
void
counter_u64_zero(counter_u64_t c)
{
@@ -62,7 +60,7 @@ counter_u64_alloc(int flags)
{
counter_u64_t r;
- r = uma_zalloc(uint64_pcpu_zone, flags);
+ r = uma_zalloc(pcpu_zone_64, flags);
if (r != NULL)
counter_u64_zero(r);
@@ -73,7 +71,7 @@ void
counter_u64_free(counter_u64_t c)
{
- uma_zfree(uint64_pcpu_zone, c);
+ uma_zfree(pcpu_zone_64, c);
}
int
@@ -96,12 +94,3 @@ sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS)
return (0);
}
-
-static void
-counter_startup(void)
-{
-
- uint64_pcpu_zone = uma_zcreate("uint64 pcpu", sizeof(uint64_t),
- NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
-}
-SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_ANY, counter_startup, NULL);
diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c
index 505a4dfeff49..a01f67aba1e6 100644
--- a/sys/kern/subr_pcpu.c
+++ b/sys/kern/subr_pcpu.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/smp.h>
#include <sys/sx.h>
+#include <vm/uma.h>
#include <ddb/ddb.h>
static MALLOC_DEFINE(M_PCPU, "Per-cpu", "Per-cpu resource accouting.");
@@ -127,6 +128,30 @@ dpcpu_startup(void *dummy __unused)
SYSINIT(dpcpu, SI_SUB_KLD, SI_ORDER_FIRST, dpcpu_startup, 0);
/*
+ * UMA_PCPU_ZONE zones, that are available for all kernel
+ * consumers. Right now 64 bit zone is used for counter(9)
+ * and pointer zone is used by flowtable.
+ */
+
+uma_zone_t pcpu_zone_64;
+uma_zone_t pcpu_zone_ptr;
+
+static void
+pcpu_zones_startup(void)
+{
+
+ pcpu_zone_64 = uma_zcreate("64 pcpu", sizeof(uint64_t),
+ NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
+
+ if (sizeof(uint64_t) == sizeof(void *))
+ pcpu_zone_ptr = pcpu_zone_64;
+ else
+ pcpu_zone_ptr = uma_zcreate("ptr pcpu", sizeof(void *),
+ NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU);
+}
+SYSINIT(pcpu_zones, SI_SUB_KMEM, SI_ORDER_ANY, pcpu_zones_startup, NULL);
+
+/*
* First-fit extent based allocator for allocating space in the per-cpu
* region reserved for modules. This is only intended for use by the
* kernel linkers to place module linker sets.
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 2de9a47851ea..5012d98fbdc3 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -636,6 +636,12 @@ int uma_zone_exhausted(uma_zone_t zone);
int uma_zone_exhausted_nolock(uma_zone_t zone);
/*
+ * Common UMA_ZONE_PCPU zones.
+ */
+extern uma_zone_t pcpu_zone_64;
+extern uma_zone_t pcpu_zone_ptr;
+
+/*
* Exported statistics structures to be used by user space monitoring tools.
* Statistics stream consists of a uma_stream_header, followed by a series of
* alternative uma_type_header and uma_type_stat structures.