summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/kern/subr_counter.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/kern/subr_counter.c')
-rw-r--r--freebsd/sys/kern/subr_counter.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/freebsd/sys/kern/subr_counter.c b/freebsd/sys/kern/subr_counter.c
index e4c98fae..66cda02b 100644
--- a/freebsd/sys/kern/subr_counter.c
+++ b/freebsd/sys/kern/subr_counter.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#define IN_SUBR_COUNTER_C
#include <sys/counter.h>
-
+
void
counter_u64_zero(counter_u64_t c)
{
@@ -62,20 +62,15 @@ counter_u64_fetch(counter_u64_t c)
counter_u64_t
counter_u64_alloc(int flags)
{
- counter_u64_t r;
-
- r = uma_zalloc(pcpu_zone_64, flags);
- if (r != NULL)
- counter_u64_zero(r);
- return (r);
+ return (uma_zalloc_pcpu(pcpu_zone_64, flags | M_ZERO));
}
void
counter_u64_free(counter_u64_t c)
{
- uma_zfree(pcpu_zone_64, c);
+ uma_zfree_pcpu(pcpu_zone_64, c);
}
int
@@ -142,7 +137,7 @@ counter_ratecheck(struct counter_rate *cr, int64_t limit)
val = cr->cr_over;
now = ticks;
- if (now - cr->cr_ticks >= hz) {
+ if ((u_int)(now - cr->cr_ticks) >= hz) {
/*
* Time to clear the structure, we are in the next second.
* First try unlocked read, and then proceed with atomic.
@@ -153,7 +148,7 @@ counter_ratecheck(struct counter_rate *cr, int64_t limit)
* Check if other thread has just went through the
* reset sequence before us.
*/
- if (now - cr->cr_ticks >= hz) {
+ if ((u_int)(now - cr->cr_ticks) >= hz) {
val = counter_u64_fetch(cr->cr_rate);
counter_u64_zero(cr->cr_rate);
cr->cr_over = 0;