From owner-svn-src-head@FreeBSD.ORG Mon Nov 3 08:23:49 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DBFA8E4D; Mon, 3 Nov 2014 08:23:49 +0000 (UTC) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F355BA3; Mon, 3 Nov 2014 08:23:49 +0000 (UTC) Received: from Julian-MBP3.local (50-196-156-133-static.hfc.comcastbusiness.net [50.196.156.133]) (authenticated bits=0) by vps1.elischer.org (8.14.9/8.14.9) with ESMTP id sA38NgTY021951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 3 Nov 2014 00:23:46 -0800 (PST) (envelope-from julian@freebsd.org) Message-ID: <54573B87.7000801@freebsd.org> Date: Mon, 03 Nov 2014 16:23:35 +0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Mateusz Guzik , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r274017 - head/sys/kern References: <201411030746.sA37kpPu037113@svn.freebsd.org> <54573AEE.9010602@freebsd.org> In-Reply-To: <54573AEE.9010602@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Nov 2014 08:23:50 -0000 On 11/3/14, 4:21 PM, Julian Elischer wrote: > On 11/3/14, 3:46 PM, Mateusz Guzik wrote: >> Author: mjg >> Date: Mon Nov 3 07:46:51 2014 >> New Revision: 274017 >> URL: https://svnweb.freebsd.org/changeset/base/274017 >> >> Log: >> Provide an on-stack temporary buffer for small ioctl requests. > I'm not sure I like this. We don't know how many more levels > of stack may be needed. > I know that machines are getting faster with more memory, > but the current move towards bloating out the ... "bloating out the stack" ... > worries me. we started out with a single page of stack (SHARED > with the U-area!). I think we are now at several pages.. I forget, > is it 8? > I'm open to being persuaded but I think we need to have a discussion > about stack usage. We used to say that anything greater that, say > 64 bytes should probably be allocated. > >> Modified: >> head/sys/kern/sys_generic.c >> >> Modified: head/sys/kern/sys_generic.c >> ============================================================================== >> >> --- head/sys/kern/sys_generic.c Mon Nov 3 07:18:42 2014 (r274016) >> +++ head/sys/kern/sys_generic.c Mon Nov 3 07:46:51 2014 (r274017) >> @@ -649,6 +649,7 @@ sys_ioctl(struct thread *td, struct ioct >> u_long com; >> int arg, error; >> u_int size; >> + u_char smalldata[128]; >> caddr_t data; >> if (uap->com > 0xffffffff) { >> @@ -680,17 +681,18 @@ sys_ioctl(struct thread *td, struct ioct >> arg = (intptr_t)uap->data; >> data = (void *)&arg; >> size = 0; >> - } else >> - data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK); >> + } else { >> + if (size <= sizeof(smalldata)) >> + data = smalldata; >> + else >> + data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK); >> + } >> } else >> data = (void *)&uap->data; >> if (com & IOC_IN) { >> error = copyin(uap->data, data, (u_int)size); >> - if (error) { >> - if (size > 0) >> - free(data, M_IOCTLOPS); >> - return (error); >> - } >> + if (error != 0) >> + goto out; >> } else if (com & IOC_OUT) { >> /* >> * Zero the buffer so the user always >> @@ -704,7 +706,8 @@ sys_ioctl(struct thread *td, struct ioct >> if (error == 0 && (com & IOC_OUT)) >> error = copyout(data, uap->data, (u_int)size); >> - if (size > 0) >> +out: >> + if (size > 0 && data != (caddr_t)&smalldata) >> free(data, M_IOCTLOPS); >> return (error); >> } >> >> >> > > > >