1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-28 08:07:03 +00:00

Remove last callers of the 'lbolt' sleep channel.

When a process in a background group attempts TTY I/O, it is currently
put to sleep on 'lbolt'. This relies on the 1Hz wakeup() from schedcpu().
Replace ttysleep(tp, &lbolt, ...) with ttysleep_nsec(tp, &nowake,
..., SEC_TO_NSEC(1)) and remove unused 'lbolt' channel.

From Tim Leslie, ok claudio.
This commit is contained in:
mvs
2025-09-25 08:46:50 +00:00
parent 15f5326ca8
commit ba454d9751
5 changed files with 16 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: sched_bsd.c,v 1.104 2025/08/01 10:53:23 claudio Exp $ */
/* $OpenBSD: sched_bsd.c,v 1.105 2025/09/25 08:46:50 mvs Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@@ -55,7 +55,6 @@
#endif
uint64_t roundrobin_period; /* [I] roundrobin period (ns) */
int lbolt; /* once a second sleep address */
struct mutex sched_lock;
@@ -282,7 +281,6 @@ schedcpu(void *unused)
}
SCHED_UNLOCK();
}
wakeup(&lbolt);
timeout_add_sec(&to, 1);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty.c,v 1.181 2025/09/23 08:00:48 mpi Exp $ */
/* $OpenBSD: tty.c,v 1.182 2025/09/25 08:46:50 mvs Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -79,7 +79,6 @@ void filt_ttywdetach(struct knote *kn);
int filt_ttyexcept(struct knote *kn, long hint);
void ttystats_init(struct itty **, int *, size_t *);
int ttywait_nsec(struct tty *, uint64_t);
int ttysleep_nsec(struct tty *, void *, int, char *, uint64_t);
/* Symbolic sleep message strings. */
char ttclos[] = "ttycls";
@@ -747,8 +746,8 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
if (pr->ps_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(pr->ps_pgrp, SIGTTOU, 1);
error = ttysleep(tp, &lbolt, TTOPRI | PCATCH,
ttybg);
error = ttysleep_nsec(tp, &nowake, TTOPRI | PCATCH,
ttybg, SEC_TO_NSEC(1));
if (error)
return (error);
}
@@ -1515,7 +1514,8 @@ loop: lflag = tp->t_lflag;
goto out;
}
pgsignal(pr->ps_pgrp, SIGTTIN, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg);
error = ttysleep_nsec(tp, &nowake, TTIPRI | PCATCH, ttybg,
SEC_TO_NSEC(1));
if (error)
goto out;
goto loop;
@@ -1613,8 +1613,8 @@ read:
ISSET(lflag, IEXTEN | ISIG) == (IEXTEN | ISIG)) {
pgsignal(tp->t_pgrp, SIGTSTP, 1);
if (first) {
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH,
ttybg);
error = ttysleep_nsec(tp, &nowake, TTIPRI | PCATCH,
ttybg, SEC_TO_NSEC(1));
if (error)
break;
goto loop;
@@ -1765,7 +1765,8 @@ loop:
goto out;
}
pgsignal(pr->ps_pgrp, SIGTTOU, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg);
error = ttysleep_nsec(tp, &nowake, TTIPRI | PCATCH, ttybg,
SEC_TO_NSEC(1));
if (error)
goto out;
goto loop;

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty_pty.c,v 1.115 2024/11/05 06:03:19 jsg Exp $ */
/* $OpenBSD: tty_pty.c,v 1.116 2025/09/25 08:46:50 mvs Exp $ */
/* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */
/*
@@ -294,7 +294,8 @@ again:
pr->ps_flags & PS_PPWAIT)
return (EIO);
pgsignal(pr->ps_pgrp, SIGTTIN, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg);
error = ttysleep_nsec(tp, &nowake, TTIPRI | PCATCH,
ttybg, SEC_TO_NSEC(1));
if (error)
return (error);
}

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: kernel.h,v 1.27 2024/08/14 13:54:08 mvs Exp $ */
/* $OpenBSD: kernel.h,v 1.28 2025/09/25 08:46:50 mvs Exp $ */
/* $NetBSD: kernel.h,v 1.11 1995/03/03 01:24:16 cgd Exp $ */
/*-
@@ -55,7 +55,6 @@ extern int ticks; /* # of hardclock ticks */
extern int hz; /* system clock's frequency */
extern int stathz; /* statistics clock's frequency */
extern int profhz; /* profiling clock's frequency */
extern int lbolt; /* once a second sleep address */
#ifndef HZ
#define HZ 100

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: tty.h,v 1.44 2024/10/26 00:56:35 jsg Exp $ */
/* $OpenBSD: tty.h,v 1.45 2025/09/25 08:46:50 mvs Exp $ */
/* $NetBSD: tty.h,v 1.30.4.1 1996/06/02 09:08:13 mrg Exp $ */
/*-
@@ -290,6 +290,7 @@ void ttypend(struct tty *tp);
int ttyretype(struct tty *tp);
int ttyrub(int c, struct tty *tp);
int ttysleep(struct tty *tp, void *chan, int pri, char *wmesg);
int ttysleep_nsec(struct tty *, void *, int, char *, uint64_t);
int ttywait(struct tty *tp);
int ttywflush(struct tty *tp);
void ttytstamp(struct tty *tp, int octs, int ncts, int odcd, int ndcd);