Module Name: src
Committed By: riastradh
Date: Fri Apr 14 16:51:46 UTC 2023
Modified Files:
src/sys/kern: subr_pserialize.c
Log Message:
pserialize(9): Fix bug in recent micro-optimization.
curcpu() is always a valid struct cpu_info pointer, but curlwp->l_cpu
is not necessarily -- early at boot on some architectures (like x86,
apparently) it may be null.
Not clear that l->l_cpu is always a cost win over curcpu(): on some
architectures curcpu() is basically a macro for curlwp->l_cpu, while
on others it is a fixed VA. So let's use the one that always works
instead of the one that's sometimes cheaper and sometimes crashier.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/subr_pserialize.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/subr_pserialize.c
diff -u src/sys/kern/subr_pserialize.c:1.21 src/sys/kern/subr_pserialize.c:1.22
--- src/sys/kern/subr_pserialize.c:1.21 Sun Apr 9 08:28:24 2023
+++ src/sys/kern/subr_pserialize.c Fri Apr 14 16:51:46 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pserialize.c,v 1.21 2023/04/09 08:28:24 riastradh Exp $ */
+/* $NetBSD: subr_pserialize.c,v 1.22 2023/04/14 16:51:46 riastradh Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.21 2023/04/09 08:28:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.22 2023/04/14 16:51:46 riastradh Exp $");
#include <sys/param.h>
@@ -180,7 +180,7 @@ pserialize_not_in_read_section(void)
ncsw = l->l_ncsw;
__insn_barrier();
- notin = __predict_true(l->l_cpu->ci_psz_read_depth == 0);
+ notin = __predict_true(curcpu()->ci_psz_read_depth == 0);
__insn_barrier();
/*