Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern sys: Use preempt_point and preempt_needed, not open...
details: https://anonhg.NetBSD.org/src/rev/9af9d0361e3a
branches: trunk
changeset: 1029238:9af9d0361e3a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Dec 28 13:22:43 2021 +0000
description:
sys: Use preempt_point and preempt_needed, not open-coded versions.
diffstat:
sys/arch/mips/cavium/dev/octeon_rnm.c | 9 ++++-----
sys/dev/random.c | 9 ++++-----
sys/kern/sys_getrandom.c | 9 ++++-----
3 files changed, 12 insertions(+), 15 deletions(-)
diffs (90 lines):
diff -r aa214ada3f52 -r 9af9d0361e3a sys/arch/mips/cavium/dev/octeon_rnm.c
--- a/sys/arch/mips/cavium/dev/octeon_rnm.c Tue Dec 28 12:00:48 2021 +0000
+++ b/sys/arch/mips/cavium/dev/octeon_rnm.c Tue Dec 28 13:22:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_rnm.c,v 1.12 2020/06/18 13:52:08 simonb Exp $ */
+/* $NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.12 2020/06/18 13:52:08 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -262,9 +262,8 @@
sizeof sc->sc_sample, NBBY*sizeof(sc->sc_sample)/BPB);
needed -= MIN(needed, MAX(1, NBBY*sizeof(sc->sc_sample)/BPB));
- /* Yield if requested. */
- if (__predict_false(curcpu()->ci_schedstate.spc_flags &
- SPCF_SHOULDYIELD)) {
+ /* Now's a good time to yield if need. */
+ if (__predict_false(preempt_needed())) {
mutex_exit(&sc->sc_lock);
preempt();
mutex_enter(&sc->sc_lock);
diff -r aa214ada3f52 -r 9af9d0361e3a sys/dev/random.c
--- a/sys/dev/random.c Tue Dec 28 12:00:48 2021 +0000
+++ b/sys/dev/random.c Tue Dec 28 13:22:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $ */
+/* $NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -282,9 +282,8 @@
rnd_add_data(&user_rndsource, buf, n, privileged ? n*NBBY : 0);
any = true;
- /* Yield if requested. */
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- preempt();
+ /* Now's a good time to yield if needed. */
+ preempt_point();
/* Check for interruption. */
if (__predict_false(curlwp->l_flag & LW_PENDSIG) &&
diff -r aa214ada3f52 -r 9af9d0361e3a sys/kern/sys_getrandom.c
--- a/sys/kern/sys_getrandom.c Tue Dec 28 12:00:48 2021 +0000
+++ b/sys/kern/sys_getrandom.c Tue Dec 28 13:22:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $ */
+/* $NetBSD: sys_getrandom.c,v 1.2 2021/12/28 13:22:43 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_getrandom.c,v 1.2 2021/12/28 13:22:43 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -174,9 +174,8 @@
break;
}
- /* Yield if requested. */
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- preempt();
+ /* Now's a good time to yield if needed. */
+ preempt_point();
/* Check for interruption after at least 256 bytes. */
CTASSERT(RANDOM_BUFSIZE >= 256);
Home |
Main Index |
Thread Index |
Old Index