sync code with last fixes and improvements from OpenBSD
This commit is contained in:
parent
58df21ce75
commit
f960599e67
399 changed files with 7016 additions and 6902 deletions
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: init_sysent.c,v 1.266 2023/05/18 10:24:28 mvs Exp $ */
|
||||
/* $OpenBSD: init_sysent.c,v 1.267 2023/07/24 19:33:29 miod Exp $ */
|
||||
|
||||
/*
|
||||
* System call switch table.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.249 2023/07/24 19:32:23 miod Exp
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_clock.c,v 1.108 2023/04/25 00:58:47 cheloha Exp $ */
|
||||
/* $OpenBSD: kern_clock.c,v 1.109 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -49,10 +49,6 @@
|
|||
#include <sys/sched.h>
|
||||
#include <sys/timetc.h>
|
||||
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
#include <sys/gmon.h>
|
||||
#endif
|
||||
|
||||
#include "dt.h"
|
||||
#if NDT > 0
|
||||
#include <dev/dt/dtvar.h>
|
||||
|
@ -87,8 +83,6 @@ int schedhz;
|
|||
int profhz;
|
||||
int profprocs;
|
||||
int ticks = INT_MAX - (15 * 60 * HZ);
|
||||
static int psdiv, pscnt; /* prof => stat divider */
|
||||
int psratio; /* ratio: prof / stat */
|
||||
|
||||
volatile unsigned long jiffies = ULONG_MAX - (10 * 60 * HZ);
|
||||
|
||||
|
@ -99,16 +93,13 @@ void
|
|||
initclocks(void)
|
||||
{
|
||||
/*
|
||||
* Set divisors to 1 (normal case) and let the machine-specific
|
||||
* code do its bit.
|
||||
* Let the machine-specific code do its bit.
|
||||
*/
|
||||
psdiv = pscnt = 1;
|
||||
cpu_initclocks();
|
||||
|
||||
/*
|
||||
* Compute profhz/stathz.
|
||||
*/
|
||||
psratio = profhz / stathz;
|
||||
KASSERT(profhz >= stathz && profhz <= 1000000000);
|
||||
KASSERT(profhz % stathz == 0);
|
||||
profclock_period = 1000000000 / profhz;
|
||||
|
||||
inittimecounter();
|
||||
}
|
||||
|
@ -256,7 +247,6 @@ startprofclock(struct process *pr)
|
|||
atomic_setbits_int(&pr->ps_flags, PS_PROFIL);
|
||||
if (++profprocs == 1) {
|
||||
s = splstatclock();
|
||||
psdiv = pscnt = psratio;
|
||||
setstatclockrate(profhz);
|
||||
splx(s);
|
||||
}
|
||||
|
@ -275,7 +265,6 @@ stopprofclock(struct process *pr)
|
|||
atomic_clearbits_int(&pr->ps_flags, PS_PROFIL);
|
||||
if (--profprocs == 0) {
|
||||
s = splstatclock();
|
||||
psdiv = pscnt = 1;
|
||||
setstatclockrate(stathz);
|
||||
splx(s);
|
||||
}
|
||||
|
@ -289,35 +278,13 @@ stopprofclock(struct process *pr)
|
|||
void
|
||||
statclock(struct clockframe *frame)
|
||||
{
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
struct gmonparam *g;
|
||||
u_long i;
|
||||
#endif
|
||||
struct cpu_info *ci = curcpu();
|
||||
struct schedstate_percpu *spc = &ci->ci_schedstate;
|
||||
struct proc *p = curproc;
|
||||
struct process *pr;
|
||||
|
||||
/*
|
||||
* Notice changes in divisor frequency, and adjust clock
|
||||
* frequency accordingly.
|
||||
*/
|
||||
if (spc->spc_psdiv != psdiv) {
|
||||
spc->spc_psdiv = psdiv;
|
||||
spc->spc_pscnt = psdiv;
|
||||
if (psdiv == 1) {
|
||||
setstatclockrate(stathz);
|
||||
} else {
|
||||
setstatclockrate(profhz);
|
||||
}
|
||||
}
|
||||
|
||||
if (CLKF_USERMODE(frame)) {
|
||||
pr = p->p_p;
|
||||
if (pr->ps_flags & PS_PROFIL)
|
||||
addupc_intr(p, CLKF_PC(frame), 1);
|
||||
if (--spc->spc_pscnt > 0)
|
||||
return;
|
||||
/*
|
||||
* Came from user mode; CPU was in user state.
|
||||
* If this process is being profiled record the tick.
|
||||
|
@ -328,23 +295,6 @@ statclock(struct clockframe *frame)
|
|||
else
|
||||
spc->spc_cp_time[CP_USER]++;
|
||||
} else {
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
/*
|
||||
* Kernel statistics are just like addupc_intr, only easier.
|
||||
*/
|
||||
g = ci->ci_gmon;
|
||||
if (g != NULL && g->state == GMON_PROF_ON) {
|
||||
i = CLKF_PC(frame) - g->lowpc;
|
||||
if (i < g->textsize) {
|
||||
i /= HISTFRACTION * sizeof(*g->kcount);
|
||||
g->kcount[i]++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (p != NULL && p->p_p->ps_flags & PS_PROFIL)
|
||||
addupc_intr(p, PROC_PC(p), 1);
|
||||
if (--spc->spc_pscnt > 0)
|
||||
return;
|
||||
/*
|
||||
* Came from kernel mode, so we were:
|
||||
* - spinning on a lock
|
||||
|
@ -371,7 +321,6 @@ statclock(struct clockframe *frame)
|
|||
spc->spc_cp_time[spc->spc_spinning ?
|
||||
CP_SPIN : CP_IDLE]++;
|
||||
}
|
||||
spc->spc_pscnt = psdiv;
|
||||
|
||||
if (p != NULL) {
|
||||
p->p_cpticks++;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_clockintr.c,v 1.27 2023/07/02 19:02:27 cheloha Exp $ */
|
||||
/* $OpenBSD: kern_clockintr.c,v 1.28 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -32,39 +32,23 @@
|
|||
/*
|
||||
* Protection for global variables in this file:
|
||||
*
|
||||
* C Global clockintr configuration mutex (clockintr_mtx).
|
||||
* I Immutable after initialization.
|
||||
*/
|
||||
struct mutex clockintr_mtx = MUTEX_INITIALIZER(IPL_CLOCK);
|
||||
|
||||
u_int clockintr_flags; /* [I] global state + behavior flags */
|
||||
uint32_t hardclock_period; /* [I] hardclock period (ns) */
|
||||
uint32_t schedclock_period; /* [I] schedclock period (ns) */
|
||||
volatile u_int statclock_gen = 1; /* [C] statclock update generation */
|
||||
volatile uint32_t statclock_avg; /* [C] average statclock period (ns) */
|
||||
uint32_t statclock_min; /* [C] minimum statclock period (ns) */
|
||||
uint32_t statclock_mask; /* [C] set of allowed offsets */
|
||||
uint32_t stat_avg; /* [I] average stathz period (ns) */
|
||||
uint32_t stat_min; /* [I] set of allowed offsets */
|
||||
uint32_t stat_mask; /* [I] max offset from minimum (ns) */
|
||||
uint32_t prof_avg; /* [I] average profhz period (ns) */
|
||||
uint32_t prof_min; /* [I] minimum profhz period (ns) */
|
||||
uint32_t prof_mask; /* [I] set of allowed offsets */
|
||||
uint32_t statclock_avg; /* [I] average statclock period (ns) */
|
||||
uint32_t statclock_min; /* [I] minimum statclock period (ns) */
|
||||
uint32_t statclock_mask; /* [I] set of allowed offsets */
|
||||
|
||||
uint64_t clockintr_advance(struct clockintr *, uint64_t);
|
||||
void clockintr_cancel(struct clockintr *);
|
||||
void clockintr_cancel_locked(struct clockintr *);
|
||||
struct clockintr *clockintr_establish(struct clockintr_queue *,
|
||||
void (*)(struct clockintr *, void *));
|
||||
uint64_t clockintr_expiration(const struct clockintr *);
|
||||
void clockintr_hardclock(struct clockintr *, void *);
|
||||
uint64_t clockintr_nsecuptime(const struct clockintr *);
|
||||
void clockintr_schedclock(struct clockintr *, void *);
|
||||
void clockintr_schedule(struct clockintr *, uint64_t);
|
||||
void clockintr_schedule_locked(struct clockintr *, uint64_t);
|
||||
void clockintr_stagger(struct clockintr *, uint64_t, u_int, u_int);
|
||||
void clockintr_statclock(struct clockintr *, void *);
|
||||
void clockintr_statvar_init(int, uint32_t *, uint32_t *, uint32_t *);
|
||||
uint64_t clockqueue_next(const struct clockintr_queue *);
|
||||
void clockqueue_reset_intrclock(struct clockintr_queue *);
|
||||
uint64_t nsec_advance(uint64_t *, uint64_t, uint64_t);
|
||||
|
@ -75,6 +59,8 @@ uint64_t nsec_advance(uint64_t *, uint64_t, uint64_t);
|
|||
void
|
||||
clockintr_init(u_int flags)
|
||||
{
|
||||
uint32_t half_avg, var;
|
||||
|
||||
KASSERT(CPU_IS_PRIMARY(curcpu()));
|
||||
KASSERT(clockintr_flags == 0);
|
||||
KASSERT(!ISSET(flags, ~CL_FLAG_MASK));
|
||||
|
@ -83,12 +69,22 @@ clockintr_init(u_int flags)
|
|||
hardclock_period = 1000000000 / hz;
|
||||
|
||||
KASSERT(stathz >= 1 && stathz <= 1000000000);
|
||||
KASSERT(profhz >= stathz && profhz <= 1000000000);
|
||||
KASSERT(profhz % stathz == 0);
|
||||
clockintr_statvar_init(stathz, &stat_avg, &stat_min, &stat_mask);
|
||||
clockintr_statvar_init(profhz, &prof_avg, &prof_min, &prof_mask);
|
||||
SET(clockintr_flags, CL_STATCLOCK);
|
||||
clockintr_setstatclockrate(stathz);
|
||||
|
||||
/*
|
||||
* Compute the average statclock() period. Then find var, the
|
||||
* largest power of two such that var <= statclock_avg / 2.
|
||||
*/
|
||||
statclock_avg = 1000000000 / stathz;
|
||||
half_avg = statclock_avg / 2;
|
||||
for (var = 1U << 31; var > half_avg; var /= 2)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Set a lower bound for the range using statclock_avg and var.
|
||||
* The mask for that range is just (var - 1).
|
||||
*/
|
||||
statclock_min = statclock_avg - (var / 2);
|
||||
statclock_mask = var - 1;
|
||||
|
||||
KASSERT(schedhz >= 0 && schedhz <= 1000000000);
|
||||
if (schedhz != 0)
|
||||
|
@ -479,70 +475,6 @@ clockintr_stagger(struct clockintr *cl, uint64_t period, u_int n, u_int count)
|
|||
mtx_leave(&cq->cq_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the period (avg) for the given frequency and a range around
|
||||
* that period. The range is [min + 1, min + mask]. The range is used
|
||||
* during dispatch to choose a new pseudorandom deadline for each statclock
|
||||
* event.
|
||||
*/
|
||||
void
|
||||
clockintr_statvar_init(int freq, uint32_t *avg, uint32_t *min, uint32_t *mask)
|
||||
{
|
||||
uint32_t half_avg, var;
|
||||
|
||||
KASSERT(!ISSET(clockintr_flags, CL_INIT | CL_STATCLOCK));
|
||||
KASSERT(freq > 0 && freq <= 1000000000);
|
||||
|
||||
/* Compute avg, the average period. */
|
||||
*avg = 1000000000 / freq;
|
||||
|
||||
/* Find var, the largest power of two such that var <= avg / 2. */
|
||||
half_avg = *avg / 2;
|
||||
for (var = 1U << 31; var > half_avg; var /= 2)
|
||||
continue;
|
||||
|
||||
/* Using avg and var, set a lower bound for the range. */
|
||||
*min = *avg - (var / 2);
|
||||
|
||||
/* The mask is just (var - 1). */
|
||||
*mask = var - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the statclock_* variables according to the given frequency.
|
||||
* Must only be called after clockintr_statvar_init() initializes both
|
||||
* stathz_* and profhz_*.
|
||||
*/
|
||||
void
|
||||
clockintr_setstatclockrate(int freq)
|
||||
{
|
||||
u_int ogen;
|
||||
|
||||
KASSERT(ISSET(clockintr_flags, CL_STATCLOCK));
|
||||
|
||||
mtx_enter(&clockintr_mtx);
|
||||
|
||||
ogen = statclock_gen;
|
||||
statclock_gen = 0;
|
||||
membar_producer();
|
||||
if (freq == stathz) {
|
||||
statclock_avg = stat_avg;
|
||||
statclock_min = stat_min;
|
||||
statclock_mask = stat_mask;
|
||||
} else if (freq == profhz) {
|
||||
statclock_avg = prof_avg;
|
||||
statclock_min = prof_min;
|
||||
statclock_mask = prof_mask;
|
||||
} else {
|
||||
panic("%s: frequency is not stathz (%d) or profhz (%d): %d",
|
||||
__func__, stathz, profhz, freq);
|
||||
}
|
||||
membar_producer();
|
||||
statclock_gen = MAX(1, ogen + 1);
|
||||
|
||||
mtx_leave(&clockintr_mtx);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
clockintr_nsecuptime(const struct clockintr *cl)
|
||||
{
|
||||
|
@ -577,24 +509,16 @@ void
|
|||
clockintr_statclock(struct clockintr *cl, void *frame)
|
||||
{
|
||||
uint64_t count, expiration, i, uptime;
|
||||
uint32_t mask, min, off;
|
||||
u_int gen;
|
||||
uint32_t off;
|
||||
|
||||
if (ISSET(clockintr_flags, CL_RNDSTAT)) {
|
||||
do {
|
||||
gen = statclock_gen;
|
||||
membar_consumer();
|
||||
min = statclock_min;
|
||||
mask = statclock_mask;
|
||||
membar_consumer();
|
||||
} while (gen == 0 || gen != statclock_gen);
|
||||
count = 0;
|
||||
expiration = clockintr_expiration(cl);
|
||||
uptime = clockintr_nsecuptime(cl);
|
||||
while (expiration <= uptime) {
|
||||
while ((off = (random() & mask)) == 0)
|
||||
while ((off = (random() & statclock_mask)) == 0)
|
||||
continue;
|
||||
expiration += min + off;
|
||||
expiration += statclock_min + off;
|
||||
count++;
|
||||
}
|
||||
clockintr_schedule(cl, expiration);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_sched.c,v 1.79 2023/07/14 07:07:08 claudio Exp $ */
|
||||
/* $OpenBSD: kern_sched.c,v 1.80 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
|
||||
*
|
||||
|
@ -21,6 +21,8 @@
|
|||
#include <sys/proc.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/clockintr.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/task.h>
|
||||
#include <sys/smr.h>
|
||||
#include <sys/tracepoint.h>
|
||||
|
@ -85,6 +87,15 @@ sched_init_cpu(struct cpu_info *ci)
|
|||
|
||||
spc->spc_idleproc = NULL;
|
||||
|
||||
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__);
|
||||
clockintr_stagger(spc->spc_profclock, profclock_period,
|
||||
CPU_INFO_UNIT(ci), MAXCPUS);
|
||||
}
|
||||
|
||||
kthread_create_deferred(sched_kthreads_create, ci);
|
||||
|
||||
LIST_INIT(&spc->spc_deadproc);
|
||||
|
@ -214,6 +225,11 @@ sched_exit(struct proc *p)
|
|||
timespecsub(&ts, &spc->spc_runtime, &ts);
|
||||
timespecadd(&p->p_rtime, &ts, &p->p_rtime);
|
||||
|
||||
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_cancel(spc->spc_profclock);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&spc->spc_deadproc, p, p_hash);
|
||||
|
||||
#ifdef MULTIPROCESSOR
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: sched_bsd.c,v 1.77 2023/07/11 07:02:43 claudio Exp $ */
|
||||
/* $OpenBSD: sched_bsd.c,v 1.78 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/clockintr.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
|
@ -349,6 +350,12 @@ mi_switch(void)
|
|||
/* add the time counts for this thread to the process's total */
|
||||
tuagg_unlocked(pr, p);
|
||||
|
||||
/* Stop the profclock if it's running. */
|
||||
if (ISSET(spc->spc_schedflags, SPCF_PROFCLOCK)) {
|
||||
atomic_clearbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK);
|
||||
clockintr_cancel(spc->spc_profclock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process is about to yield the CPU; clear the appropriate
|
||||
* scheduling flags.
|
||||
|
@ -393,6 +400,14 @@ mi_switch(void)
|
|||
*/
|
||||
KASSERT(p->p_cpu == curcpu());
|
||||
|
||||
/* Start the profclock if profil(2) is enabled. */
|
||||
if (ISSET(p->p_p->ps_flags, PS_PROFIL)) {
|
||||
atomic_setbits_int(&p->p_cpu->ci_schedstate.spc_schedflags,
|
||||
SPCF_PROFCLOCK);
|
||||
clockintr_advance(p->p_cpu->ci_schedstate.spc_profclock,
|
||||
profclock_period);
|
||||
}
|
||||
|
||||
nanouptime(&p->p_cpu->ci_schedstate.spc_runtime);
|
||||
|
||||
#ifdef MULTIPROCESSOR
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: subr_prof.c,v 1.35 2023/06/02 17:44:29 cheloha Exp $ */
|
||||
/* $OpenBSD: subr_prof.c,v 1.36 2023/07/25 18:16:19 cheloha Exp $ */
|
||||
/* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -34,13 +34,17 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/clockintr.h>
|
||||
#include <sys/pledge.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syscallargs.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
uint32_t profclock_period;
|
||||
|
||||
#if defined(GPROF) || defined(DDBPROF)
|
||||
#include <sys/malloc.h>
|
||||
|
@ -60,6 +64,8 @@ u_int gmon_cpu_count; /* [K] number of CPUs with profiling enabled */
|
|||
|
||||
extern char etext[];
|
||||
|
||||
void gmonclock(struct clockintr *, void *);
|
||||
|
||||
void
|
||||
prof_init(void)
|
||||
{
|
||||
|
@ -95,6 +101,14 @@ prof_init(void)
|
|||
|
||||
/* Allocate and initialize one profiling buffer per CPU. */
|
||||
CPU_INFO_FOREACH(cii, ci) {
|
||||
ci->ci_gmonclock = clockintr_establish(&ci->ci_queue,
|
||||
gmonclock);
|
||||
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");
|
||||
|
@ -124,8 +138,9 @@ prof_init(void)
|
|||
}
|
||||
|
||||
int
|
||||
prof_state_toggle(struct gmonparam *gp, int oldstate)
|
||||
prof_state_toggle(struct cpu_info *ci, int oldstate)
|
||||
{
|
||||
struct gmonparam *gp = ci->ci_gmon;
|
||||
int error = 0;
|
||||
|
||||
KERNEL_ASSERT_LOCKED();
|
||||
|
@ -145,6 +160,7 @@ prof_state_toggle(struct gmonparam *gp, int oldstate)
|
|||
if (error == 0) {
|
||||
if (++gmon_cpu_count == 1)
|
||||
startprofclock(&process0);
|
||||
clockintr_advance(ci->ci_gmonclock, profclock_period);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -152,6 +168,7 @@ prof_state_toggle(struct gmonparam *gp, int oldstate)
|
|||
gp->state = GMON_PROF_OFF;
|
||||
/* FALLTHROUGH */
|
||||
case GMON_PROF_OFF:
|
||||
clockintr_cancel(ci->ci_gmonclock);
|
||||
if (--gmon_cpu_count == 0)
|
||||
stopprofclock(&process0);
|
||||
#if !defined(GPROF)
|
||||
|
@ -201,7 +218,7 @@ sysctl_doprof(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
|
|||
error = sysctl_int(oldp, oldlenp, newp, newlen, &gp->state);
|
||||
if (error)
|
||||
return (error);
|
||||
return (prof_state_toggle(gp, state));
|
||||
return prof_state_toggle(ci, state);
|
||||
case GPROF_COUNT:
|
||||
return (sysctl_struct(oldp, oldlenp, newp, newlen,
|
||||
gp->kcount, gp->kcountsize));
|
||||
|
@ -218,6 +235,31 @@ sysctl_doprof(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
|
|||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
gmonclock(struct clockintr *cl, void *cf)
|
||||
{
|
||||
uint64_t count;
|
||||
struct clockframe *frame = cf;
|
||||
struct gmonparam *g = curcpu()->ci_gmon;
|
||||
u_long i;
|
||||
|
||||
count = clockintr_advance(cl, profclock_period);
|
||||
if (count > ULONG_MAX)
|
||||
count = ULONG_MAX;
|
||||
|
||||
/*
|
||||
* Kernel statistics are just like addupc_intr(), only easier.
|
||||
*/
|
||||
if (!CLKF_USERMODE(frame) && g != NULL && g->state == GMON_PROF_ON) {
|
||||
i = CLKF_PC(frame) - g->lowpc;
|
||||
if (i < g->textsize) {
|
||||
i /= HISTFRACTION * sizeof(*g->kcount);
|
||||
g->kcount[i] += (u_long)count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GPROF || DDBPROF */
|
||||
|
||||
/*
|
||||
|
@ -247,6 +289,7 @@ sys_profil(struct proc *p, void *v, register_t *retval)
|
|||
return (EINVAL);
|
||||
if (SCARG(uap, scale) == 0) {
|
||||
stopprofclock(pr);
|
||||
need_resched(curcpu());
|
||||
return (0);
|
||||
}
|
||||
upp = &pr->ps_prof;
|
||||
|
@ -259,10 +302,31 @@ sys_profil(struct proc *p, void *v, register_t *retval)
|
|||
upp->pr_size = SCARG(uap, size);
|
||||
startprofclock(pr);
|
||||
splx(s);
|
||||
need_resched(curcpu());
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
profclock(struct clockintr *cl, void *cf)
|
||||
{
|
||||
uint64_t count;
|
||||
struct clockframe *frame = cf;
|
||||
struct proc *p = curproc;
|
||||
|
||||
count = clockintr_advance(cl, profclock_period);
|
||||
if (count > ULONG_MAX)
|
||||
count = ULONG_MAX;
|
||||
|
||||
if (CLKF_USERMODE(frame)) {
|
||||
if (ISSET(p->p_p->ps_flags, PS_PROFIL))
|
||||
addupc_intr(p, CLKF_PC(frame), (u_long)count);
|
||||
} else {
|
||||
if (p != NULL && ISSET(p->p_p->ps_flags, PS_PROFIL))
|
||||
addupc_intr(p, PROC_PC(p), (u_long)count);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Scale is a fixed-point number with the binary point 16 bits
|
||||
* into the value, and is <= 1.0. pc is at most 32 bits, so the
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: syscalls.c,v 1.264 2023/05/18 10:24:28 mvs Exp $ */
|
||||
/* $OpenBSD: syscalls.c,v 1.265 2023/07/24 19:33:29 miod Exp $ */
|
||||
|
||||
/*
|
||||
* System call names.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.249 2023/07/24 19:32:23 miod Exp
|
||||
*/
|
||||
|
||||
const char *const syscallnames[] = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $OpenBSD: syscalls.master,v 1.248 2023/05/18 10:23:19 mvs Exp $
|
||||
; $OpenBSD: syscalls.master,v 1.249 2023/07/24 19:32:23 miod Exp $
|
||||
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
|
||||
|
||||
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
||||
|
@ -279,7 +279,7 @@
|
|||
139 OBSOL 4.2 sigreturn
|
||||
140 STD NOLOCK { int sys_adjtime(const struct timeval *delta, \
|
||||
struct timeval *olddelta); }
|
||||
141 STD { int sys_getlogin_r(char *namebuf, u_int namelen); }
|
||||
141 STD { int sys_getlogin_r(char *namebuf, size_t namelen); }
|
||||
142 STD { int sys_getthrname(pid_t tid, char *name, size_t len); }
|
||||
143 STD { int sys_setthrname(pid_t tid, const char *name); }
|
||||
144 OBSOL ogetrlimit
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uipc_socket.c,v 1.305 2023/07/04 22:28:24 mvs Exp $ */
|
||||
/* $OpenBSD: uipc_socket.c,v 1.306 2023/07/22 14:30:39 mvs Exp $ */
|
||||
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -2366,7 +2366,8 @@ sobuf_print(struct sockbuf *sb,
|
|||
(*pr)("\tsb_mbtail: %p\n", sb->sb_mbtail);
|
||||
(*pr)("\tsb_lastrecord: %p\n", sb->sb_lastrecord);
|
||||
(*pr)("\tsb_sel: ...\n");
|
||||
(*pr)("\tsb_flags: %i\n", sb->sb_flags);
|
||||
(*pr)("\tsb_flags: %04x\n", sb->sb_flags);
|
||||
(*pr)("\tsb_state: %04x\n", sb->sb_state);
|
||||
(*pr)("\tsb_timeo_nsecs: %llu\n", sb->sb_timeo_nsecs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue