counter.h (83ef78be9591275896b8a0bda1d2155becca3f3c) | counter.h (ab3059a8e7f382cff93dbe4d1b082adf62f4d849) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 90 unchanged lines hidden (view full) --- 99 * The machines without cmpxchg8b are not SMP. 100 * Disabling the preemption provides atomicity of the 101 * counter reading, since update is done in the 102 * critical section as well. 103 */ 104 critical_enter(); 105 CPU_FOREACH(i) { 106 res += *(uint64_t *)((char *)p + | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 90 unchanged lines hidden (view full) --- 99 * The machines without cmpxchg8b are not SMP. 100 * Disabling the preemption provides atomicity of the 101 * counter reading, since update is done in the 102 * critical section as well. 103 */ 104 critical_enter(); 105 CPU_FOREACH(i) { 106 res += *(uint64_t *)((char *)p + |
107 sizeof(struct pcpu) * i); | 107 UMA_PCPU_ALLOC_SIZE * i); |
108 } 109 critical_exit(); 110 } else { 111 CPU_FOREACH(i) 112 res += counter_u64_read_one_8b((uint64_t *)((char *)p + | 108 } 109 critical_exit(); 110 } else { 111 CPU_FOREACH(i) 112 res += counter_u64_read_one_8b((uint64_t *)((char *)p + |
113 sizeof(struct pcpu) * i)); | 113 UMA_PCPU_ALLOC_SIZE * i)); |
114 } 115 return (res); 116} 117 118static inline void 119counter_u64_zero_one_8b(uint64_t *p) 120{ 121 --- 10 unchanged lines hidden (view full) --- 132 : "memory", "cc", "eax", "edx", "ebx", "ecx"); 133} 134 135static void 136counter_u64_zero_one_cpu(void *arg) 137{ 138 uint64_t *p; 139 | 114 } 115 return (res); 116} 117 118static inline void 119counter_u64_zero_one_8b(uint64_t *p) 120{ 121 --- 10 unchanged lines hidden (view full) --- 132 : "memory", "cc", "eax", "edx", "ebx", "ecx"); 133} 134 135static void 136counter_u64_zero_one_cpu(void *arg) 137{ 138 uint64_t *p; 139 |
140 p = (uint64_t *)((char *)arg + sizeof(struct pcpu) * PCPU_GET(cpuid)); | 140 p = (uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * PCPU_GET(cpuid)); |
141 counter_u64_zero_one_8b(p); 142} 143 144static inline void 145counter_u64_zero_inline(counter_u64_t c) 146{ 147 int i; 148 149 if ((cpu_feature & CPUID_CX8) == 0) { 150 critical_enter(); 151 CPU_FOREACH(i) | 141 counter_u64_zero_one_8b(p); 142} 143 144static inline void 145counter_u64_zero_inline(counter_u64_t c) 146{ 147 int i; 148 149 if ((cpu_feature & CPUID_CX8) == 0) { 150 critical_enter(); 151 CPU_FOREACH(i) |
152 *(uint64_t *)((char *)c + sizeof(struct pcpu) * i) = 0; | 152 *(uint64_t *)((char *)c + UMA_PCPU_ALLOC_SIZE * i) = 0; |
153 critical_exit(); 154 } else { 155 smp_rendezvous(smp_no_rendezvous_barrier, 156 counter_u64_zero_one_cpu, smp_no_rendezvous_barrier, c); 157 } 158} 159#endif 160 --- 22 unchanged lines hidden --- | 153 critical_exit(); 154 } else { 155 smp_rendezvous(smp_no_rendezvous_barrier, 156 counter_u64_zero_one_cpu, smp_no_rendezvous_barrier, c); 157 } 158} 159#endif 160 --- 22 unchanged lines hidden --- |