-/* $OpenBSD: cpu.h,v 1.70 2023/07/25 18:16:19 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.71 2024/01/24 19:23:38 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.159 2023/08/23 01:55:46 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.160 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
u_int64_t ci_hz_aperf;
#if defined(GPROF) || defined(DDBPROF)
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
u_int32_t ci_vmm_flags;
#define CI_VMM_VMX (1 << 0)
-/* $OpenBSD: cpu.h,v 1.64 2023/08/23 01:55:46 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.65 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.41 2024/01/15 11:58:45 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.42 2024/01/24 19:23:39 cheloha Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.102 2023/11/05 16:33:50 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.103 2024/01/24 19:23:39 cheloha Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.183 2023/08/23 01:55:46 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.184 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
struct ksensor ci_sensor;
#if defined(GPROF) || defined(DDBPROF)
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.73 2023/07/25 18:16:20 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.74 2024/01/24 19:23:39 cheloha Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
struct clockintr_queue ci_queue;
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.144 2023/08/23 01:55:47 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.145 2024/01/24 19:23:39 cheloha Exp $ */
/*-
* Copyright (c) 1992, 1993
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
char ci_panicbuf[512];
};
-/* $OpenBSD: cpu.h,v 1.75 2023/07/25 18:16:20 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.76 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
char ci_panicbuf[512];
};
-/* $OpenBSD: cpu.h,v 1.19 2023/09/19 19:20:33 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.20 2024/01/24 19:23:39 cheloha Exp $ */
/*
* Copyright (c) 2019 Mike Larkin <mlarkin@openbsd.org>
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
char ci_panicbuf[512];
-/* $OpenBSD: cpu.h,v 1.35 2023/07/25 18:16:21 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.36 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */
/*-
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
int ci_want_resched;
-/* $OpenBSD: cpu.h,v 1.102 2023/07/25 18:16:21 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.103 2024/01/24 19:23:39 cheloha Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
#endif
#ifdef GPROF
struct gmonparam *ci_gmon;
- struct clockintr *ci_gmonclock;
+ struct clockintr ci_gmonclock;
#endif
char ci_panicbuf[512];
};
-/* $OpenBSD: kern_clockintr.c,v 1.63 2024/01/15 01:15:37 cheloha Exp $ */
+/* $OpenBSD: kern_clockintr.c,v 1.64 2024/01/24 19:23:38 cheloha Exp $ */
/*
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
clockqueue_intrclock_install(cq, ic);
/* TODO: Remove this from struct clockintr_queue. */
- if (cq->cq_hardclock == NULL) {
- cq->cq_hardclock = clockintr_establish(ci, clockintr_hardclock,
+ if (cq->cq_hardclock.cl_expiration == 0) {
+ clockintr_bind(&cq->cq_hardclock, ci, clockintr_hardclock,
NULL);
- if (cq->cq_hardclock == NULL)
- panic("%s: failed to establish hardclock", __func__);
}
/*
* behalf.
*/
if (CPU_IS_PRIMARY(ci)) {
- if (cq->cq_hardclock->cl_expiration == 0)
- clockintr_schedule(cq->cq_hardclock, 0);
+ if (cq->cq_hardclock.cl_expiration == 0)
+ clockintr_schedule(&cq->cq_hardclock, 0);
else
- clockintr_advance(cq->cq_hardclock, hardclock_period);
+ clockintr_advance(&cq->cq_hardclock, hardclock_period);
} else {
- if (cq->cq_hardclock->cl_expiration == 0) {
- clockintr_stagger(cq->cq_hardclock, hardclock_period,
+ if (cq->cq_hardclock.cl_expiration == 0) {
+ clockintr_stagger(&cq->cq_hardclock, hardclock_period,
multiplier, MAXCPUS);
}
- clockintr_advance(cq->cq_hardclock, hardclock_period);
+ clockintr_advance(&cq->cq_hardclock, hardclock_period);
}
/*
* stagger a randomized statclock.
*/
if (!statclock_is_randomized) {
- if (spc->spc_statclock->cl_expiration == 0) {
- clockintr_stagger(spc->spc_statclock, statclock_avg,
+ if (spc->spc_statclock.cl_expiration == 0) {
+ clockintr_stagger(&spc->spc_statclock, statclock_avg,
multiplier, MAXCPUS);
}
}
- clockintr_advance(spc->spc_statclock, statclock_avg);
+ clockintr_advance(&spc->spc_statclock, statclock_avg);
/*
* XXX Need to find a better place to do this. We can't do it in
* sched_init_cpu() because initclocks() runs after it.
*/
- if (spc->spc_itimer->cl_expiration == 0) {
- clockintr_stagger(spc->spc_itimer, hardclock_period,
+ if (spc->spc_itimer.cl_expiration == 0) {
+ clockintr_stagger(&spc->spc_itimer, hardclock_period,
multiplier, MAXCPUS);
}
- if (spc->spc_profclock->cl_expiration == 0) {
- clockintr_stagger(spc->spc_profclock, profclock_period,
+ if (spc->spc_profclock.cl_expiration == 0) {
+ clockintr_stagger(&spc->spc_profclock, profclock_period,
multiplier, MAXCPUS);
}
- if (spc->spc_roundrobin->cl_expiration == 0) {
- clockintr_stagger(spc->spc_roundrobin, hardclock_period,
+ if (spc->spc_roundrobin.cl_expiration == 0) {
+ clockintr_stagger(&spc->spc_roundrobin, hardclock_period,
multiplier, MAXCPUS);
}
- clockintr_advance(spc->spc_roundrobin, roundrobin_period);
+ clockintr_advance(&spc->spc_roundrobin, roundrobin_period);
if (reset_cq_intrclock)
SET(cq->cq_flags, CQ_INTRCLOCK);
mtx_leave(&cq->cq_mtx);
}
-struct clockintr *
-clockintr_establish(struct cpu_info *ci,
+void
+clockintr_bind(struct clockintr *cl, struct cpu_info *ci,
void (*func)(struct clockrequest *, void *, void *), void *arg)
{
- struct clockintr *cl;
struct clockintr_queue *cq = &ci->ci_queue;
- cl = malloc(sizeof *cl, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (cl == NULL)
- return NULL;
cl->cl_arg = arg;
cl->cl_func = func;
cl->cl_queue = cq;
mtx_enter(&cq->cq_mtx);
TAILQ_INSERT_TAIL(&cq->cq_all, cl, cl_alink);
mtx_leave(&cq->cq_mtx);
- return cl;
}
void
-/* $OpenBSD: kern_fork.c,v 1.256 2024/01/19 01:43:26 bluhm Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.257 2024/01/24 19:23:38 cheloha Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
/* Start any optional clock interrupts needed by the thread. */
if (ISSET(p->p_p->ps_flags, PS_ITIMER)) {
atomic_setbits_int(&spc->spc_schedflags, SPCF_ITIMER);
- clockintr_advance(spc->spc_itimer, hardclock_period);
+ clockintr_advance(&spc->spc_itimer, hardclock_period);
}
if (ISSET(p->p_p->ps_flags, PS_PROFIL)) {
atomic_setbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
- clockintr_advance(spc->spc_profclock, profclock_period);
+ clockintr_advance(&spc->spc_profclock, profclock_period);
}
nanouptime(&spc->spc_runtime);
-/* $OpenBSD: kern_sched.c,v 1.93 2023/10/24 13:20:11 claudio Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.94 2024/01/24 19:23:38 cheloha Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
spc->spc_idleproc = NULL;
- spc->spc_itimer = clockintr_establish(ci, itimer_update, NULL);
- if (spc->spc_itimer == NULL)
- panic("%s: clockintr_establish itimer_update", __func__);
- spc->spc_profclock = clockintr_establish(ci, profclock, NULL);
- if (spc->spc_profclock == NULL)
- panic("%s: clockintr_establish profclock", __func__);
- spc->spc_roundrobin = clockintr_establish(ci, roundrobin, NULL);
- if (spc->spc_roundrobin == NULL)
- panic("%s: clockintr_establish roundrobin", __func__);
- spc->spc_statclock = clockintr_establish(ci, statclock, NULL);
- if (spc->spc_statclock == NULL)
- panic("%s: clockintr_establish statclock", __func__);
+ clockintr_bind(&spc->spc_itimer, ci, itimer_update, NULL);
+ clockintr_bind(&spc->spc_profclock, ci, profclock, NULL);
+ clockintr_bind(&spc->spc_roundrobin, ci, roundrobin, NULL);
+ clockintr_bind(&spc->spc_statclock, ci, statclock, NULL);
kthread_create_deferred(sched_kthreads_create, ci);
if (ISSET(spc->spc_schedflags, SPCF_ITIMER)) {
atomic_clearbits_int(&spc->spc_schedflags, SPCF_ITIMER);
- clockintr_cancel(spc->spc_itimer);
+ clockintr_cancel(&spc->spc_itimer);
}
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
- clockintr_cancel(spc->spc_profclock);
+ clockintr_cancel(&spc->spc_profclock);
}
atomic_clearbits_int(&spc->spc_schedflags, SPCF_SWITCHCLEAR);
-/* $OpenBSD: sched_bsd.c,v 1.89 2023/10/17 00:04:02 cheloha Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.90 2024/01/24 19:23:38 cheloha Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
/* Stop any optional clock interrupts. */
if (ISSET(spc->spc_schedflags, SPCF_ITIMER)) {
atomic_clearbits_int(&spc->spc_schedflags, SPCF_ITIMER);
- clockintr_cancel(spc->spc_itimer);
+ clockintr_cancel(&spc->spc_itimer);
}
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
- clockintr_cancel(spc->spc_profclock);
+ clockintr_cancel(&spc->spc_profclock);
}
/*
/* Start any optional clock interrupts needed by the thread. */
if (ISSET(p->p_p->ps_flags, PS_ITIMER)) {
atomic_setbits_int(&spc->spc_schedflags, SPCF_ITIMER);
- clockintr_advance(spc->spc_itimer, hardclock_period);
+ clockintr_advance(&spc->spc_itimer, hardclock_period);
}
if (ISSET(p->p_p->ps_flags, PS_PROFIL)) {
atomic_setbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
- clockintr_advance(spc->spc_profclock, profclock_period);
+ clockintr_advance(&spc->spc_profclock, profclock_period);
}
nanouptime(&spc->spc_runtime);
-/* $OpenBSD: subr_prof.c,v 1.40 2023/10/17 00:04:02 cheloha Exp $ */
+/* $OpenBSD: subr_prof.c,v 1.41 2024/01/24 19:23:38 cheloha Exp $ */
/* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */
/*-
/* Allocate and initialize one profiling buffer per CPU. */
CPU_INFO_FOREACH(cii, ci) {
- ci->ci_gmonclock = clockintr_establish(ci, gmonclock, NULL);
- if (ci->ci_gmonclock == NULL) {
- printf("%s: clockintr_establish gmonclock\n", __func__);
- return;
- }
- clockintr_stagger(ci->ci_gmonclock, profclock_period,
- CPU_INFO_UNIT(ci), MAXCPUS);
cp = km_alloc(round_page(size), &kv_any, &kp_zero, &kd_nowait);
if (cp == NULL) {
printf("No memory for profiling.\n");
return;
}
+ clockintr_bind(&ci->ci_gmonclock, ci, gmonclock, NULL);
+ clockintr_stagger(&ci->ci_gmonclock, profclock_period,
+ CPU_INFO_UNIT(ci), MAXCPUS);
+
p = (struct gmonparam *)cp;
cp += sizeof(*p);
p->tos = (struct tostruct *)cp;
if (error == 0) {
if (++gmon_cpu_count == 1)
startprofclock(&process0);
- clockintr_advance(ci->ci_gmonclock, profclock_period);
+ clockintr_advance(&ci->ci_gmonclock, profclock_period);
}
break;
default:
gp->state = GMON_PROF_OFF;
/* FALLTHROUGH */
case GMON_PROF_OFF:
- clockintr_cancel(ci->ci_gmonclock);
+ clockintr_cancel(&ci->ci_gmonclock);
if (--gmon_cpu_count == 0)
stopprofclock(&process0);
#if !defined(GPROF)
-/* $OpenBSD: clockintr.h,v 1.24 2024/01/15 01:15:37 cheloha Exp $ */
+/* $OpenBSD: clockintr.h,v 1.25 2024/01/24 19:23:38 cheloha Exp $ */
/*
* Copyright (c) 2020-2022 Scott Cheloha <cheloha@openbsd.org>
*
TAILQ_HEAD(, clockintr) cq_all; /* [m] established clockintr list */
TAILQ_HEAD(, clockintr) cq_pend;/* [m] pending clockintr list */
struct clockintr *cq_running; /* [m] running clockintr */
- struct clockintr *cq_hardclock; /* [o] hardclock handle */
+ struct clockintr cq_hardclock; /* [o] hardclock handle */
struct intrclock cq_intrclock; /* [I] local interrupt clock */
struct clockintr_stat cq_stat; /* [o] dispatch statistics */
volatile uint32_t cq_gen; /* [o] cq_stat update generation */
*/
uint64_t clockintr_advance(struct clockintr *, uint64_t);
-void clockintr_cancel(struct clockintr *);
-struct clockintr *clockintr_establish(struct cpu_info *,
+void clockintr_bind(struct clockintr *, struct cpu_info *,
void (*)(struct clockrequest *, void *, void *), void *);
+void clockintr_cancel(struct clockintr *);
void clockintr_schedule(struct clockintr *, uint64_t);
void clockintr_stagger(struct clockintr *, uint64_t, uint32_t, uint32_t);
uint64_t clockrequest_advance(struct clockrequest *, uint64_t);
-/* $OpenBSD: sched.h,v 1.69 2024/01/14 17:23:56 cheloha Exp $ */
+/* $OpenBSD: sched.h,v 1.70 2024/01/24 19:23:38 cheloha Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
#ifdef _KERNEL
+#include <sys/clockintr.h>
#include <sys/queue.h>
#define SCHED_NQS 32 /* 32 run queues. */
-struct clockintr;
struct smr_entry;
/*
u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */
u_char spc_curpriority; /* usrpri of curproc */
- struct clockintr *spc_itimer; /* [o] itimer_update handle */
- struct clockintr *spc_profclock; /* [o] profclock handle */
- struct clockintr *spc_roundrobin; /* [o] roundrobin handle */
- struct clockintr *spc_statclock; /* [o] statclock handle */
+ struct clockintr spc_itimer; /* [o] itimer_update handle */
+ struct clockintr spc_profclock; /* [o] profclock handle */
+ struct clockintr spc_roundrobin;/* [o] roundrobin handle */
+ struct clockintr spc_statclock; /* [o] statclock handle */
u_int spc_nrun; /* procs on the run queues */