Date: Fri, 7 Feb 2020 16:22:02 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357658 - head/sys/amd64/include Message-ID: <202002071622.017GM2UI006077@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Fri Feb 7 16:22:02 2020 New Revision: 357658 URL: https://svnweb.freebsd.org/changeset/base/357658 Log: amd64: clean up counter(9) - stop open-coding access to per-cpu data, use common macros instead - consistently use counter_t type where appropriate Modified: head/sys/amd64/include/counter.h Modified: head/sys/amd64/include/counter.h ============================================================================== --- head/sys/amd64/include/counter.h Fri Feb 7 15:50:47 2020 (r357657) +++ head/sys/amd64/include/counter.h Fri Feb 7 16:22:02 2020 (r357658) @@ -40,21 +40,21 @@ #ifdef IN_SUBR_COUNTER_C static inline uint64_t -counter_u64_read_one(uint64_t *p, int cpu) +counter_u64_read_one(counter_u64_t c, int cpu) { - return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); + return (*zpcpu_get_cpu(c, cpu)); } static inline uint64_t -counter_u64_fetch_inline(uint64_t *p) +counter_u64_fetch_inline(uint64_t *c) { uint64_t r; - int i; + int cpu; r = 0; - CPU_FOREACH(i) - r += counter_u64_read_one((uint64_t *)p, i); + CPU_FOREACH(cpu) + r += counter_u64_read_one(c, cpu); return (r); } @@ -62,9 +62,10 @@ counter_u64_fetch_inline(uint64_t *p) static void counter_u64_zero_one_cpu(void *arg) { + counter_u64_t c; - *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * - PCPU_GET(cpuid))) = 0; + c = arg; + *(zpcpu_get(c)) = 0; } static inline void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002071622.017GM2UI006077>