Module Name:    src
Committed By:   riastradh
Date:           Thu Mar 24 12:58:56 UTC 2022

Modified Files:
        src/sys/kern: kern_entropy.c

Log Message:
entropy(9): Call entropy_softintr while bound to CPU.

It looks like We tripped on the new assertion in entropy_account_cpu
when there was pending entropy on cpu0 running lwp0 when xc_broadcast
ran -- since xc_broadcast calls the function directly rather than
calling it through softint_schedule, it's not called via the softint
lwp which would satisfy the assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/kern_entropy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.53 src/sys/kern/kern_entropy.c:1.54
--- src/sys/kern/kern_entropy.c:1.53	Wed Mar 23 23:20:52 2022
+++ src/sys/kern/kern_entropy.c	Thu Mar 24 12:58:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.53 2022/03/23 23:20:52 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.54 2022/03/24 12:58:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.53 2022/03/23 23:20:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.54 2022/03/24 12:58:56 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -413,8 +413,20 @@ entropy_init(void)
 static void
 entropy_init_late_cpu(void *a, void *b)
 {
+	int bound;
 
+	/*
+	 * We're not necessarily in a softint lwp here (xc_broadcast
+	 * triggers softint on other CPUs, but calls directly on this
+	 * CPU), so explicitly bind to the current CPU to invoke the
+	 * softintr -- this lets us have a simpler assertion in
+	 * entropy_account_cpu.  Not necessary to avoid migration
+	 * because xc_broadcast disables kpreemption anyway, but it
+	 * doesn't hurt.
+	 */
+	bound = curlwp_bind();
 	entropy_softintr(NULL);
+	curlwp_bindx(bound);
 }
 
 /*

Reply via email to