From c29824db05b9b69bf1fbb2868bb2fe3c3af16b3a Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 8 Mar 2002 18:55:59 +0000 Subject: [PATCH] Read KTR_CPU into a temporary variable so that we use a consistent value for both the cpumask check and the cpu entry field w/o needing to use a critical section. --- sys/kern/kern_ktr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 9896ed8e55f3..0686aa2fdec9 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -120,8 +120,8 @@ ktr_tracepoint(u_int mask, const char *format, u_long arg1, u_long arg2, { struct ktr_entry *entry; int newindex, saveindex; - critical_t savecrit; struct thread *td; + int cpu; #ifdef KTR_EXTEND va_list ap; #endif @@ -133,19 +133,16 @@ ktr_tracepoint(u_int mask, const char *format, u_long arg1, u_long arg2, td = curthread; if (td->td_inktr) return; - savecrit = cpu_critical_enter(); - if (((1 << KTR_CPU) & ktr_cpumask) == 0) { - cpu_critical_exit(savecrit); + cpu = KTR_CPU; + if (((1 << cpu) & ktr_cpumask) == 0) return; - } td->td_inktr++; do { saveindex = ktr_idx; newindex = (saveindex + 1) & (KTR_ENTRIES - 1); } while (atomic_cmpset_rel_int(&ktr_idx, saveindex, newindex) == 0); entry = &ktr_buf[saveindex]; - entry->ktr_cpu = KTR_CPU; - cpu_critical_exit(savecrit); + entry->ktr_cpu = cpu; nanotime(&entry->ktr_tv); #ifdef KTR_EXTEND entry->ktr_filename = filename;