Download raw body.
Remove last callers of the lbolt sleep channel
On Wed, Sep 24, 2025 at 08:07:29PM +0300, Vitaliy Makkoveev wrote:
> On Wed, Sep 24, 2025 at 04:20:08PM +0000, Tim Leslie wrote:
> > > > So I prefer to use `nowake', because this 100% exclude the fallout from
> > > > current or hypothetical newly introduced wakeup(pr->ps_pgrp).
> > >
> > >
> > > I agree with this. Replacing this with 'nowake' is the right way since
> > > only the 1sec timer should wake up these ttysleeps.
> >
> > Updated diff below.
> >
> > Tim
> >
>
> Since you added ttysleep_nsec() declaration to sys/tty.h, you don't need
> this declaration in kern/tty.c. With this fix this diff is ok by mvs.
>
> I will commit it by myself unless someone has objections or commit it by
> himself.
OK claudio@ with your removal of the extra ttysleep_nsec() prototype.
> > --
> >
> >
> >
> > diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c
> > --- a/sys/kern/sched_bsd.c
> > +++ b/sys/kern/sched_bsd.c
> > @@ -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);
> > }
> >
> > diff --git a/sys/kern/tty.c b/sys/kern/tty.c
> > --- a/sys/kern/tty.c
> > +++ b/sys/kern/tty.c
> > @@ -747,8 +747,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 +1515,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 +1614,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 +1766,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;
> > diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
> > --- a/sys/kern/tty_pty.c
> > +++ b/sys/kern/tty_pty.c
> > @@ -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);
> > }
> > diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h
> > --- a/sys/sys/kernel.h
> > +++ b/sys/sys/kernel.h
> > @@ -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
> > diff --git a/sys/sys/tty.h b/sys/sys/tty.h
> > --- a/sys/sys/tty.h
> > +++ b/sys/sys/tty.h
> > @@ -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);
> >
>
--
:wq Claudio
Remove last callers of the lbolt sleep channel