From 3cdedeaec6bdfcd123386c86d818502274a450df Mon Sep 17 00:00:00 2001 From: cheloha Date: Thu, 31 Aug 2023 19:29:51 +0000 Subject: [PATCH] sched_cpu_init: remove unnecessary NULL-checks for clockintr pointers sched_cpu_init() is only run once per cpu_info struct, so we don't need these NULL-checks. The NULL-checks are a vestige of clockintr_cpu_init(), which runs more than once per CPU and uses the checks to avoid leaking clockintr handles. Thread: https://marc.info/?l=openbsd-tech&m=169349579804340&w=2 ok claudio@ --- sys/kern/kern_sched.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 4d776259630..0d2deb5f47e 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.87 2023/08/29 16:19:34 claudio Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.88 2023/08/31 19:29:51 cheloha Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski * @@ -88,26 +88,15 @@ sched_init_cpu(struct cpu_info *ci) spc->spc_idleproc = NULL; - if (spc->spc_itimer == NULL) { - spc->spc_itimer = clockintr_establish(&ci->ci_queue, - itimer_update); - if (spc->spc_itimer == NULL) { - panic("%s: clockintr_establish itimer_update", - __func__); - } - } - if (spc->spc_profclock == NULL) { - spc->spc_profclock = clockintr_establish(&ci->ci_queue, - profclock); - if (spc->spc_profclock == NULL) - panic("%s: clockintr_establish profclock", __func__); - } - if (spc->spc_roundrobin == NULL) { - spc->spc_roundrobin = clockintr_establish(&ci->ci_queue, - roundrobin); - if (spc->spc_roundrobin == NULL) - panic("%s: clockintr_establish roundrobin", __func__); - } + spc->spc_itimer = clockintr_establish(&ci->ci_queue, itimer_update); + if (spc->spc_itimer == NULL) + panic("%s: clockintr_establish itimer_update", __func__); + spc->spc_profclock = clockintr_establish(&ci->ci_queue, profclock); + if (spc->spc_profclock == NULL) + panic("%s: clockintr_establish profclock", __func__); + spc->spc_roundrobin = clockintr_establish(&ci->ci_queue, roundrobin); + if (spc->spc_roundrobin == NULL) + panic("%s: clockintr_establish roundrobin", __func__); kthread_create_deferred(sched_kthreads_create, ci); -- 2.20.1