From owner-svn-src-all@FreeBSD.ORG Wed Nov 5 06:52:14 2014 Return-Path: Delivered-To: svn-src-all@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 785E08DE; Wed, 5 Nov 2014 06:52:14 +0000 (UTC) Received: from mail-wi0-x236.google.com (mail-wi0-x236.google.com [IPv6:2a00:1450:400c:c05::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9AB8796B; Wed, 5 Nov 2014 06:52:13 +0000 (UTC) Received: by mail-wi0-f182.google.com with SMTP id d1so1073707wiv.3 for ; Tue, 04 Nov 2014 22:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=wI0LFfNvC7jbO8Ds5SAk96ZUPRWn2DIVUM5+EkKv/88=; b=sNGocHlpJ1PZ3tNc4b/POyAPGeyOGXiwatPv4vKoByxBiMlUz+oYNCdVPtPoMrm9VL HQfTpcanIJCs8AAFr2vasSO3UYpb/sSF+3X0EKizu1IBPjm8pM1GhR/aLEz866wmxJB/ LEI1E7A2vNfihKrWPzOC+zLPZIa7Ftr8zPvJu2ZSb2EMZDD0pQbnKFVJEfFp6gtQkw5v FPJnhcWZaLcnk8HlEyy3kkdzhSTwqJ3J/qCANVpzRc64S9JUQLp3uSemwENNH242bgM2 GHl4fu01mArIVCGonhwJc49XqAvuvCg0uDlO6LVO/2axZNW9VRl3GGs8nCFz9X8iZ5Ba y/BA== MIME-Version: 1.0 X-Received: by 10.180.87.33 with SMTP id u1mr3354585wiz.20.1415170331977; Tue, 04 Nov 2014 22:52:11 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Tue, 4 Nov 2014 22:52:11 -0800 (PST) In-Reply-To: <201411041129.sA4BTnwX030600@svn.freebsd.org> References: <201411041129.sA4BTnwX030600@svn.freebsd.org> Date: Tue, 4 Nov 2014 22:52:11 -0800 X-Google-Sender-Auth: zNo0qKk5OpzWm-Q5xC5oxtSCP3M Message-ID: Subject: Re: svn commit: r274088 - head/sys/kern From: Adrian Chadd To: Hans Petter Selasky Content-Type: text/plain; charset=UTF-8 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Wed, 05 Nov 2014 06:52:14 -0000 ... why not just use UMA? -adrian On 4 November 2014 03:29, Hans Petter Selasky wrote: > Author: hselasky > Date: Tue Nov 4 11:29:49 2014 > New Revision: 274088 > URL: https://svnweb.freebsd.org/changeset/base/274088 > > Log: > Simplify logic a bit. Ensure data buffer is properly aligned, > especially for platforms where unaligned access is not allowed. Make > it possible to override the small buffer size. > > A simple continuous read string test using libusb showed a reduction > in CPU usage from roughly 10% to less than 1% using a dual-core GHz > CPU, when the malloc() operation was skipped for small buffers. > > MFC after: 2 weeks > > Modified: > head/sys/kern/sys_generic.c > > Modified: head/sys/kern/sys_generic.c > ============================================================================== > --- head/sys/kern/sys_generic.c Tue Nov 4 10:25:52 2014 (r274087) > +++ head/sys/kern/sys_generic.c Tue Nov 4 11:29:49 2014 (r274088) > @@ -646,10 +646,13 @@ struct ioctl_args { > int > sys_ioctl(struct thread *td, struct ioctl_args *uap) > { > +#ifndef SYS_IOCTL_SMALL_SIZE > +#define SYS_IOCTL_SMALL_SIZE 128 > +#endif > + u_char smalldata[SYS_IOCTL_SMALL_SIZE] __aligned(8); > u_long com; > int arg, error; > u_int size; > - u_char smalldata[128]; > caddr_t data; > > if (uap->com > 0xffffffff) { > @@ -682,10 +685,10 @@ sys_ioctl(struct thread *td, struct ioct > data = (void *)&arg; > size = 0; > } else { > - if (size <= sizeof(smalldata)) > - data = smalldata; > - else > + if (size > SYS_IOCTL_SMALL_SIZE) > data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK); > + else > + data = smalldata; > } > } else > data = (void *)&uap->data; > @@ -707,7 +710,7 @@ sys_ioctl(struct thread *td, struct ioct > error = copyout(data, uap->data, (u_int)size); > > out: > - if (size > 0 && data != (caddr_t)&smalldata) > + if (size > SYS_IOCTL_SMALL_SIZE) > free(data, M_IOCTLOPS); > return (error); > } >