Deleted Added
full compact
counter.h (252434) counter.h (302372)
1/*-
2 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/i386/include/counter.h 252434 2013-07-01 02:48:27Z kib $
26 * $FreeBSD: head/sys/i386/include/counter.h 302372 2016-07-06 14:09:49Z nwhitehorn $
27 */
28
29#ifndef __MACHINE_COUNTER_H__
30#define __MACHINE_COUNTER_H__
31
32#include <sys/pcpu.h>
33#ifdef INVARIANTS
34#include <sys/proc.h>

--- 58 unchanged lines hidden (view full) ---

93 if ((cpu_feature & CPUID_CX8) == 0) {
94 /*
95 * The machines without cmpxchg8b are not SMP.
96 * Disabling the preemption provides atomicity of the
97 * counter reading, since update is done in the
98 * critical section as well.
99 */
100 critical_enter();
27 */
28
29#ifndef __MACHINE_COUNTER_H__
30#define __MACHINE_COUNTER_H__
31
32#include <sys/pcpu.h>
33#ifdef INVARIANTS
34#include <sys/proc.h>

--- 58 unchanged lines hidden (view full) ---

93 if ((cpu_feature & CPUID_CX8) == 0) {
94 /*
95 * The machines without cmpxchg8b are not SMP.
96 * Disabling the preemption provides atomicity of the
97 * counter reading, since update is done in the
98 * critical section as well.
99 */
100 critical_enter();
101 for (i = 0; i < mp_ncpus; i++) {
101 CPU_FOREACH(i) {
102 res += *(uint64_t *)((char *)p +
103 sizeof(struct pcpu) * i);
104 }
105 critical_exit();
106 } else {
102 res += *(uint64_t *)((char *)p +
103 sizeof(struct pcpu) * i);
104 }
105 critical_exit();
106 } else {
107 for (i = 0; i < mp_ncpus; i++)
107 CPU_FOREACH(i)
108 res += counter_u64_read_one_8b((uint64_t *)((char *)p +
109 sizeof(struct pcpu) * i));
110 }
111 return (res);
112}
113
114static inline void
115counter_u64_zero_one_8b(uint64_t *p)

--- 23 unchanged lines hidden (view full) ---

139
140static inline void
141counter_u64_zero_inline(counter_u64_t c)
142{
143 int i;
144
145 if ((cpu_feature & CPUID_CX8) == 0) {
146 critical_enter();
108 res += counter_u64_read_one_8b((uint64_t *)((char *)p +
109 sizeof(struct pcpu) * i));
110 }
111 return (res);
112}
113
114static inline void
115counter_u64_zero_one_8b(uint64_t *p)

--- 23 unchanged lines hidden (view full) ---

139
140static inline void
141counter_u64_zero_inline(counter_u64_t c)
142{
143 int i;
144
145 if ((cpu_feature & CPUID_CX8) == 0) {
146 critical_enter();
147 for (i = 0; i < mp_ncpus; i++)
147 CPU_FOREACH(i)
148 *(uint64_t *)((char *)c + sizeof(struct pcpu) * i) = 0;
149 critical_exit();
150 } else {
151 smp_rendezvous(smp_no_rendevous_barrier,
152 counter_u64_zero_one_cpu, smp_no_rendevous_barrier, c);
153 }
154}
155#endif

--- 23 unchanged lines hidden ---
148 *(uint64_t *)((char *)c + sizeof(struct pcpu) * i) = 0;
149 critical_exit();
150 } else {
151 smp_rendezvous(smp_no_rendevous_barrier,
152 counter_u64_zero_one_cpu, smp_no_rendevous_barrier, c);
153 }
154}
155#endif

--- 23 unchanged lines hidden ---