From owner-p4-projects@FreeBSD.ORG Sat Sep 15 21:04:48 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A117316A420; Sat, 15 Sep 2007 21:04:48 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6912F16A419 for ; Sat, 15 Sep 2007 21:04:48 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 463EA13C45E for ; Sat, 15 Sep 2007 21:04:48 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8FL4mK9013955 for ; Sat, 15 Sep 2007 21:04:48 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8FL4lV5013952 for perforce@freebsd.org; Sat, 15 Sep 2007 21:04:47 GMT (envelope-from kmacy@freebsd.org) Date: Sat, 15 Sep 2007 21:04:47 GMT Message-Id: <200709152104.l8FL4lV5013952@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 126448 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2007 21:04:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=126448 Change 126448 by kmacy@kmacy_home:ethng on 2007/09/15 21:04:17 inline critical_{enter, exit} Affected files ... .. //depot/projects/ethng/src/sys/amd64/amd64/local_apic.c#3 edit .. //depot/projects/ethng/src/sys/sys/proc.h#2 edit .. //depot/projects/ethng/src/sys/sys/systm.h#2 edit Differences ... ==== //depot/projects/ethng/src/sys/amd64/amd64/local_apic.c#3 (text+ko) ==== @@ -46,6 +46,7 @@ #include #include #include +#include #include #include ==== //depot/projects/ethng/src/sys/sys/proc.h#2 (text+ko) ==== @@ -913,6 +913,46 @@ struct thread *thread_find(struct proc *p, lwpid_t tid); void thr_exit1(void); +#include +#include +#include "opt_sched.h" + +/* + * Kernel thread preemption implementation. Critical sections mark + * regions of code in which preemptions are not allowed. + */ +static __inline void +critical_enter(void) +{ + struct thread *td; + + td = curthread; + td->td_critnest++; + CTR4(KTR_CRITICAL, "critical_enter by thread %p (%ld, %s) to %d", td, + (long)td->td_proc->p_pid, td->td_proc->p_comm, td->td_critnest); +} + +static __inline void +critical_exit(void) +{ + struct thread *td; + + td = curthread; + KASSERT(td->td_critnest != 0, + ("critical_exit: td_critnest == 0")); +#ifdef PREEMPTION + if (td->td_critnest == 1) { + td->td_critnest = 0; + if (td->td_owepreempt) + critical_exit_owepreempt(td); + } else +#endif + td->td_critnest--; + + CTR4(KTR_CRITICAL, "critical_exit by thread %p (%ld, %s) to %d", td, + (long)td->td_proc->p_pid, td->td_proc->p_comm, td->td_critnest); +} + #endif /* _KERNEL */ #endif /* !_SYS_PROC_H_ */ ==== //depot/projects/ethng/src/sys/sys/systm.h#2 (text+ko) ==== @@ -151,8 +151,7 @@ void cpu_boot(int); void cpu_rootconf(void); -void critical_enter(void); -void critical_exit(void); +void critical_exit_owepreempt(struct thread *td); void init_param1(void); void init_param2(long physpages); void init_param3(long kmempages); @@ -184,6 +183,7 @@ #define HD_OMIT_HEX (1 << 17) #define HD_OMIT_CHARS (1 << 18) + #define ovbcopy(f, t, l) bcopy((f), (t), (l)) void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2); void bzero(void *buf, size_t len) __nonnull(1);