Date: Sun, 17 Feb 2019 10:01:42 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344230 - stable/11/sys/i386/include Message-ID: <201902171001.x1HA1gYa033429@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Feb 17 10:01:42 2019 New Revision: 344230 URL: https://svnweb.freebsd.org/changeset/base/344230 Log: MFC r343723: i386: Do not ever store to other-CPU counter64 slot. Modified: stable/11/sys/i386/include/counter.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/include/counter.h ============================================================================== --- stable/11/sys/i386/include/counter.h Sun Feb 17 09:57:43 2019 (r344229) +++ stable/11/sys/i386/include/counter.h Sun Feb 17 10:01:42 2019 (r344230) @@ -68,7 +68,12 @@ counter_64_inc_8b(uint64_t *p, int64_t inc) } #ifdef IN_SUBR_COUNTER_C -static inline uint64_t +struct counter_u64_fetch_cx8_arg { + uint64_t res; + uint64_t *p; +}; + +static uint64_t counter_u64_read_one_8b(uint64_t *p) { uint32_t res_lo, res_high; @@ -83,9 +88,22 @@ counter_u64_read_one_8b(uint64_t *p) return (res_lo + ((uint64_t)res_high << 32)); } +static void +counter_u64_fetch_cx8_one(void *arg1) +{ + struct counter_u64_fetch_cx8_arg *arg; + uint64_t val; + + arg = arg1; + val = counter_u64_read_one_8b((uint64_t *)((char *)arg->p + + sizeof(struct pcpu) * PCPU_GET(cpuid))); + atomic_add_64(&arg->res, val); +} + static inline uint64_t counter_u64_fetch_inline(uint64_t *p) { + struct counter_u64_fetch_cx8_arg arg; uint64_t res; int i; @@ -104,9 +122,10 @@ counter_u64_fetch_inline(uint64_t *p) } critical_exit(); } else { - CPU_FOREACH(i) - res += counter_u64_read_one_8b((uint64_t *)((char *)p + - sizeof(struct pcpu) * i)); + arg.p = p; + arg.res = 0; + smp_rendezvous(NULL, counter_u64_fetch_cx8_one, NULL, &arg); + res = arg.res; } return (res); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902171001.x1HA1gYa033429>