summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-06-21 21:16:22 +0000
committerScott Soule Cheloha <cheloha@cvs.openbsd.org>2023-06-21 21:16:22 +0000
commitd75f65d40a7b2cf83a64349d3434fae7d50c2283 (patch)
treec73cd54fb8f78feab80f4c940bab73287ffefb12
parent9d7d271e2ca581fa830b3329bc6d5a263e4c7cde (diff)
Revert "schedcpu, uvm_meter(9): make uvm_meter() an independent timeout"
Sometimes causes boot hang after mounting root partition. Thread 1: https://marc.info/?l=openbsd-misc&m=168736497407357&w=2 Thread 2: https://marc.info/?l=openbsd-misc&m=168737429214370&w=2
-rw-r--r--share/man/man9/uvm_init.98
-rw-r--r--sys/kern/sched_bsd.c4
-rw-r--r--sys/uvm/uvm_extern.h4
-rw-r--r--sys/uvm/uvm_meter.c15
4 files changed, 15 insertions, 16 deletions
diff --git a/share/man/man9/uvm_init.9 b/share/man/man9/uvm_init.9
index 636a16a13b3..a8493cd90df 100644
--- a/share/man/man9/uvm_init.9
+++ b/share/man/man9/uvm_init.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: uvm_init.9,v 1.6 2023/06/20 16:30:30 cheloha Exp $
+.\" $OpenBSD: uvm_init.9,v 1.7 2023/06/21 21:16:21 cheloha Exp $
.\" $NetBSD: uvm.9,v 1.14 2000/06/29 06:08:44 mrg Exp $
.\"
.\" Copyright (c) 1998 Matthew R. Green
@@ -28,7 +28,7 @@
.\" XXX this manual sets nS to 1 or 0 in the description, to obtain
.\" synopsis-like function prototypes. any better way?
.\"
-.Dd $Mdocdate: June 20 2023 $
+.Dd $Mdocdate: June 21 2023 $
.Dt UVM_INIT 9
.Os
.Sh NAME
@@ -168,7 +168,7 @@ argument is ignored.
.Ft void
.Fn uvm_kernacc "caddr_t addr" "size_t len" "int rw"
.Ft void
-.Fn uvm_meter "void *"
+.Fn uvm_meter
.Ft int
.Fn uvm_sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp " "size_t newlen" "struct proc *p"
.Ft int
@@ -212,7 +212,7 @@ access, in the kernel address space.
.Pp
The
.Fn uvm_meter
-function periodically recomputes the load average.
+function calculates the load average and wakes up the swapper if necessary.
.Pp
The
.Fn uvm_sysctl
diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c
index 3a82cca9b51..753edaed6f2 100644
--- a/sys/kern/sched_bsd.c
+++ b/sys/kern/sched_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched_bsd.c,v 1.75 2023/06/20 16:30:30 cheloha Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.76 2023/06/21 21:16:21 cheloha Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@@ -234,6 +234,7 @@ schedcpu(void *arg)
}
SCHED_UNLOCK(s);
}
+ uvm_meter();
wakeup(&lbolt);
timeout_add_sec(to, 1);
}
@@ -668,7 +669,6 @@ scheduler_start(void)
rrticks_init = hz / 10;
schedcpu(&schedcpu_to);
- uvm_meter(NULL);
#ifndef SMALL_KERNEL
if (perfpolicy == PERFPOL_AUTO)
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h
index 85124bd8135..a6fc5f04121 100644
--- a/sys/uvm/uvm_extern.h
+++ b/sys/uvm/uvm_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_extern.h,v 1.169 2023/06/20 16:30:30 cheloha Exp $ */
+/* $OpenBSD: uvm_extern.h,v 1.170 2023/06/21 21:16:21 cheloha Exp $ */
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
/*
@@ -414,7 +414,7 @@ void uvmspace_free(struct vmspace *);
struct vmspace *uvmspace_share(struct process *);
int uvm_share(vm_map_t, vaddr_t, vm_prot_t,
vm_map_t, vaddr_t, vsize_t);
-void uvm_meter(void *);
+void uvm_meter(void);
int uvm_sysctl(int *, u_int, void *, size_t *,
void *, size_t, struct proc *);
struct vm_page *uvm_pagealloc(struct uvm_object *,
diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c
index 8fc7c1030d8..cd0efeeca6f 100644
--- a/sys/uvm/uvm_meter.c
+++ b/sys/uvm/uvm_meter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_meter.c,v 1.43 2023/06/20 16:30:30 cheloha Exp $ */
+/* $OpenBSD: uvm_meter.c,v 1.44 2023/06/21 21:16:21 cheloha Exp $ */
/* $NetBSD: uvm_meter.c,v 1.21 2001/07/14 06:36:03 matt Exp $ */
/*
@@ -65,9 +65,6 @@
int maxslp = MAXSLP; /* patchable ... */
struct loadavg averunnable;
-#define UVM_METER_INTVL 5
-struct timeout uvm_meter_to = TIMEOUT_INITIALIZER(uvm_meter, NULL);
-
/*
* constants for averages over 1, 5, and 15 minutes when sampling at
* 5 second intervals.
@@ -85,13 +82,15 @@ void uvm_total(struct vmtotal *);
void uvmexp_read(struct uvmexp *);
/*
- * uvm_meter: recompute load averages
+ * uvm_meter: calculate load average and wake up the swapper (if needed)
*/
void
-uvm_meter(void *unused)
+uvm_meter(void)
{
- timeout_add_sec(&uvm_meter_to, UVM_METER_INTVL);
- uvm_loadav(&averunnable);
+ if ((gettime() % 5) == 0)
+ uvm_loadav(&averunnable);
+ if (proc0.p_slptime > (maxslp / 2))
+ wakeup(&proc0);
}
/*