From owner-svn-src-all@FreeBSD.ORG Mon Oct 19 07:17:38 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32DD1106566C; Mon, 19 Oct 2009 07:17:38 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 084F48FC24; Mon, 19 Oct 2009 07:17:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9J7Hbx2094536; Mon, 19 Oct 2009 07:17:37 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9J7HbpP094533; Mon, 19 Oct 2009 07:17:37 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200910190717.n9J7HbpP094533@svn.freebsd.org> From: Ed Schouten Date: Mon, 19 Oct 2009 07:17:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198223 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2009 07:17:38 -0000 Author: ed Date: Mon Oct 19 07:17:37 2009 New Revision: 198223 URL: http://svn.freebsd.org/changeset/base/198223 Log: Properly set the low watermarks when reducing the baud rate. Now that buffers are deallocated lazily, we should not use tty*q_getsize() to obtain the buffer size to calculate the low watermarks. Doing this may cause the watermark to be placed outside the typical buffer size. This caused some regressions after my previous commit to the TTY code, which allows pseudo-devices to resize the buffers as well. Reported by: yongari, dougb MFC after: 1 week Modified: head/sys/kern/tty.c head/sys/sys/ttyqueue.h Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Sun Oct 18 23:38:59 2009 (r198222) +++ head/sys/kern/tty.c Mon Oct 19 07:17:37 2009 (r198223) @@ -109,14 +109,14 @@ tty_watermarks(struct tty *tp) ttyinq_setsize(&tp->t_inq, tp, bs); /* Set low watermark at 10% (when 90% is available). */ - tp->t_inlow = (ttyinq_getsize(&tp->t_inq) * 9) / 10; + tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10; /* Provide an ouput buffer for 0.2 seconds of data. */ bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX); ttyoutq_setsize(&tp->t_outq, tp, bs); /* Set low watermark at 10% (when 90% is available). */ - tp->t_outlow = (ttyoutq_getsize(&tp->t_outq) * 9) / 10; + tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10; } static int Modified: head/sys/sys/ttyqueue.h ============================================================================== --- head/sys/sys/ttyqueue.h Sun Oct 18 23:38:59 2009 (r198222) +++ head/sys/sys/ttyqueue.h Mon Oct 19 07:17:37 2009 (r198223) @@ -93,6 +93,13 @@ ttyinq_getsize(struct ttyinq *ti) } static __inline size_t +ttyinq_getallocatedsize(struct ttyinq *ti) +{ + + return (ti->ti_quota * TTYINQ_DATASIZE); +} + +static __inline size_t ttyinq_bytesleft(struct ttyinq *ti) { size_t len; @@ -143,6 +150,13 @@ ttyoutq_getsize(struct ttyoutq *to) } static __inline size_t +ttyoutq_getallocatedsize(struct ttyoutq *to) +{ + + return (to->to_quota * TTYOUTQ_DATASIZE); +} + +static __inline size_t ttyoutq_bytesleft(struct ttyoutq *to) { size_t len;