svn commit: r341722 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Sat Dec 8 06:34:14 UTC 2018


Author: mjg
Date: Sat Dec  8 06:34:12 2018
New Revision: 341722
URL: https://svnweb.freebsd.org/changeset/base/341722

Log:
  proc: postpone proc unlock until after reporting with kqueue
  
  kqueue would always relock immediately afterwards.
  
  While here drop the NULL check for list itself. The list is
  always allocated.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/kern_event.c
  head/sys/kern/kern_fork.c

Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c	Sat Dec  8 06:31:43 2018	(r341721)
+++ head/sys/kern/kern_event.c	Sat Dec  8 06:34:12 2018	(r341722)
@@ -533,11 +533,12 @@ knote_fork(struct knlist *list, int pid)
 	struct kevent kev;
 	int error;
 
-	if (list == NULL)
+	MPASS(list != NULL);
+	KNL_ASSERT_LOCKED(list);
+	if (SLIST_EMPTY(&list->kl_list))
 		return;
 
 	memset(&kev, 0, sizeof(kev));
-	list->kl_lock(list->kl_lockarg);
 	SLIST_FOREACH(kn, &list->kl_list, kn_selnext) {
 		kq = kn->kn_kq;
 		KQ_LOCK(kq);
@@ -606,7 +607,6 @@ knote_fork(struct knlist *list, int pid)
 		kn_leave_flux(kn);
 		KQ_UNLOCK_FLUX(kq);
 	}
-	list->kl_unlock(list->kl_lockarg);
 }
 
 /*

Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c	Sat Dec  8 06:31:43 2018	(r341721)
+++ head/sys/kern/kern_fork.c	Sat Dec  8 06:34:12 2018	(r341722)
@@ -686,15 +686,15 @@ do_fork(struct thread *td, struct fork_req *fr, struct
 	PROC_UNLOCK(p2);
 
 	/*
-	 * Now can be swapped.
+	 * Tell any interested parties about the new process.
 	 */
-	_PRELE(p1);
-	PROC_UNLOCK(p1);
+	knote_fork(p1->p_klist, p2->p_pid);
 
 	/*
-	 * Tell any interested parties about the new process.
+	 * Now can be swapped.
 	 */
-	knote_fork(p1->p_klist, p2->p_pid);
+	_PRELE(p1);
+	PROC_UNLOCK(p1);
 	SDT_PROBE3(proc, , , create, p2, p1, fr->fr_flags);
 
 	if (fr->fr_flags & RFPROCDESC) {


More information about the svn-src-head mailing list