ttycheckoutq(9): wait=0 always, parameter no longer useful, nix it. XXX kernel revbumpdiff -r1.199 -r1.200 src/sys/kern/subr_prf.c
(riastradh)
--- src/sys/kern/subr_prf.c 2023/04/09 09:18:09 1.199
+++ src/sys/kern/subr_prf.c 2023/04/12 06:35:26 1.200
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: subr_prf.c,v 1.199 2023/04/09 09:18:09 riastradh Exp $ */ | 1 | /* $NetBSD: subr_prf.c,v 1.200 2023/04/12 06:35:26 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1986, 1988, 1991, 1993 | 4 | * Copyright (c) 1986, 1988, 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * (c) UNIX System Laboratories, Inc. | 6 | * (c) UNIX System Laboratories, Inc. | |
7 | * All or some portions of this file are derived from material licensed | 7 | * All or some portions of this file are derived from material licensed | |
8 | * to the University of California by American Telephone and Telegraph | 8 | * to the University of California by American Telephone and Telegraph | |
9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
10 | * the permission of UNIX System Laboratories, Inc. | 10 | * the permission of UNIX System Laboratories, Inc. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
34 | * SUCH DAMAGE. | 34 | * SUCH DAMAGE. | |
35 | * | 35 | * | |
36 | * @(#)subr_prf.c 8.4 (Berkeley) 5/4/95 | 36 | * @(#)subr_prf.c 8.4 (Berkeley) 5/4/95 | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.199 2023/04/09 09:18:09 riastradh Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.200 2023/04/12 06:35:26 riastradh Exp $"); | |
41 | 41 | |||
42 | #ifdef _KERNEL_OPT | 42 | #ifdef _KERNEL_OPT | |
43 | #include "opt_ddb.h" | 43 | #include "opt_ddb.h" | |
44 | #include "opt_kgdb.h" | 44 | #include "opt_kgdb.h" | |
45 | #include "opt_dump.h" | 45 | #include "opt_dump.h" | |
46 | #include "opt_rnd_printf.h" | 46 | #include "opt_rnd_printf.h" | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
50 | #include <sys/stdint.h> | 50 | #include <sys/stdint.h> | |
51 | #include <sys/systm.h> | 51 | #include <sys/systm.h> | |
52 | #include <sys/buf.h> | 52 | #include <sys/buf.h> | |
53 | #include <sys/device.h> | 53 | #include <sys/device.h> | |
@@ -632,27 +632,27 @@ tprintf_close(tpr_t sess) | @@ -632,27 +632,27 @@ tprintf_close(tpr_t sess) | |||
632 | * send a message to the controlling tty for that process. | 632 | * send a message to the controlling tty for that process. | |
633 | * | 633 | * | |
634 | * => also sends message to /dev/klog | 634 | * => also sends message to /dev/klog | |
635 | */ | 635 | */ | |
636 | void | 636 | void | |
637 | tprintf(tpr_t tpr, const char *fmt, ...) | 637 | tprintf(tpr_t tpr, const char *fmt, ...) | |
638 | { | 638 | { | |
639 | struct session *sess = (struct session *)tpr; | 639 | struct session *sess = (struct session *)tpr; | |
640 | struct tty *tp = NULL; | 640 | struct tty *tp = NULL; | |
641 | int flags = TOLOG; | 641 | int flags = TOLOG; | |
642 | va_list ap; | 642 | va_list ap; | |
643 | 643 | |||
644 | /* mutex_enter(&proc_lock); XXXSMP */ | 644 | /* mutex_enter(&proc_lock); XXXSMP */ | |
645 | if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp, 0)) { | 645 | if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp)) { | |
646 | flags |= TOTTY; | 646 | flags |= TOTTY; | |
647 | tp = sess->s_ttyp; | 647 | tp = sess->s_ttyp; | |
648 | } | 648 | } | |
649 | 649 | |||
650 | kprintf_lock(); | 650 | kprintf_lock(); | |
651 | 651 | |||
652 | klogpri(LOG_INFO); | 652 | klogpri(LOG_INFO); | |
653 | va_start(ap, fmt); | 653 | va_start(ap, fmt); | |
654 | kprintf(fmt, flags, tp, NULL, ap); | 654 | kprintf(fmt, flags, tp, NULL, ap); | |
655 | va_end(ap); | 655 | va_end(ap); | |
656 | 656 | |||
657 | kprintf_unlock(); | 657 | kprintf_unlock(); | |
658 | /* mutex_exit(&proc_lock); XXXSMP */ | 658 | /* mutex_exit(&proc_lock); XXXSMP */ |
--- src/sys/kern/tty.c 2023/04/11 10:23:47 1.309
+++ src/sys/kern/tty.c 2023/04/12 06:35:26 1.310
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tty.c,v 1.309 2023/04/11 10:23:47 riastradh Exp $ */ | 1 | /* $NetBSD: tty.c,v 1.310 2023/04/12 06:35:26 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -53,27 +53,27 @@ | @@ -53,27 +53,27 @@ | |||
53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 | * SUCH DAMAGE. | 60 | * SUCH DAMAGE. | |
61 | * | 61 | * | |
62 | * @(#)tty.c 8.13 (Berkeley) 1/9/95 | 62 | * @(#)tty.c 8.13 (Berkeley) 1/9/95 | |
63 | */ | 63 | */ | |
64 | 64 | |||
65 | #include <sys/cdefs.h> | 65 | #include <sys/cdefs.h> | |
66 | __KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.309 2023/04/11 10:23:47 riastradh Exp $"); | 66 | __KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.310 2023/04/12 06:35:26 riastradh Exp $"); | |
67 | 67 | |||
68 | #ifdef _KERNEL_OPT | 68 | #ifdef _KERNEL_OPT | |
69 | #include "opt_compat_netbsd.h" | 69 | #include "opt_compat_netbsd.h" | |
70 | #endif | 70 | #endif | |
71 | 71 | |||
72 | #define TTY_ALLOW_PRIVATE | 72 | #define TTY_ALLOW_PRIVATE | |
73 | 73 | |||
74 | #include <sys/param.h> | 74 | #include <sys/param.h> | |
75 | #include <sys/systm.h> | 75 | #include <sys/systm.h> | |
76 | #include <sys/ioctl.h> | 76 | #include <sys/ioctl.h> | |
77 | #include <sys/proc.h> | 77 | #include <sys/proc.h> | |
78 | #define TTYDEFCHARS | 78 | #define TTYDEFCHARS | |
79 | #include <sys/tty.h> | 79 | #include <sys/tty.h> | |
@@ -2183,51 +2183,49 @@ ttread(struct tty *tp, struct uio *uio, | @@ -2183,51 +2183,49 @@ ttread(struct tty *tp, struct uio *uio, | |||
2183 | 2183 | |||
2184 | return (error); | 2184 | return (error); | |
2185 | } | 2185 | } | |
2186 | 2186 | |||
2187 | /* | 2187 | /* | |
2188 | * Check the output queue on tp for space for a kernel message (from uprintf | 2188 | * Check the output queue on tp for space for a kernel message (from uprintf | |
2189 | * or tprintf). Allow some space over the normal hiwater mark so we don't | 2189 | * or tprintf). Allow some space over the normal hiwater mark so we don't | |
2190 | * lose messages due to normal flow control, but don't let the tty run amok. | 2190 | * lose messages due to normal flow control, but don't let the tty run amok. | |
2191 | * Sleeps here are not interruptible, but we return prematurely if new signals | 2191 | * Sleeps here are not interruptible, but we return prematurely if new signals | |
2192 | * arrive. | 2192 | * arrive. | |
2193 | * Call with tty lock held. | 2193 | * Call with tty lock held. | |
2194 | */ | 2194 | */ | |
2195 | static int | 2195 | static int | |
2196 | ttycheckoutq_wlock(struct tty *tp, int wait) | 2196 | ttycheckoutq_wlock(struct tty *tp) | |
2197 | { | 2197 | { | |
2198 | int hiwat; | 2198 | int hiwat; | |
2199 | 2199 | |||
2200 | KASSERT(mutex_owned(&tty_lock)); | 2200 | KASSERT(mutex_owned(&tty_lock)); | |
2201 | 2201 | |||
2202 | KASSERT(wait == 0); | |||
2203 | ||||
2204 | hiwat = tp->t_hiwat; | 2202 | hiwat = tp->t_hiwat; | |
2205 | if (tp->t_outq.c_cc > hiwat + 200) | 2203 | if (tp->t_outq.c_cc > hiwat + 200) | |
2206 | if (tp->t_outq.c_cc > hiwat) { | 2204 | if (tp->t_outq.c_cc > hiwat) { | |
2207 | ttstart(tp); | 2205 | ttstart(tp); | |
2208 | return (0); | 2206 | return (0); | |
2209 | } | 2207 | } | |
2210 | 2208 | |||
2211 | return (1); | 2209 | return (1); | |
2212 | } | 2210 | } | |
2213 | 2211 | |||
2214 | int | 2212 | int | |
2215 | ttycheckoutq(struct tty *tp, int wait) | 2213 | ttycheckoutq(struct tty *tp) | |
2216 | { | 2214 | { | |
2217 | int r; | 2215 | int r; | |
2218 | 2216 | |||
2219 | mutex_spin_enter(&tty_lock); | 2217 | mutex_spin_enter(&tty_lock); | |
2220 | r = ttycheckoutq_wlock(tp, wait); | 2218 | r = ttycheckoutq_wlock(tp); | |
2221 | mutex_spin_exit(&tty_lock); | 2219 | mutex_spin_exit(&tty_lock); | |
2222 | 2220 | |||
2223 | return (r); | 2221 | return (r); | |
2224 | } | 2222 | } | |
2225 | 2223 | |||
2226 | /* | 2224 | /* | |
2227 | * Process a write call on a tty device. | 2225 | * Process a write call on a tty device. | |
2228 | */ | 2226 | */ | |
2229 | int | 2227 | int | |
2230 | ttwrite(struct tty *tp, struct uio *uio, int flag) | 2228 | ttwrite(struct tty *tp, struct uio *uio, int flag) | |
2231 | { | 2229 | { | |
2232 | u_char *cp; | 2230 | u_char *cp; | |
2233 | struct proc *p; | 2231 | struct proc *p; | |
@@ -2791,27 +2789,27 @@ ttygetinfo(struct tty *tp, int fromsig, | @@ -2791,27 +2789,27 @@ ttygetinfo(struct tty *tp, int fromsig, | |||
2791 | strlcat(buf, lmsg, bufsz); | 2789 | strlcat(buf, lmsg, bufsz); | |
2792 | } | 2790 | } | |
2793 | 2791 | |||
2794 | /* | 2792 | /* | |
2795 | * Print report on state of foreground process group. | 2793 | * Print report on state of foreground process group. | |
2796 | * Call with tty_lock held. | 2794 | * Call with tty_lock held. | |
2797 | */ | 2795 | */ | |
2798 | void | 2796 | void | |
2799 | ttyputinfo(struct tty *tp, char *buf) | 2797 | ttyputinfo(struct tty *tp, char *buf) | |
2800 | { | 2798 | { | |
2801 | 2799 | |||
2802 | KASSERT(mutex_owned(&tty_lock)); | 2800 | KASSERT(mutex_owned(&tty_lock)); | |
2803 | 2801 | |||
2804 | if (ttycheckoutq_wlock(tp, 0) == 0) | 2802 | if (ttycheckoutq_wlock(tp) == 0) | |
2805 | return; | 2803 | return; | |
2806 | ttyprintf_nolock(tp, "%s\n", buf); | 2804 | ttyprintf_nolock(tp, "%s\n", buf); | |
2807 | tp->t_rocount = 0; /* so pending input will be retyped if BS */ | 2805 | tp->t_rocount = 0; /* so pending input will be retyped if BS */ | |
2808 | } | 2806 | } | |
2809 | 2807 | |||
2810 | /* | 2808 | /* | |
2811 | * Returns 1 if p2 has a better chance being the active foreground process | 2809 | * Returns 1 if p2 has a better chance being the active foreground process | |
2812 | * in a terminal instead of p1. | 2810 | * in a terminal instead of p1. | |
2813 | */ | 2811 | */ | |
2814 | static int | 2812 | static int | |
2815 | proc_compare_wrapper(struct proc *p1, struct proc *p2) | 2813 | proc_compare_wrapper(struct proc *p1, struct proc *p2) | |
2816 | { | 2814 | { | |
2817 | lwp_t *l1, *l2; | 2815 | lwp_t *l1, *l2; |
--- src/sys/sys/tty.h 2022/10/26 23:41:49 1.103
+++ src/sys/sys/tty.h 2023/04/12 06:35:26 1.104
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tty.h,v 1.103 2022/10/26 23:41:49 riastradh Exp $ */ | 1 | /* $NetBSD: tty.h,v 1.104 2023/04/12 06:35:26 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -275,27 +275,27 @@ int unputc(struct clist *); | @@ -275,27 +275,27 @@ int unputc(struct clist *); | |||
275 | 275 | |||
276 | int nullmodem(struct tty *, int); | 276 | int nullmodem(struct tty *, int); | |
277 | int tputchar(int, int, struct tty *); | 277 | int tputchar(int, int, struct tty *); | |
278 | int ttioctl(struct tty *, u_long, void *, int, struct lwp *); | 278 | int ttioctl(struct tty *, u_long, void *, int, struct lwp *); | |
279 | int ttread(struct tty *, struct uio *, int); | 279 | int ttread(struct tty *, struct uio *, int); | |
280 | void ttrstrt(void *); | 280 | void ttrstrt(void *); | |
281 | int ttpoll(struct tty *, int, struct lwp *); | 281 | int ttpoll(struct tty *, int, struct lwp *); | |
282 | void ttsetwater(struct tty *); | 282 | void ttsetwater(struct tty *); | |
283 | int ttspeedtab(int, const struct speedtab *); | 283 | int ttspeedtab(int, const struct speedtab *); | |
284 | int ttstart(struct tty *); | 284 | int ttstart(struct tty *); | |
285 | void ttwakeup(struct tty *); | 285 | void ttwakeup(struct tty *); | |
286 | int ttwrite(struct tty *, struct uio *, int); | 286 | int ttwrite(struct tty *, struct uio *, int); | |
287 | void ttychars(struct tty *); | 287 | void ttychars(struct tty *); | |
288 | int ttycheckoutq(struct tty *, int); | 288 | int ttycheckoutq(struct tty *); | |
289 | void ttycancel(struct tty *); | 289 | void ttycancel(struct tty *); | |
290 | int ttyclose(struct tty *); | 290 | int ttyclose(struct tty *); | |
291 | void ttyflush(struct tty *, int); | 291 | void ttyflush(struct tty *, int); | |
292 | void ttygetinfo(struct tty *, int, char *, size_t); | 292 | void ttygetinfo(struct tty *, int, char *, size_t); | |
293 | void ttyputinfo(struct tty *, char *); | 293 | void ttyputinfo(struct tty *, char *); | |
294 | int ttyinput(int, struct tty *); | 294 | int ttyinput(int, struct tty *); | |
295 | int ttyinput_wlock(int, struct tty *); /* XXX see wsdisplay.c */ | 295 | int ttyinput_wlock(int, struct tty *); /* XXX see wsdisplay.c */ | |
296 | int ttylclose(struct tty *, int); | 296 | int ttylclose(struct tty *, int); | |
297 | int ttylopen(dev_t, struct tty *); | 297 | int ttylopen(dev_t, struct tty *); | |
298 | int ttykqfilter(dev_t, struct knote *); | 298 | int ttykqfilter(dev_t, struct knote *); | |
299 | int ttymodem(struct tty *, int); | 299 | int ttymodem(struct tty *, int); | |
300 | int ttyopen(struct tty *, int, int); | 300 | int ttyopen(struct tty *, int, int); | |
301 | int ttyoutput(int, struct tty *); | 301 | int ttyoutput(int, struct tty *); |