NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/45352: pty(4)/tty(4) have a 1024 bytes transfer limit



The following reply was made to PR kern/45352; it has been noted by GNATS.

From: christos%zoulas.com@localhost (Christos Zoulas)
To: gnats-bugs%NetBSD.org@localhost, kern-bug-people%netbsd.org@localhost, 
        gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/45352: pty(4)/tty(4) have a 1024 bytes transfer limit
Date: Fri, 9 Sep 2011 12:37:54 -0400

 On Sep 9,  1:50pm, mm_lists%pulsar-zone.net@localhost (Matthew Mondor) wrote:
 -- Subject: kern/45352: pty(4)/tty(4) have a 1024 bytes transfer limit
 
 | >Number:         45352
 | >Category:       kern
 | >Synopsis:       pty(4)/tty(4) have a 1024 bytes transfer limit
 | >Confidential:   no
 | >Severity:       non-critical
 | >Priority:       medium
 | >Responsible:    kern-bug-people
 | >State:          open
 | >Class:          change-request
 | >Submitter-Id:   net
 | >Arrival-Date:   Fri Sep 09 13:50:00 +0000 2011
 | >Originator:     Matthew Mondor
 | >Release:        NetBSD 5.1_STABLE
 | >Organization:
 | >Environment:
 | System: NetBSD behemoth.xisop 5.1_STABLE NetBSD 5.1_STABLE (GENERIC_MM) #0: 
Mon Aug 1 12:19:58 EDT 2011 
root@behemoth.xisop:/usr/obj/sys/arch/i386/compile/GENERIC_MM i386
 | Architecture: i386
 | Machine: i386
 | >Description:
 | 
 
 Here's a patch that adds sysctl kern.tty.qsize to change this.
 I have compile and run tested it, but no performance testing for pppd
 
 christos
 
 Index: sys/tty.h
 ===================================================================
 RCS file: /cvsroot/src/sys/sys/tty.h,v
 retrieving revision 1.88
 diff -u -u -r1.88 tty.h
 --- sys/tty.h  26 Jul 2011 13:14:17 -0000      1.88
 +++ sys/tty.h  9 Sep 2011 16:35:27 -0000
 @@ -126,6 +126,7 @@
        int     t_state;                /* Device and driver (TS*) state. */
        int     t_wopen;                /* Processes waiting for open. */
        int     t_flags;                /* Tty flags. */
 +      int     t_qsize;                /* Tty character queue size */
        struct  pgrp *t_pgrp;           /* Foreground process group. */
        struct  session *t_session;     /* Enclosing session. */
        struct  selinfo t_rsel;         /* Tty read/oob select. */
 @@ -162,13 +163,13 @@
  
  #define       TTMASK  15
  #define       OBUFSIZ 100
 -#define       TTYHOG  1024
 +#define       TTYHOG  tp->t_qsize
  
  #ifdef _KERNEL
 -#define       TTMAXHIWAT      roundup(2048, CBSIZE)
 -#define       TTMINHIWAT      roundup(100, CBSIZE)
 -#define       TTMAXLOWAT      256
 -#define       TTMINLOWAT      32
 +#define       TTMAXHIWAT      roundup(tp->t_qsize << 1, CBSIZE)
 +#define       TTMINHIWAT      roundup(tp->t_qsize >> 3, CBSIZE)
 +#define       TTMAXLOWAT      (tp->t_qsize >> 2)
 +#define       TTMINLOWAT      (tp->t_qsize >> 5)
  #endif /* _KERNEL */
  
  /* These flags are kept in t_state. */
 Index: kern/tty.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/tty.c,v
 retrieving revision 1.246
 diff -u -u -r1.246 tty.c
 --- kern/tty.c 26 Jul 2011 13:14:18 -0000      1.246
 +++ kern/tty.c 9 Sep 2011 16:35:30 -0000
 @@ -91,6 +91,7 @@
  #include <sys/intr.h>
  #include <sys/ioctl_compat.h>
  #include <sys/module.h>
 +#include <sys/bitops.h>
  
  static int    ttnread(struct tty *);
  static void   ttyblock(struct tty *);
 @@ -207,12 +208,41 @@
  
  static kauth_listener_t tty_listener;
  
 -static struct sysctllog *kern_tkstat_sysctllog;
 +#define       TTY_MINQSIZE    0x00400
 +#define       TTY_MAXQSIZE    0x10000
 +int tty_qsize = TTY_MINQSIZE;
 +
 +static int
 +sysctl_kern_tty_qsize(SYSCTLFN_ARGS)
 +{
 +      int newsize;
 +      int error;
 +      struct sysctlnode node;
 +      node = *rnode;
 +      node.sysctl_data = &newsize;
 +
 +      newsize = tty_qsize;
 +      error = sysctl_lookup(SYSCTLFN_CALL(&node));
 +      if (error || newp == NULL)
 +              return error;
 +
 +      newsize = 1 << ilog2(newsize);  /* Make it a power of two */ 
 +
 +      if (newsize < TTY_MINQSIZE || newsize > TTY_MAXQSIZE)
 +              return EINVAL;
 +
 +      tty_qsize = newsize;
 +
 +      return 0;
 +}
  
  static void
 -sysctl_kern_tkstat_setup(void)
 +sysctl_kern_tty_setup(void)
  {
 +      const struct sysctlnode *rnode, *cnode;
 +      struct sysctllog *kern_tkstat_sysctllog, *kern_tty_sysctllog;
  
 +      kern_tkstat_sysctllog = NULL;
        sysctl_createv(&kern_tkstat_sysctllog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT,
                       CTLTYPE_NODE, "kern", NULL,
 @@ -250,6 +280,19 @@
                       SYSCTL_DESCR("Number of raw tty input characters"),
                       NULL, 0, &tk_rawcc, 0,
                       CTL_KERN, KERN_TKSTAT, KERN_TKSTAT_RAWCC, CTL_EOL);
 +
 +      kern_tty_sysctllog = NULL;
 +      sysctl_createv(&kern_tty_sysctllog, 0, NULL, &rnode,
 +                     CTLFLAG_PERMANENT,
 +                     CTLTYPE_NODE, "tty", NULL,
 +                     NULL, 0, NULL, 0,
 +                     CTL_KERN, CTL_CREATE, CTL_EOL);
 +      sysctl_createv(&kern_tty_sysctllog, 0, &rnode, &cnode,
 +                     CTLFLAG_PERMANENT,
 +                     CTLTYPE_INT, "qsize",
 +                     SYSCTL_DESCR("TTY input and output queue size"),
 +                     sysctl_kern_tty_qsize, 0, &tty_qsize, 0,
 +                     CTL_CREATE, CTL_EOL);
  }
  
  int
 @@ -2694,15 +2737,15 @@
        tp = kmem_zalloc(sizeof(*tp), KM_SLEEP);
        callout_init(&tp->t_rstrt_ch, 0);
        callout_setfunc(&tp->t_rstrt_ch, ttrstrt, tp);
 -      /* XXX: default to 1024 chars for now */
 -      clalloc(&tp->t_rawq, 1024, 1);
 +      tp->t_qsize = tty_qsize;
 +      clalloc(&tp->t_rawq, tp->t_qsize, 1);
        cv_init(&tp->t_rawcv, "ttyraw");
        cv_init(&tp->t_rawcvf, "ttyrawf");
 -      clalloc(&tp->t_canq, 1024, 1);
 +      clalloc(&tp->t_canq, tp->t_qsize, 1);
        cv_init(&tp->t_cancv, "ttycan");
        cv_init(&tp->t_cancvf, "ttycanf");
        /* output queue doesn't need quoting */
 -      clalloc(&tp->t_outq, 1024, 0);
 +      clalloc(&tp->t_outq, tp->t_qsize, 0);
        cv_init(&tp->t_outcv, "ttyout");
        cv_init(&tp->t_outcvf, "ttyoutf");
        /* Set default line discipline. */
 @@ -2817,7 +2860,7 @@
        tty_listener = kauth_listen_scope(KAUTH_SCOPE_DEVICE,
            tty_listener_cb, NULL);
  
 -      sysctl_kern_tkstat_setup();
 +      sysctl_kern_tty_setup();
  }
  
  /*
 


Home | Main Index | Thread Index | Old Index