summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-07-08 14:46:48 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-07-08 14:46:48 +0000
commit31f5a15902a5a1bb8e354696e7eb9102ad9539b1 (patch)
tree599c51411a71e78553b015b2a49ac97ac0d2cdc6
parent69d9547e9e5b0ad9c26bc3a3e1c712e464f3c336 (diff)
Introduce sched_unpeg_curproc() to abstract the current implementation.
ok kettenis@, mlarkin@, miod@, claudio@
-rw-r--r--sys/arch/amd64/amd64/identcpu.c4
-rw-r--r--sys/dev/kstat.c4
-rw-r--r--sys/kern/kern_sched.c14
-rw-r--r--sys/kern/kern_smr.c4
-rw-r--r--sys/sys/sched.h3
5 files changed, 20 insertions, 9 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c
index 1c1df3a11a1..a6e31e50255 100644
--- a/sys/arch/amd64/amd64/identcpu.c
+++ b/sys/arch/amd64/amd64/identcpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identcpu.c,v 1.145 2024/06/24 21:22:14 bluhm Exp $ */
+/* $OpenBSD: identcpu.c,v 1.146 2024/07/08 14:46:47 mpi Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
@@ -169,7 +169,7 @@ cpu_hz_update_sensor(void *args)
ci->ci_hz_sensor.value = val;
}
- atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
+ sched_unpeg_curproc();
}
#endif
diff --git a/sys/dev/kstat.c b/sys/dev/kstat.c
index 073f61a2c34..5b41743395e 100644
--- a/sys/dev/kstat.c
+++ b/sys/dev/kstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kstat.c,v 1.2 2022/01/31 05:09:17 dlg Exp $ */
+/* $OpenBSD: kstat.c,v 1.3 2024/07/08 14:46:47 mpi Exp $ */
/*
* Copyright (c) 2020 David Gwynne <dlg@openbsd.org>
@@ -593,7 +593,7 @@ kstat_cpu_enter(void *p)
void
kstat_cpu_leave(void *p)
{
- atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
+ sched_unpeg_curproc();
}
void
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 129d46422d6..a2e9ffa76b7 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.97 2024/07/08 13:17:12 claudio Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.98 2024/07/08 14:46:47 mpi Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -646,6 +646,16 @@ sched_peg_curproc(struct cpu_info *ci)
SCHED_UNLOCK();
}
+void
+sched_unpeg_curproc(void)
+{
+ struct proc *p = curproc;
+
+ KASSERT(ISSET(p->p_flag, P_CPUPEG));
+
+ atomic_clearbits_int(&p->p_flag, P_CPUPEG);
+}
+
#ifdef MULTIPROCESSOR
void
@@ -712,7 +722,7 @@ sched_barrier_task(void *arg)
sched_peg_curproc(ci);
cond_signal(&sb->cond);
- atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
+ sched_unpeg_curproc();
}
void
diff --git a/sys/kern/kern_smr.c b/sys/kern/kern_smr.c
index 6227c1df8fc..14dad262214 100644
--- a/sys/kern/kern_smr.c
+++ b/sys/kern/kern_smr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_smr.c,v 1.16 2022/08/14 01:58:27 jsg Exp $ */
+/* $OpenBSD: kern_smr.c,v 1.17 2024/07/08 14:46:47 mpi Exp $ */
/*
* Copyright (c) 2019-2020 Visa Hankala
@@ -163,7 +163,7 @@ smr_grace_wait(void)
sched_peg_curproc(ci);
KASSERT(ci->ci_schedstate.spc_smrgp == smrgp);
}
- atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
+ sched_unpeg_curproc();
#endif /* MULTIPROCESSOR */
}
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index dcc9b636679..2bd5c4e594b 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.72 2024/06/03 12:48:25 claudio Exp $ */
+/* $OpenBSD: sched.h,v 1.73 2024/07/08 14:46:47 mpi Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -169,6 +169,7 @@ void cpu_idle_enter(void);
void cpu_idle_cycle(void);
void cpu_idle_leave(void);
void sched_peg_curproc(struct cpu_info *ci);
+void sched_unpeg_curproc(void);
void sched_barrier(struct cpu_info *ci);
int sysctl_hwsetperf(void *, size_t *, void *, size_t);