Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Aug 2001 07:08:34 -0700
From:      Julian Elischer <julian@elischer.org>
To:        Nick Hibma <n_hibma@qubesoft.com>
Cc:        Julian Elischer <julian@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/dev/usb uhub.c
Message-ID:  <3B7930E2.2A16C92C@elischer.org>
References:  <CEEKLNFIGKODPCCPEKLDKEGGCBAA.n_hibma@qubesoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Nick Hibma wrote:
> 
> This is not the correct way to do it. usbd_devinfo should allocate the
> buffer and return it. All drivers should be adapted to use an allocated
> buffer.

I'm wasn't really intersted in the optimal way of doing it.. because that
would require that I learn the USB code. I just need it off the stack so 
I can boot. This is functionally the same as what was here defore and minimal 
impact on the rest of the USB code so I could prove to myself that
I wasn't going to break anything else.  You should also go through the 
USB cade and remove all allocations onthe stack that are > 32 bytes or so unless
you 
can show that they only occur with very small prior and later stack usage.
(in anscestors and descendents.) The fact that I hit 3.5K of stack in the USB
code with 2K alloated here means that there was already 1.5K allocated
somewhere else which si already too much.. a kernel stack frame should 
really not be more than 25 pointers (100 bytes on ia32) as a rough guide. 

The USB code routinely seems to allocate some structures that have 127 (or was 
it 256?)
byte buffers in them, on the stack this is bad practice because if someone
decides to up the buffer size constant, we blow our stack again.

I singled out  the USB code because that is what hit me, but there are other
pieces of code that have the same problems. For example I think I saw the 
newbus code allocating some prety large items on the stack..


> 
> Nick
> 
> > -----Original Message-----
> > From: owner-cvs-committers@FreeBSD.org
> > [mailto:owner-cvs-committers@FreeBSD.org]On Behalf Of Julian Elischer
> > Sent: 10 August 2001 18:32
> > To: cvs-committers@FreeBSD.org; cvs-all@FreeBSD.org
> > Subject: cvs commit: src/sys/dev/usb uhub.c
> >
> >
> > julian      2001/08/10 10:32:12 PDT
> >
> >   Modified files:
> >     sys/dev/usb          uhub.c
> >   Log:
> >   Do NOT allocate a 1K buffer on the kernel stack.
> >
> >   Found by: Smashed u-area and hardware watch points.
> >   MFC after: 1 week
> >
> >   Revision  Changes    Path
> >   1.29      +13 -3     src/sys/dev/usb/uhub.c
> >
> >
> > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/usb/uhub.c?r
> > 1=1.28&r2=1.29&cvsroot=freebsd
> >

-- 
+------------------------------------+       ______ _  __
|   __--_|\  Julian Elischer         |       \     U \/ / hard at work in 
|  /       \ julian@elischer.org     +------>x   USA    \ a very strange
| (   OZ    )                                \___   ___ | country !
+- X_.---._/    presently in San Francisco       \_/   \\
          v

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B7930E2.2A16C92C>