Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm - Hide the details of SPCF_SHOULDYIELD and related b...
details: https://anonhg.NetBSD.org/src/rev/0ba856a06beb
branches: trunk
changeset: 970164:0ba856a06beb
user: ad <ad%NetBSD.org@localhost>
date: Sat Mar 14 18:08:38 2020 +0000
description:
- Hide the details of SPCF_SHOULDYIELD and related behind a couple of small
functions: preempt_point() and preempt_needed().
- preempt(): if the LWP has exceeded its timeslice in kernel, strip it of
any priority boost gained earlier from blocking.
diffstat:
sys/arch/arm/arm32/bus_dma.c | 12 ++---
sys/arch/mips/mips/bus_dma.c | 12 ++---
sys/arch/x86/x86/bus_dma.c | 12 ++---
sys/compat/linux/common/linux_futex.c | 7 +-
sys/dev/nvmm/x86/nvmm_x86_svm.c | 11 +---
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 11 +---
sys/dev/pci/qat/qatvar.h | 4 +-
sys/external/bsd/drm2/include/linux/sched.h | 5 +-
sys/kern/kern_ktrace.c | 8 +-
sys/kern/kern_synch.c | 61 +++++++++++++++++++++++++---
sys/kern/subr_copy.c | 8 +--
sys/kern/vfs_bio.c | 7 +-
sys/miscfs/genfs/genfs_io.c | 7 +-
sys/nfs/nfs_syscalls.c | 10 +--
sys/rump/librump/rumpkern/scheduler.c | 17 +++++++-
sys/sys/sched.h | 4 +-
sys/ufs/ext2fs/ext2fs_lookup.c | 8 +-
sys/ufs/lfs/ulfs_dirhash.c | 10 +--
sys/ufs/lfs/ulfs_lookup.c | 8 +-
sys/ufs/ufs/ufs_dirhash.c | 10 +--
sys/ufs/ufs/ufs_lookup.c | 8 +-
sys/uvm/uvm_amap.c | 8 +-
22 files changed, 144 insertions(+), 104 deletions(-)
diffs (truncated from 725 to 300 lines):
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/arch/arm/arm32/bus_dma.c
--- a/sys/arch/arm/arm32/bus_dma.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/arch/arm/arm32/bus_dma.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: bus_dma.c,v 1.120 2020/02/22 08:22:09 skrll Exp $ */
+/* $NetBSD: bus_dma.c,v 1.121 2020/03/14 18:08:38 ad Exp $ */
/*-
- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996, 1997, 1998, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -36,7 +36,7 @@
#include "opt_cputypes.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.120 2020/02/22 08:22:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.121 2020/03/14 18:08:38 ad Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -1790,10 +1790,8 @@
continue;
cnt = MIN(resid, iov->iov_len);
- if (!VMSPACE_IS_KERNEL_P(vm) &&
- (curlwp->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- != 0) {
- preempt();
+ if (!VMSPACE_IS_KERNEL_P(vm)) {
+ preempt_point();
}
if (direction == UIO_READ) {
error = copyout_vmspace(vm, cp, iov->iov_base, cnt);
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/arch/mips/mips/bus_dma.c
--- a/sys/arch/mips/mips/bus_dma.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/arch/mips/mips/bus_dma.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $ */
+/* $NetBSD: bus_dma.c,v 1.40 2020/03/14 18:08:38 ad Exp $ */
/*-
- * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.40 2020/03/14 18:08:38 ad Exp $");
#define _MIPS_BUS_DMA_PRIVATE
@@ -1291,10 +1291,8 @@
continue;
cnt = MIN(resid, iov->iov_len);
- if (!VMSPACE_IS_KERNEL_P(vm) &&
- (curlwp->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- != 0) {
- preempt();
+ if (!VMSPACE_IS_KERNEL_P(vm)) {
+ preempt_point();
}
if (direction == UIO_READ) {
error = copyout_vmspace(vm, cp, iov->iov_base, cnt);
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/arch/x86/x86/bus_dma.c
--- a/sys/arch/x86/x86/bus_dma.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/arch/x86/x86/bus_dma.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: bus_dma.c,v 1.81 2019/11/14 16:23:52 maxv Exp $ */
+/* $NetBSD: bus_dma.c,v 1.82 2020/03/14 18:08:38 ad Exp $ */
/*-
- * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996, 1997, 1998, 2007, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.81 2019/11/14 16:23:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.82 2020/03/14 18:08:38 ad Exp $");
/*
* The following is included because _bus_dma_uiomove is derived from
@@ -1064,10 +1064,8 @@
continue;
cnt = MIN(resid, iov->iov_len);
- if (!VMSPACE_IS_KERNEL_P(vm) &&
- (curlwp->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- != 0) {
- preempt();
+ if (!VMSPACE_IS_KERNEL_P(vm)) {
+ preempt_point();
}
if (direction == UIO_READ) {
error = copyout_vmspace(vm, cp, iov->iov_base, cnt);
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/compat/linux/common/linux_futex.c
--- a/sys/compat/linux/common/linux_futex.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/compat/linux/common/linux_futex.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_futex.c,v 1.37 2017/04/10 15:04:32 dholland Exp $ */
+/* $NetBSD: linux_futex.c,v 1.38 2020/03/14 18:08:38 ad Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.37 2017/04/10 15:04:32 dholland Exp $");
+__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.38 2020/03/14 18:08:38 ad Exp $");
#include <sys/param.h>
#include <sys/time.h>
@@ -45,6 +45,7 @@
#include <sys/kmem.h>
#include <sys/kernel.h>
#include <sys/atomic.h>
+#include <sys/sched.h>
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_emuldata.h>
@@ -801,7 +802,7 @@
if (!--limit)
break;
- yield(); /* XXX why? */
+ preempt_point();
}
if (pending)
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.56 2020/02/21 00:26:22 joerg Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.57 2020/03/14 18:08:39 ad Exp $ */
/*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.56 2020/02/21 00:26:22 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.57 2020/03/14 18:08:39 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1441,10 +1441,7 @@
}
/* If no reason to return to userland, keep rolling. */
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) {
- break;
- }
- if (curcpu()->ci_data.cpu_softints != 0) {
+ if (preempt_needed()) {
break;
}
if (curlwp->l_flag & LW_USERRET) {
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.50 2020/03/12 13:01:59 tnn Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.51 2020/03/14 18:08:39 ad Exp $ */
/*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.50 2020/03/12 13:01:59 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.51 2020/03/14 18:08:39 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2063,10 +2063,7 @@
}
/* If no reason to return to userland, keep rolling. */
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) {
- break;
- }
- if (curcpu()->ci_data.cpu_softints != 0) {
+ if (preempt_needed()) {
break;
}
if (curlwp->l_flag & LW_USERRET) {
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/dev/pci/qat/qatvar.h
--- a/sys/dev/pci/qat/qatvar.h Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/dev/pci/qat/qatvar.h Sat Mar 14 18:08:38 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: qatvar.h,v 1.1 2019/11/20 09:37:46 hikaru Exp $ */
+/* $NetBSD: qatvar.h,v 1.2 2020/03/14 18:08:39 ad Exp $ */
/*
* Copyright (c) 2019 Internet Initiative Japan, Inc.
@@ -889,7 +889,7 @@
* and the configroot threads, which is running for qat_init(),
* takes kernel_lock and the uvm_scheduler is not working at that point.
*/
-#define QAT_YIELD() yield()
+#define QAT_YIELD() preempt_point()
extern int qat_dump;
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/external/bsd/drm2/include/linux/sched.h
--- a/sys/external/bsd/drm2/include/linux/sched.h Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/external/bsd/drm2/include/linux/sched.h Sat Mar 14 18:08:38 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sched.h,v 1.13 2019/09/28 15:13:08 christos Exp $ */
+/* $NetBSD: sched.h,v 1.14 2020/03/14 18:08:39 ad Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -87,8 +87,7 @@
cond_resched(void)
{
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
- preempt();
+ preempt_point();
}
#endif /* _LINUX_SCHED_H_ */
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/kern/kern_ktrace.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: kern_ktrace.c,v 1.175 2020/02/21 00:26:22 joerg Exp $ */
+/* $NetBSD: kern_ktrace.c,v 1.176 2020/03/14 18:08:39 ad Exp $ */
/*-
- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.175 2020/02/21 00:26:22 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.176 2020/03/14 18:08:39 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -720,7 +720,7 @@
*/
ktraddentry(l, kte, KTA_WAITOK | KTA_LARGE);
if (resid > 0) {
- if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) {
+ if (preempt_needed()) {
(void)ktrenter(l);
preempt();
ktrexit(l);
diff -r cfe4627d9bb2 -r 0ba856a06beb sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Sat Mar 14 17:29:53 2020 +0000
+++ b/sys/kern/kern_synch.c Sat Mar 14 18:08:38 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.342 2020/02/23 16:27:09 ad Exp $ */
+/* $NetBSD: kern_synch.c,v 1.343 2020/03/14 18:08:39 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.342 2020/02/23 16:27:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.343 2020/03/14 18:08:39 ad Exp $");
#include "opt_kstack.h"
#include "opt_dtrace.h"
@@ -306,8 +306,7 @@
/*
* General yield call. Puts the current LWP back on its run queue and
- * performs a voluntary context switch. Should only be called when the
- * current LWP explicitly requests it (eg sched_yield(2)).
Home |
Main Index |
Thread Index |
Old Index