PERFORCE change 126448 for review

Kip Macy kmacy at FreeBSD.org
Sat Sep 15 14:04:48 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=126448

Change 126448 by kmacy at 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 <sys/mutex.h>
 #include <sys/pcpu.h>
 #include <sys/smp.h>
+#include <sys/proc.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>

==== //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 <sys/ktr.h>
+#include <sys/systm.h>
+#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);


More information about the p4-projects mailing list