aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-03-06 19:10:00 +0000
committerMark Johnston <markj@FreeBSD.org>2020-03-06 19:10:00 +0000
commitd869a17e6262d087df9934ff8731b9476a4097e1 (patch)
treea4edee7dfecd3c56e542d9eaa46e847270cd3f41 /sys
parentfffcb56f7a7b1ee6fb1a91584ba69b62d133c2d5 (diff)
downloadsrc-d869a17e6262d087df9934ff8731b9476a4097e1.tar.gz
src-d869a17e6262d087df9934ff8731b9476a4097e1.zip
Use COUNTER_U64_DEFINE_EARLY() in places where it simplifies things.
Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23978
Notes
Notes: svn path=/head/; revision=358716
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_smr.c22
-rw-r--r--sys/kern/vfs_cache.c29
-rw-r--r--sys/vm/swap_pager.c13
-rw-r--r--sys/vm/vm_object.c16
-rw-r--r--sys/vm/vm_page.c16
-rw-r--r--sys/vm/vm_reserv.c21
6 files changed, 21 insertions, 96 deletions
diff --git a/sys/kern/subr_smr.c b/sys/kern/subr_smr.c
index f5f30ac9fedb..cbbf185fee79 100644
--- a/sys/kern/subr_smr.c
+++ b/sys/kern/subr_smr.c
@@ -198,15 +198,15 @@ static uma_zone_t smr_zone;
static SYSCTL_NODE(_debug, OID_AUTO, smr, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL,
"SMR Stats");
-static counter_u64_t advance = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(advance);
SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance, CTLFLAG_RW, &advance, "");
-static counter_u64_t advance_wait = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(advance_wait);
SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance_wait, CTLFLAG_RW, &advance_wait, "");
-static counter_u64_t poll = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(poll);
SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll, CTLFLAG_RW, &poll, "");
-static counter_u64_t poll_scan = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(poll_scan);
SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_scan, CTLFLAG_RW, &poll_scan, "");
-static counter_u64_t poll_fail = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(poll_fail);
SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_fail, CTLFLAG_RW, &poll_fail, "");
/*
@@ -631,15 +631,3 @@ smr_init(void)
smr_zone = uma_zcreate("SMR CPU", sizeof(struct smr),
NULL, NULL, NULL, NULL, (CACHE_LINE_SIZE * 2) - 1, UMA_ZONE_PCPU);
}
-
-static void
-smr_init_counters(void *unused)
-{
-
- advance = counter_u64_alloc(M_WAITOK);
- advance_wait = counter_u64_alloc(M_WAITOK);
- poll = counter_u64_alloc(M_WAITOK);
- poll_scan = counter_u64_alloc(M_WAITOK);
- poll_fail = counter_u64_alloc(M_WAITOK);
-}
-SYSINIT(smr_counters, SI_SUB_CPU, SI_ORDER_ANY, smr_init_counters, NULL);
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index f581dedcde7a..da15237ab3c6 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -345,11 +345,12 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, namecache, CTLFLAG_RD, SYSCTL_NULL_INT_PTR,
*/
static SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"Name cache statistics");
-#define STATNODE_ULONG(name, descr) \
+#define STATNODE_ULONG(name, descr) \
SYSCTL_ULONG(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, descr);
-#define STATNODE_COUNTER(name, descr) \
- static counter_u64_t __read_mostly name; \
- SYSCTL_COUNTER_U64(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, descr);
+#define STATNODE_COUNTER(name, descr) \
+ static COUNTER_U64_DEFINE_EARLY(name); \
+ SYSCTL_COUNTER_U64(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, \
+ descr);
STATNODE_ULONG(numneg, "Number of negative cache entries");
STATNODE_ULONG(numcache, "Number of cache entries");
STATNODE_COUNTER(numcachehv, "Number of namecache entries with vnodes held");
@@ -1936,26 +1937,6 @@ nchinit(void *dummy __unused)
TAILQ_INIT(&ncneg_hot.nl_list);
mtx_init(&ncneg_shrink_lock, "ncnegs", NULL, MTX_DEF);
-
- numcachehv = counter_u64_alloc(M_WAITOK);
- numcalls = counter_u64_alloc(M_WAITOK);
- dothits = counter_u64_alloc(M_WAITOK);
- dotdothits = counter_u64_alloc(M_WAITOK);
- numchecks = counter_u64_alloc(M_WAITOK);
- nummiss = counter_u64_alloc(M_WAITOK);
- nummisszap = counter_u64_alloc(M_WAITOK);
- numposzaps = counter_u64_alloc(M_WAITOK);
- numposhits = counter_u64_alloc(M_WAITOK);
- numnegzaps = counter_u64_alloc(M_WAITOK);
- numneghits = counter_u64_alloc(M_WAITOK);
- numfullpathcalls = counter_u64_alloc(M_WAITOK);
- numfullpathfail1 = counter_u64_alloc(M_WAITOK);
- numfullpathfail2 = counter_u64_alloc(M_WAITOK);
- numfullpathfail4 = counter_u64_alloc(M_WAITOK);
- numfullpathfound = counter_u64_alloc(M_WAITOK);
- zap_and_exit_bucket_relock_success = counter_u64_alloc(M_WAITOK);
- numneg_evicted = counter_u64_alloc(M_WAITOK);
- shrinking_skipped = counter_u64_alloc(M_WAITOK);
}
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nchinit, NULL);
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 312c50add406..eae12d5a3953 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -177,12 +177,12 @@ static unsigned long swap_maxpages;
SYSCTL_ULONG(_vm, OID_AUTO, swap_maxpages, CTLFLAG_RD, &swap_maxpages, 0,
"Maximum amount of swap supported");
-static counter_u64_t swap_free_deferred;
+static COUNTER_U64_DEFINE_EARLY(swap_free_deferred);
SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_deferred,
CTLFLAG_RD, &swap_free_deferred,
"Number of pages that deferred freeing swap space");
-static counter_u64_t swap_free_completed;
+static COUNTER_U64_DEFINE_EARLY(swap_free_completed);
SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_completed,
CTLFLAG_RD, &swap_free_completed,
"Number of deferred frees completed");
@@ -527,15 +527,6 @@ swap_pager_init(void)
sx_init(&swdev_syscall_lock, "swsysc");
}
-static void
-swap_pager_counters(void)
-{
-
- swap_free_deferred = counter_u64_alloc(M_WAITOK);
- swap_free_completed = counter_u64_alloc(M_WAITOK);
-}
-SYSINIT(swap_counters, SI_SUB_CPU, SI_ORDER_ANY, swap_pager_counters, NULL);
-
/*
* SWAP_PAGER_SWAP_INIT() - swap pager initialization from pageout process
*
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index b974a1f9e88a..a823c55d72ef 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -153,31 +153,21 @@ struct vm_object kernel_object_store;
static SYSCTL_NODE(_vm_stats, OID_AUTO, object, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"VM object stats");
-static counter_u64_t object_collapses = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(object_collapses);
SYSCTL_COUNTER_U64(_vm_stats_object, OID_AUTO, collapses, CTLFLAG_RD,
&object_collapses,
"VM object collapses");
-static counter_u64_t object_bypasses = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(object_bypasses);
SYSCTL_COUNTER_U64(_vm_stats_object, OID_AUTO, bypasses, CTLFLAG_RD,
&object_bypasses,
"VM object bypasses");
-static counter_u64_t object_collapse_waits = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(object_collapse_waits);
SYSCTL_COUNTER_U64(_vm_stats_object, OID_AUTO, collapse_waits, CTLFLAG_RD,
&object_collapse_waits,
"Number of sleeps for collapse");
-static void
-counter_startup(void)
-{
-
- object_collapses = counter_u64_alloc(M_WAITOK);
- object_bypasses = counter_u64_alloc(M_WAITOK);
- object_collapse_waits = counter_u64_alloc(M_WAITOK);
-}
-SYSINIT(object_counters, SI_SUB_CPU, SI_ORDER_ANY, counter_startup, NULL);
-
static uma_zone_t obj_zone;
static int vm_object_zinit(void *mem, int size, int flags);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 41e7a5bb3099..5a45de6b2753 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -130,31 +130,21 @@ static int vm_pageproc_waiters;
static SYSCTL_NODE(_vm_stats, OID_AUTO, page, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"VM page statistics");
-static counter_u64_t pqstate_commit_retries = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(pqstate_commit_retries);
SYSCTL_COUNTER_U64(_vm_stats_page, OID_AUTO, pqstate_commit_retries,
CTLFLAG_RD, &pqstate_commit_retries,
"Number of failed per-page atomic queue state updates");
-static counter_u64_t queue_ops = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(queue_ops);
SYSCTL_COUNTER_U64(_vm_stats_page, OID_AUTO, queue_ops,
CTLFLAG_RD, &queue_ops,
"Number of batched queue operations");
-static counter_u64_t queue_nops = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(queue_nops);
SYSCTL_COUNTER_U64(_vm_stats_page, OID_AUTO, queue_nops,
CTLFLAG_RD, &queue_nops,
"Number of batched queue operations with no effects");
-static void
-counter_startup(void)
-{
-
- pqstate_commit_retries = counter_u64_alloc(M_WAITOK);
- queue_ops = counter_u64_alloc(M_WAITOK);
- queue_nops = counter_u64_alloc(M_WAITOK);
-}
-SYSINIT(page_counters, SI_SUB_CPU, SI_ORDER_ANY, counter_startup, NULL);
-
/*
* bogus page -- for I/O to/from partially complete buffers,
* or for paging into sparsely invalid regions.
diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
index 6023f886a034..c08895164171 100644
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -264,11 +264,11 @@ static struct vm_reserv_domain vm_rvd[MAXMEMDOM];
static SYSCTL_NODE(_vm, OID_AUTO, reserv, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"Reservation Info");
-static counter_u64_t vm_reserv_broken = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(vm_reserv_broken);
SYSCTL_COUNTER_U64(_vm_reserv, OID_AUTO, broken, CTLFLAG_RD,
&vm_reserv_broken, "Cumulative number of broken reservations");
-static counter_u64_t vm_reserv_freed = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(vm_reserv_freed);
SYSCTL_COUNTER_U64(_vm_reserv, OID_AUTO, freed, CTLFLAG_RD,
&vm_reserv_freed, "Cumulative number of freed reservations");
@@ -284,7 +284,7 @@ SYSCTL_OID(_vm_reserv, OID_AUTO, partpopq,
sysctl_vm_reserv_partpopq, "A",
"Partially populated reservation queues");
-static counter_u64_t vm_reserv_reclaimed = EARLY_COUNTER;
+static COUNTER_U64_DEFINE_EARLY(vm_reserv_reclaimed);
SYSCTL_COUNTER_U64(_vm_reserv, OID_AUTO, reclaimed, CTLFLAG_RD,
&vm_reserv_reclaimed, "Cumulative number of reclaimed reservations");
@@ -1441,21 +1441,6 @@ vm_reserv_startup(vm_offset_t *vaddr, vm_paddr_t end)
}
/*
- * Initializes the reservation management system. Specifically, initializes
- * the reservation counters.
- */
-static void
-vm_reserv_counter_init(void *unused)
-{
-
- vm_reserv_freed = counter_u64_alloc(M_WAITOK);
- vm_reserv_broken = counter_u64_alloc(M_WAITOK);
- vm_reserv_reclaimed = counter_u64_alloc(M_WAITOK);
-}
-SYSINIT(vm_reserv_counter_init, SI_SUB_CPU, SI_ORDER_ANY,
- vm_reserv_counter_init, NULL);
-
-/*
* Returns the superpage containing the given page.
*/
vm_page_t