From owner-freebsd-arch@FreeBSD.ORG Sun Dec 14 00:43:55 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F6921065676 for ; Sun, 14 Dec 2008 00:43:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from cmail.optima.ua (cmail.optima.ua [195.248.191.121]) by mx1.freebsd.org (Postfix) with ESMTP id D92F28FC14 for ; Sun, 14 Dec 2008 00:43:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) X-Spam-Flag: SKIP X-Spam-Yversion: Spamooborona-2.1.0 Received: from [212.86.226.226] (account mav@alkar.net HELO mavbook.mavhome.dp.ua) by cmail.optima.ua (CommuniGate Pro SMTP 5.2.9) with ESMTPSA id 229719946; Sun, 14 Dec 2008 01:33:52 +0200 Message-ID: <4944465F.1030102@FreeBSD.org> Date: Sun, 14 Dec 2008 01:33:51 +0200 From: Alexander Motin User-Agent: Thunderbird 2.0.0.17 (X11/20081029) MIME-Version: 1.0 To: freebsd-arch@freebsd.org, freebsd-net@freebsd.org Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: m_devget() and const buffer X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Dec 2008 00:43:55 -0000 Hi. Does anybody knows why m_devget() receives non-const char* as first argument? Is there any destructive copy routines used with it? I have searched all the kernel, but haven't found any. May be we could change that? -- Alexander Motin From owner-freebsd-arch@FreeBSD.ORG Sun Dec 14 18:30:45 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAFD2106564A for ; Sun, 14 Dec 2008 18:30:45 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 53F768FC08 for ; Sun, 14 Dec 2008 18:30:45 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mBEISuDE016069; Sun, 14 Dec 2008 11:28:56 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Sun, 14 Dec 2008 11:28:55 -0700 (MST) Message-Id: <20081214.112855.-1484714042.imp@bsdimp.com> To: wollman@hergotha.csail.mit.edu From: "M. Warner Losh" In-Reply-To: <200812042313.mB4NDA6j045334@hergotha.csail.mit.edu> References: <49382502.1040403@delphij.net> <200812042313.mB4NDA6j045334@hergotha.csail.mit.edu> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: Adding strndup(3) to libc viable/useful? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Dec 2008 18:30:45 -0000 In message: <200812042313.mB4NDA6j045334@hergotha.csail.mit.edu> Garrett Wollman writes: : >FWIW, there are a bunch of other useful utility str*() and mem*() : >functions that glibc has that we do not. : : Any of the functions that POSIX has adopted should definitely be : added. Got a list? Warner From owner-freebsd-arch@FreeBSD.ORG Mon Dec 15 11:06:49 2008 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32B2B1065672 for ; Mon, 15 Dec 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0C14E8FC27 for ; Mon, 15 Dec 2008 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mBFB6m5O004265 for ; Mon, 15 Dec 2008 11:06:48 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mBFB6mbG004261 for freebsd-arch@FreeBSD.org; Mon, 15 Dec 2008 11:06:48 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 15 Dec 2008 11:06:48 GMT Message-Id: <200812151106.mBFB6mbG004261@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-arch@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Dec 2008 11:06:49 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/120749 arch [request] Suggest upping the default kern.ps_arg_cache 1 problem total. From owner-freebsd-arch@FreeBSD.ORG Tue Dec 16 20:21:13 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82D931065676 for ; Tue, 16 Dec 2008 20:21:13 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 3B4B48FC2E for ; Tue, 16 Dec 2008 20:21:13 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mBGKIfBg064282 for ; Tue, 16 Dec 2008 13:18:41 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 16 Dec 2008 13:18:45 -0700 (MST) Message-Id: <20081216.131845.-1739986974.imp@bsdimp.com> To: arch@freebsd.org From: "M. Warner Losh" X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 20:21:13 -0000 I was looking at the MIPS elf stuff based on a submission of some 64-bit support. In doing so, I discovered a number of 'unused' types that appear to have comments that indicate that they can be removed now and were just slavishly copied from arch to arch to arch. /* * The following non-standard values are used for passing information * from John Polstra's testbed program to the dynamic linker. These * are expected to go away soon. * * Unfortunately, these overlap the Linux non-standard values, so they * must not be used in the same context. */ #define AT_BRK 10 /* Starting point for sbrk and brk. */ #define AT_DEBUG 11 /* Debugging level. */ These have be slavishly copied to arm, powerpc, sparc64, ia64, mips, sun4v and amd64. All these files have nearly identical comments (except powerpc, which changes the value). The only place these are used in the kernel is in the Linux! emulation in i386/linux/linux_sysvec.c and amd64/linux32/linux32_sysvec.c: if (args->trace) AUXARGS_ENTRY(pos, AT_DEBUG, 1); Since AT_DEBUG and AT_UID have the same value, and we look at AT_UID later, we wind up passing the wrong value for AT_UID. Fortunately, we don't use AT_UID for anything in the tree.... So I'd like to remove all this stuff unless there's a compelling reason to keep it. Can anybody think of a reason to keep it? It seems completely non-functional... Warner From owner-freebsd-arch@FreeBSD.ORG Tue Dec 16 21:49:40 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41B1A106564A for ; Tue, 16 Dec 2008 21:49:40 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from vlakno.cz (77-93-215-190.static.masterinter.net [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id C2E4B8FC08 for ; Tue, 16 Dec 2008 21:49:39 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id D70359CB1B6; Tue, 16 Dec 2008 22:27:49 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rvLkBQafwWNs; Tue, 16 Dec 2008 22:27:47 +0100 (CET) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 6BADE9CB1BE; Tue, 16 Dec 2008 22:27:47 +0100 (CET) Received: (from rdivacky@localhost) by lev.vlakno.cz (8.14.2/8.14.2/Submit) id mBGLRkLW029399; Tue, 16 Dec 2008 22:27:46 +0100 (CET) (envelope-from rdivacky) Date: Tue, 16 Dec 2008 22:27:46 +0100 From: Roman Divacky To: "M. Warner Losh" Message-ID: <20081216212746.GA28834@freebsd.org> References: <20081216.131845.-1739986974.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081216.131845.-1739986974.imp@bsdimp.com> User-Agent: Mutt/1.4.2.3i Cc: arch@freebsd.org Subject: Re: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 21:49:40 -0000 On Tue, Dec 16, 2008 at 01:18:45PM -0700, M. Warner Losh wrote: > I was looking at the MIPS elf stuff based on a submission of some > 64-bit support. In doing so, I discovered a number of 'unused' types > that appear to have comments that indicate that they can be removed > now and were just slavishly copied from arch to arch to arch. > > /* > * The following non-standard values are used for passing information > * from John Polstra's testbed program to the dynamic linker. These > * are expected to go away soon. > * > * Unfortunately, these overlap the Linux non-standard values, so they > * must not be used in the same context. > */ > #define AT_BRK 10 /* Starting point for sbrk and brk. */ > #define AT_DEBUG 11 /* Debugging level. */ > > These have be slavishly copied to arm, powerpc, sparc64, ia64, mips, > sun4v and amd64. All these files have nearly identical comments > (except powerpc, which changes the value). > > The only place these are used in the kernel is in the Linux! > emulation in i386/linux/linux_sysvec.c and > amd64/linux32/linux32_sysvec.c: > > if (args->trace) > AUXARGS_ENTRY(pos, AT_DEBUG, 1); > > Since AT_DEBUG and AT_UID have the same value, and we look at AT_UID > later, we wind up passing the wrong value for AT_UID. Fortunately, we > don't use AT_UID for anything in the tree.... I cannot find any reference of AT_DEBUG in linux 2.6.16 sources and it indeed looks bogus... From owner-freebsd-arch@FreeBSD.ORG Tue Dec 16 23:19:25 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4E891065675; Tue, 16 Dec 2008 23:19:25 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 77C698FC12; Tue, 16 Dec 2008 23:19:25 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mBGNGXaI066247; Tue, 16 Dec 2008 16:16:33 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 16 Dec 2008 16:16:38 -0700 (MST) Message-Id: <20081216.161638.644659879.imp@bsdimp.com> To: rdivacky@freebsd.org From: "M. Warner Losh" In-Reply-To: <20081216212746.GA28834@freebsd.org> References: <20081216.131845.-1739986974.imp@bsdimp.com> <20081216212746.GA28834@freebsd.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 23:19:26 -0000 In message: <20081216212746.GA28834@freebsd.org> Roman Divacky writes: : On Tue, Dec 16, 2008 at 01:18:45PM -0700, M. Warner Losh wrote: : > I was looking at the MIPS elf stuff based on a submission of some : > 64-bit support. In doing so, I discovered a number of 'unused' types : > that appear to have comments that indicate that they can be removed : > now and were just slavishly copied from arch to arch to arch. : > : > /* : > * The following non-standard values are used for passing information : > * from John Polstra's testbed program to the dynamic linker. These : > * are expected to go away soon. : > * : > * Unfortunately, these overlap the Linux non-standard values, so they : > * must not be used in the same context. : > */ : > #define AT_BRK 10 /* Starting point for sbrk and brk. */ : > #define AT_DEBUG 11 /* Debugging level. */ : > : > These have be slavishly copied to arm, powerpc, sparc64, ia64, mips, : > sun4v and amd64. All these files have nearly identical comments : > (except powerpc, which changes the value). : > : > The only place these are used in the kernel is in the Linux! : > emulation in i386/linux/linux_sysvec.c and : > amd64/linux32/linux32_sysvec.c: : > : > if (args->trace) : > AUXARGS_ENTRY(pos, AT_DEBUG, 1); : > : > Since AT_DEBUG and AT_UID have the same value, and we look at AT_UID : > later, we wind up passing the wrong value for AT_UID. Fortunately, we : > don't use AT_UID for anything in the tree.... : : I cannot find any reference of AT_DEBUG in linux 2.6.16 sources and it : indeed looks bogus... What do you think of the following patch? Warner Index: sys/amd64/linux32/linux32_sysvec.c =================================================================== --- sys/amd64/linux32/linux32_sysvec.c (revision 186097) +++ sys/amd64/linux32/linux32_sysvec.c (working copy) @@ -254,8 +254,6 @@ args = (Elf32_Auxargs *)imgp->auxargs; pos = base + (imgp->args->argc + imgp->args->envc + 2); - if (args->trace) - AUXARGS_ENTRY_32(pos, AT_DEBUG, 1); if (args->execfd != -1) AUXARGS_ENTRY_32(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY_32(pos, AT_PHDR, args->phdr); Index: sys/i386/linux/linux_sysvec.c =================================================================== --- sys/i386/linux/linux_sysvec.c (revision 186097) +++ sys/i386/linux/linux_sysvec.c (working copy) @@ -245,8 +245,6 @@ args = (Elf32_Auxargs *)imgp->auxargs; pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2); - if (args->trace) - AUXARGS_ENTRY(pos, AT_DEBUG, 1); if (args->execfd != -1) AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY(pos, AT_PHDR, args->phdr); From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 03:33:49 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 651B51065693 for ; Wed, 17 Dec 2008 03:33:49 +0000 (UTC) (envelope-from peter@wemm.org) Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.30]) by mx1.freebsd.org (Postfix) with ESMTP id 29A9E8FC21 for ; Wed, 17 Dec 2008 03:33:49 +0000 (UTC) (envelope-from peter@wemm.org) Received: by yw-out-2324.google.com with SMTP id 9so2166023ywe.13 for ; Tue, 16 Dec 2008 19:33:48 -0800 (PST) Received: by 10.100.143.12 with SMTP id q12mr157119and.22.1229484828183; Tue, 16 Dec 2008 19:33:48 -0800 (PST) Received: by 10.100.211.19 with HTTP; Tue, 16 Dec 2008 19:33:48 -0800 (PST) Message-ID: Date: Tue, 16 Dec 2008 19:33:48 -0800 From: "Peter Wemm" To: "M. Warner Losh" In-Reply-To: <20081216.131845.-1739986974.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20081216.131845.-1739986974.imp@bsdimp.com> Cc: arch@freebsd.org Subject: Re: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 03:33:49 -0000 On Tue, Dec 16, 2008 at 12:18 PM, M. Warner Losh wrote: > I was looking at the MIPS elf stuff based on a submission of some > 64-bit support. In doing so, I discovered a number of 'unused' types > that appear to have comments that indicate that they can be removed > now and were just slavishly copied from arch to arch to arch. > > /* > * The following non-standard values are used for passing information > * from John Polstra's testbed program to the dynamic linker. These > * are expected to go away soon. > * > * Unfortunately, these overlap the Linux non-standard values, so they > * must not be used in the same context. > */ > #define AT_BRK 10 /* Starting point for sbrk and brk. */ > #define AT_DEBUG 11 /* Debugging level. */ > > These have be slavishly copied to arm, powerpc, sparc64, ia64, mips, > sun4v and amd64. All these files have nearly identical comments > (except powerpc, which changes the value). [..] > So I'd like to remove all this stuff unless there's a compelling > reason to keep it. > > Can anybody think of a reason to keep it? It seems completely > non-functional... Remove it completely. It probably should never have been committed to the tree in the first place. In either case, it has been OBE for a good ~10 years. -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV "All of this is for nothing if we don't go to the stars" - JMS/B5 "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 08:20:53 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 863371065672 for ; Wed, 17 Dec 2008 08:20:53 +0000 (UTC) (envelope-from paul.m.saab@gmail.com) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.175]) by mx1.freebsd.org (Postfix) with ESMTP id 561978FC17 for ; Wed, 17 Dec 2008 08:20:53 +0000 (UTC) (envelope-from paul.m.saab@gmail.com) Received: by wf-out-1314.google.com with SMTP id 24so3839563wfg.7 for ; Wed, 17 Dec 2008 00:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type:references :x-google-sender-auth; bh=+/6w5MhKKPmGIQTOXy7CI7hppoBDR2uef7VJq2fUjsg=; b=FPwwd6WvHh5kGDNJ4wH3KB16OZg0Dsxu8103Cm28qQmzlsz0lIREuWeCHOiuf+cWKv t0Uks7ZlnDVAtyoSWzQB3hA39/y59g3EdZ0pIav6l98gpMJ4XngWptEIkRwWLWpjvXjd Qtl2YHfoVeMZqw3mrzG6S3PR87vfyZgkH7WuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:references:x-google-sender-auth; b=QouGF/9iOrzF498qgEEqC04gB4OGT3W6vUm0iHDufAia7C8JzIek53uCDR1RY7TIMi vX96w8Lcyk5p+frXbFxtGsYPf2HQocAu8APglD2PMfvn7HfoBkNvGh2OYFG4rtptGDL7 +3Q4R+uqpSJZZBUsBdmJAuuiWOpEPlOBkkuSg= Received: by 10.142.135.13 with SMTP id i13mr193077wfd.8.1229500190709; Tue, 16 Dec 2008 23:49:50 -0800 (PST) Received: by 10.142.125.20 with HTTP; Tue, 16 Dec 2008 23:49:50 -0800 (PST) Message-ID: <5c0ff6a70812162349n38395f84o45020f334cd09853@mail.gmail.com> Date: Tue, 16 Dec 2008 23:49:50 -0800 From: "Paul Saab" Sender: paul.m.saab@gmail.com To: "Jeff Roberson" In-Reply-To: <20081209155714.K960@desktop> MIME-Version: 1.0 References: <20081209155714.K960@desktop> X-Google-Sender-Auth: 656124c1ed1f874f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: arch@freebsd.org Subject: Re: UMA & mbuf cache utilization. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 08:20:53 -0000 So far testing has shown in a pure transmit test, that this doesn't hurt performance at all. On Tue, Dec 9, 2008 at 6:22 PM, Jeff Roberson wrote: > Hello, > > Nokia has graciously allowed me to release a patch which I developed to > improve general mbuf and cluster cache behavior. This is based on others > observations that due to simple alignment at 2k and 256k we achieve a poor > cache distribution for the header area of packets and the most heavily used > mbuf header fields. In addition, modern machines stripe memory access > across several memories and even memory controllers. Accessing heavily > aligned locations such as these can also create load imbalances among > memories. > > To solve this problem I have added two new features to UMA. The first is > the zone flag UMA_ZONE_CACHESPREAD. This flag modifies the meaning of the > alignment field such that start addresses are staggered by at least align + > 1 bytes. In the case of clusters and mbufs this means adding > uma_cache_align + 1 bytes to the amount of storage allocated. This creates > a certain constant amount of waste, 3% and 12% respectively. It also means > we must use contiguous physical and virtual memory consisting of several > pages to efficiently use the memory and land on as many cache lines as > possible. > > Because contiguous physical memory is not always available, the allocator > had to have a fallback mechanism. We don't simply want to have all mbuf > allocations check two zones as once we deplete available contiguous memory > the check on the first zone will always fail using the most expensive code > path. > > To resolve this issue, I added the ability for secondary zones to stack on > top of multiple primary zones. Secondary zones are zones which get their > storage from another zone but handle their own caching, ctors, dtors, etc. > By adding this feature a secondary zone can be created that can allocate > either from the contiguous memory pool or the non-contiguous single-page > pool depending on availability. It is also much faster to fail between them > deep in the allocator because it is only required when we exhaust the > already available mbuf memory. > > For mbufs and clusters there are now three zones each. A contigmalloc > backed zone, a single-page allocator zone, and a secondary zone with the > original zome_mbuf or zone_clust name. The packet zone also takes from both > available mbuf zones. The individual backend zones are not exposed outside > of kern_mbuf.c. > > Currently, each backend zone can have its own limit. The secondary zone > only blocks when both are full. Statistic wise the limit should be reported > as the sum of the backend limits, however, that isn't presently done. The > secondary zone can not have its own limit independent of the backends at > this time. I'm not sure if that's valuable or not. > > I have test results from nokia which show a dramatic improvement in several > workloads but which I am probably not at liberty to discuss. I'm in the > process of convincing Kip to help me get some benchmark data on our stack. > > Also as part of the patch I renamed a few functions since many were > non-obvious and grew new keg abstractions to tidy things up a bit. I > suspect those of you with UMA experience (robert, bosko) will find the > renaming a welcome improvement. > > The patch is available at: > http://people.freebsd.org/~jeff/mbuf_contig.diff > > I would love to hear any feedback you may have. I have been developing > this and testing various version off and on for months, however, this is a > fresh port to current and it is a little green so should be considered > experimental. > > In particular, I'm most nervous about how the vm will respond to new > pressure on contig physical pages. I'm also interested in hearing from > embedded/limited memory people about how we might want to limit or tune > this. > > Thanks, > Jeff > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" > > From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 17:38:50 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84D02106564A for ; Wed, 17 Dec 2008 17:38:50 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from contrabass.post.ru (contrabass.post.ru [85.21.78.5]) by mx1.freebsd.org (Postfix) with ESMTP id 0E12C8FC13 for ; Wed, 17 Dec 2008 17:38:48 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 6403D38DAD; Wed, 17 Dec 2008 20:20:54 +0300 (MSK) X-Virus-Scanned: by cgpav Uf39PSi9pFi9oFi9 Received: from dchagin.dialup.corbina.ru ([78.107.232.239] verified) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPS id 1522521110; Wed, 17 Dec 2008 20:20:54 +0300 Received: from dchagin.dialup.corbina.ru (localhost.chd.net [127.0.0.1]) by dchagin.dialup.corbina.ru (8.14.3/8.14.3) with ESMTP id mBHHKrFA002969; Wed, 17 Dec 2008 20:20:53 +0300 (MSK) (envelope-from root@dchagin.dialup.corbina.ru) Received: (from root@localhost) by dchagin.dialup.corbina.ru (8.14.3/8.14.3/Submit) id mBHHKmrT002968; Wed, 17 Dec 2008 20:20:48 +0300 (MSK) (envelope-from root) Date: Wed, 17 Dec 2008 20:20:48 +0300 From: Chagin Dmitry To: "M. Warner Losh" Message-ID: <20081217172047.GA2884@dchagin.dialup.corbina.ru> References: <20081216.131845.-1739986974.imp@bsdimp.com> <20081216212746.GA28834@freebsd.org> <20081216.161638.644659879.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081216.161638.644659879.imp@bsdimp.com> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: arch@freebsd.org Subject: Re: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 17:38:50 -0000 On Tue, Dec 16, 2008 at 04:16:38PM -0700, M. Warner Losh wrote: > In message: <20081216212746.GA28834@freebsd.org> > Roman Divacky writes: > : On Tue, Dec 16, 2008 at 01:18:45PM -0700, M. Warner Losh wrote: > : > I was looking at the MIPS elf stuff based on a submission of some > : > 64-bit support. In doing so, I discovered a number of 'unused' types > : > that appear to have comments that indicate that they can be removed > : > now and were just slavishly copied from arch to arch to arch. > : > > : > /* > : > * The following non-standard values are used for passing information > : > * from John Polstra's testbed program to the dynamic linker. These > : > * are expected to go away soon. > : > * > : > * Unfortunately, these overlap the Linux non-standard values, so they > : > * must not be used in the same context. > : > */ > : > #define AT_BRK 10 /* Starting point for sbrk and brk. */ > : > #define AT_DEBUG 11 /* Debugging level. */ > : > > : > These have be slavishly copied to arm, powerpc, sparc64, ia64, mips, > : > sun4v and amd64. All these files have nearly identical comments > : > (except powerpc, which changes the value). > : > > : > The only place these are used in the kernel is in the Linux! > : > emulation in i386/linux/linux_sysvec.c and > : > amd64/linux32/linux32_sysvec.c: > : > > : > if (args->trace) > : > AUXARGS_ENTRY(pos, AT_DEBUG, 1); > : > > : > Since AT_DEBUG and AT_UID have the same value, and we look at AT_UID > : > later, we wind up passing the wrong value for AT_UID. Fortunately, we > : > don't use AT_UID for anything in the tree.... > : > : I cannot find any reference of AT_DEBUG in linux 2.6.16 sources and it > : indeed looks bogus... > > What do you think of the following patch? > > Warner > Hi, I am ready to offer more radical patch :) Move all Linux aux entry types to a new file compat/linux/linux_elf.h Add two new aux entries which improve work of futexes. Please review. thnx! diff --git a/sys/amd64/include/elf.h b/sys/amd64/include/elf.h index a4c7f79..3c2cd20 100644 --- a/sys/amd64/include/elf.h +++ b/sys/amd64/include/elf.h @@ -81,16 +81,8 @@ __ElfType(Auxinfo); #define AT_BASE 7 /* Interpreter's base address. */ #define AT_FLAGS 8 /* Flags (unused for i386). */ #define AT_ENTRY 9 /* Where interpreter should transfer control. */ -/* - * The following non-standard values are used in Linux ELF binaries. - */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_COUNT 15 /* Count of defined aux entry types. */ +#define AT_COUNT 10 /* Count of defined aux entry types. */ /* * Relocation types. diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index e0ffcdf..3f04555 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -108,6 +108,12 @@ typedef struct { #define LINUX_CTL_MAXNAME 10 +#define LINUX_AT_SYSINFO 32 +#define LINUX_AT_SYSINFO_EHDR 33 +#define LINUX_AT_COUNT 16 /* Count of used aux entry types. + * Keep this synchronized with + * elf_linux_fixup() code. + */ struct l___sysctl_args { l_uintptr_t name; diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index aaa7458..2777e84 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -106,6 +107,8 @@ MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); #define LINUX_SYS_linux_rt_sendsig 0 #define LINUX_SYS_linux_sendsig 0 +const char linux_platform[] = "i686"; +static int linux_szplatform; extern char linux_sigcode[]; extern int linux_szsigcode; @@ -246,7 +249,12 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp) { Elf32_Auxargs *args; Elf32_Addr *base; - Elf32_Addr *pos; + Elf32_Addr *pos, *uplatform; + struct linux32_ps_strings *arginfo; + + arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS; + uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szsigcode - + linux_szplatform); KASSERT(curthread->td_proc == imgp->proc, ("unsafe elf_linux_fixup(), should be curproc")); @@ -254,8 +262,8 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp) args = (Elf32_Auxargs *)imgp->auxargs; pos = base + (imgp->args->argc + imgp->args->envc + 2); - if (args->execfd != -1) - AUXARGS_ENTRY_32(pos, AT_EXECFD, args->execfd); + AUXARGS_ENTRY_32(pos, LINUX_AT_HWCAP, cpu_feature); + AUXARGS_ENTRY_32(pos, LINUX_AT_CLKTCK, hz); AUXARGS_ENTRY_32(pos, AT_PHDR, args->phdr); AUXARGS_ENTRY_32(pos, AT_PHENT, args->phent); AUXARGS_ENTRY_32(pos, AT_PHNUM, args->phnum); @@ -263,10 +271,14 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp) AUXARGS_ENTRY_32(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY_32(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY_32(pos, AT_BASE, args->base); - AUXARGS_ENTRY_32(pos, AT_UID, imgp->proc->p_ucred->cr_ruid); - AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid); - AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid); - AUXARGS_ENTRY_32(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid); + AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, 0); + AUXARGS_ENTRY_32(pos, LINUX_AT_UID, imgp->proc->p_ucred->cr_ruid); + AUXARGS_ENTRY_32(pos, LINUX_AT_EUID, imgp->proc->p_ucred->cr_svuid); + AUXARGS_ENTRY_32(pos, LINUX_AT_GID, imgp->proc->p_ucred->cr_rgid); + AUXARGS_ENTRY_32(pos, LINUX_AT_EGID, imgp->proc->p_ucred->cr_svgid); + AUXARGS_ENTRY_32(pos, LINUX_AT_PLATFORM, PTROUT(uplatform)); + if (args->execfd != -1) + AUXARGS_ENTRY_32(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY_32(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); @@ -851,27 +863,31 @@ static register_t * linux_copyout_strings(struct image_params *imgp) { int argc, envc; - u_int32_t *vectp; + uint32_t *vectp; char *stringp, *destp; - u_int32_t *stack_base; + uint32_t *stack_base; struct linux32_ps_strings *arginfo; - int sigcodesz; /* * Calculate string base and vector table pointers. * Also deal with signal trampoline code for this exec type. */ arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS; - sigcodesz = *(imgp->proc->p_sysent->sv_szsigcode); - destp = (caddr_t)arginfo - sigcodesz - SPARE_USRSPACE - - roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); + destp = (caddr_t)arginfo - linux_szsigcode - SPARE_USRSPACE - + linux_szplatform - roundup((ARG_MAX - imgp->args->stringspace), + sizeof(char *)); /* * install sigcode */ - if (sigcodesz) - copyout(imgp->proc->p_sysent->sv_sigcode, - ((caddr_t)arginfo - sigcodesz), sigcodesz); + copyout(imgp->proc->p_sysent->sv_sigcode, + ((caddr_t)arginfo - linux_szsigcode), linux_szsigcode); + + /* + * Install LINUX_PLATFORM + */ + copyout(linux_platform, ((caddr_t)arginfo - linux_szsigcode - + linux_szplatform), linux_szplatform); /* * If we have a valid auxargs ptr, prepare some room @@ -883,22 +899,22 @@ linux_copyout_strings(struct image_params *imgp) * lower compatibility. */ imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size - : (AT_COUNT * 2); + : (LINUX_AT_COUNT * 2); /* * The '+ 2' is for the null pointers at the end of each of * the arg and env vector sets,and imgp->auxarg_size is room * for argument of Runtime loader. */ - vectp = (u_int32_t *) (destp - (imgp->args->argc + imgp->args->envc + 2 + - imgp->auxarg_size) * sizeof(u_int32_t)); + vectp = (uint32_t *) (destp - (imgp->args->argc + + imgp->args->envc + 2 + imgp->auxarg_size) * sizeof(uint32_t)); } else /* * The '+ 2' is for the null pointers at the end of each of * the arg and env vector sets */ - vectp = (u_int32_t *) - (destp - (imgp->args->argc + imgp->args->envc + 2) * sizeof(u_int32_t)); + vectp = (uint32_t *) (destp - (imgp->args->argc + + imgp->args->envc + 2) * sizeof(uint32_t)); /* * vectp also becomes our initial stack base @@ -916,14 +932,14 @@ linux_copyout_strings(struct image_params *imgp) /* * Fill in "ps_strings" struct for ps, w, etc. */ - suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp); + suword32(&arginfo->ps_argvstr, (uint32_t)(intptr_t)vectp); suword32(&arginfo->ps_nargvstr, argc); /* * Fill in argument portion of vector table. */ for (; argc > 0; --argc) { - suword32(vectp++, (u_int32_t)(intptr_t)destp); + suword32(vectp++, (uint32_t)(intptr_t)destp); while (*stringp++ != 0) destp++; destp++; @@ -932,14 +948,14 @@ linux_copyout_strings(struct image_params *imgp) /* a null vector table pointer separates the argp's from the envp's */ suword32(vectp++, 0); - suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp); + suword32(&arginfo->ps_envstr, (uint32_t)(intptr_t)vectp); suword32(&arginfo->ps_nenvstr, envc); /* * Fill in environment portion of vector table. */ for (; envc > 0; --envc) { - suword32(vectp++, (u_int32_t)(intptr_t)destp); + suword32(vectp++, (uint32_t)(intptr_t)destp); while (*stringp++ != 0) destp++; destp++; @@ -1088,6 +1104,8 @@ linux_elf_modevent(module_t mod, int type, void *data) NULL, 1000); if (bootverbose) printf("Linux ELF exec handler installed\n"); + linux_szplatform = roundup(strlen(linux_platform) + 1, + sizeof(char *)); } else printf("cannot insert Linux ELF brand handler\n"); break; diff --git a/sys/arm/include/elf.h b/sys/arm/include/elf.h index c516864..48260e1 100644 --- a/sys/arm/include/elf.h +++ b/sys/arm/include/elf.h @@ -70,13 +70,8 @@ __ElfType(Auxinfo); #define AT_BASE 7 /* Interpreter's base address. */ #define AT_FLAGS 8 /* Flags (unused). */ #define AT_ENTRY 9 /* Where interpreter should transfer control. */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_COUNT 15 /* Count of defined aux entry types. */ +#define AT_COUNT 10 /* Count of defined aux entry types. */ #define R_ARM_COUNT 33 /* Count of defined relocation types. */ diff --git a/sys/compat/linux/linux_elf.h b/sys/compat/linux/linux_elf.h new file mode 100644 index 0000000..680e39b --- /dev/null +++ b/sys/compat/linux/linux_elf.h @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 2008 Chagin Dmitry + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUX_ELF_H_ +#define _LINUX_ELF_H_ + +/* + * Non-standard aux entry types used in Linux ELF binaries. + */ + +#define LINUX_AT_NOTELF 10 /* Program is not ELF ?? */ +#define LINUX_AT_UID 11 /* Real uid. */ +#define LINUX_AT_EUID 12 /* Effective uid. */ +#define LINUX_AT_GID 13 /* Real gid. */ +#define LINUX_AT_EGID 14 /* Effective gid. */ +#define LINUX_AT_PLATFORM 15 /* String identifying CPU */ +#define LINUX_AT_HWCAP 16 /* CPU capabilities */ +#define LINUX_AT_CLKTCK 17 /* frequency at which times() increments */ +#define LINUX_AT_SECURE 23 /* secure mode boolean */ +#define LINUX_AT_BASE_PLATFORM 24 /* string identifying real platform, may + * differ from AT_PLATFORM. + */ +#define LINUX_AT_EXECFN 31 /* filename of program */ + +#endif /* !_LINUX_ELF_H_ */ diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 93f4297..cf14da3 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -92,10 +92,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __i386__ -#include -#endif - #define BSD_TO_LINUX_SIGNAL(sig) \ (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig) @@ -731,34 +727,8 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args) *p = '\0'; break; } -#ifdef __i386__ - { - const char *class; + strlcpy(utsname.machine, linux_platform, LINUX_MAX_UTSNAME); - switch (cpu_class) { - case CPUCLASS_686: - class = "i686"; - break; - case CPUCLASS_586: - class = "i586"; - break; - case CPUCLASS_486: - class = "i486"; - break; - default: - class = "i386"; - } - strlcpy(utsname.machine, class, LINUX_MAX_UTSNAME); - } -#elif defined(__amd64__) /* XXX: Linux can change 'personality'. */ -#ifdef COMPAT_LINUX32 - strlcpy(utsname.machine, "i686", LINUX_MAX_UTSNAME); -#else - strlcpy(utsname.machine, "x86_64", LINUX_MAX_UTSNAME); -#endif /* COMPAT_LINUX32 */ -#else /* something other than i386 or amd64 - assume we and Linux agree */ - strlcpy(utsname.machine, machine, LINUX_MAX_UTSNAME); -#endif /* __i386__ */ mtx_lock(&hostname_mtx); strlcpy(utsname.domainname, V_domainname, LINUX_MAX_UTSNAME); mtx_unlock(&hostname_mtx); diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index c80a432..2cdb3c3 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -45,4 +45,6 @@ #define LINUX_MREMAP_MAYMOVE 1 #define LINUX_MREMAP_FIXED 2 +extern const char linux_platform[]; + #endif /* _LINUX_MISC_H_ */ diff --git a/sys/compat/svr4/svr4.h b/sys/compat/svr4/svr4.h index 84ee720..261e3e9 100644 --- a/sys/compat/svr4/svr4.h +++ b/sys/compat/svr4/svr4.h @@ -36,4 +36,11 @@ extern struct sysentvec svr4_sysvec; #define COMPAT_SVR4_SOLARIS2 -#endif +#define SVR4_AT_UID 11 /* Real uid. */ +#define SVR4_AT_EUID 12 /* Effective uid. */ +#define SVR4_AT_GID 13 /* Real gid. */ +#define SVR4_AT_EGID 14 /* Effective gid. */ + +#define SVR4_AT_COUNT 15 /* Count of defined aux entry types. */ + +#endif /* !_LINUX_ELF_H_ */ diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c index 0030e3a..24a742c 100644 --- a/sys/compat/svr4/svr4_sysvec.c +++ b/sys/compat/svr4/svr4_sysvec.c @@ -163,6 +163,115 @@ extern struct sysent svr4_sysent[]; extern int svr4_szsigcode; extern char svr4_sigcode[]; + +/* + * Copy strings out to the new process address space, constructing new arg + * and env vector tables. Return a pointer to the base so that it can be used + * as the initial stack pointer. + */ +static register_t * +svr4_copyout_strings(struct image_params *imgp) +{ + int argc, envc; + char **vectp; + char *stringp, *destp; + register_t *stack_base; + struct ps_strings *arginfo; + struct proc *p; + + /* + * Calculate string base and vector table pointers. + * Also deal with signal trampoline code for this exec type. + */ + p = imgp->proc; + arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings; + destp = (caddr_t)arginfo - svr4_szsigcode - SPARE_USRSPACE - + roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); + + copyout(p->p_sysent->sv_sigcode, ((caddr_t)arginfo - + svr4_szsigcode), svr4_szsigcode); + + /* + * If we have a valid auxargs ptr, prepare some room + * on the stack. + */ + if (imgp->auxargs) { + /* + * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for + * lower compatibility. + */ + imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size : + (SVR4_AT_COUNT * 2); + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets,and imgp->auxarg_size is room + * for argument of Runtime loader. + */ + vectp = (char **)(destp - (imgp->args->argc + + imgp->args->envc + 2 + imgp->auxarg_size) * + sizeof(char *)); + + } else { + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets + */ + vectp = (char **)(destp - (imgp->args->argc + imgp->args->envc + 2) * + sizeof(char *)); + } + + /* + * vectp also becomes our initial stack base + */ + stack_base = (register_t *)vectp; + + stringp = imgp->args->begin_argv; + argc = imgp->args->argc; + envc = imgp->args->envc; + + /* + * Copy out strings - arguments and environment. + */ + copyout(stringp, destp, ARG_MAX - imgp->args->stringspace); + + /* + * Fill in "ps_strings" struct for ps, w, etc. + */ + suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp); + suword(&arginfo->ps_nargvstr, argc); + + /* + * Fill in argument portion of vector table. + */ + for (; argc > 0; --argc) { + suword(vectp++, (long)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* a null vector table pointer separates the argp's from the envp's */ + suword(vectp++, 0); + + suword(&arginfo->ps_envstr, (long)(intptr_t)vectp); + suword(&arginfo->ps_nenvstr, envc); + + /* + * Fill in environment portion of vector table. + */ + for (; envc > 0; --envc) { + suword(vectp++, (long)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* end of vector table is a null pointer */ + suword(vectp, 0); + + return (stack_base); +} + struct sysentvec svr4_sysvec = { .sv_size = SVR4_SYS_MAXSYSCALL, .sv_table = svr4_sysent, @@ -187,7 +296,7 @@ struct sysentvec svr4_sysvec = { .sv_usrstack = USRSTACK, .sv_psstrings = PS_STRINGS, .sv_stackprot = VM_PROT_ALL, - .sv_copyout_strings = exec_copyout_strings, + .sv_copyout_strings = svr4_copyout_strings, .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, @@ -227,10 +336,10 @@ svr4_fixup(register_t **stack_base, struct image_params *imgp) AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY(pos, AT_BASE, args->base); - AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid); - AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid); - AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid); - AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid); + AUXARGS_ENTRY(pos, SVR4_AT_UID, imgp->proc->p_ucred->cr_ruid); + AUXARGS_ENTRY(pos, SVR4_AT_EUID, imgp->proc->p_ucred->cr_svuid); + AUXARGS_ENTRY(pos, SVR4_AT_GID, imgp->proc->p_ucred->cr_rgid); + AUXARGS_ENTRY(pos, SVR4_AT_EGID, imgp->proc->p_ucred->cr_svgid); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); @@ -307,3 +416,4 @@ static moduledata_t svr4_elf_mod = { }; DECLARE_MODULE(svr4elf, svr4_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); MODULE_DEPEND(svr4elf, streams, 1, 1, 1); + diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index f9c7ee5..46478c0 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -102,6 +102,12 @@ typedef struct { #define LINUX_CTL_MAXNAME 10 +#define LINUX_AT_SYSINFO 32 +#define LINUX_AT_SYSINFO_EHDR 33 +#define LINUX_AT_COUNT 16 /* Count of used aux entry types. + * Keep this synchronized with + * elf_linux_fixup() code. + */ struct l___sysctl_args { l_int *name; diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 42365fb..b44fb00 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -58,11 +58,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include +#include #include #include #include @@ -107,6 +109,10 @@ static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); static void exec_linux_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings); +static register_t *linux_copyout_strings(struct image_params *imgp); + +static int linux_szplatform; +const char *linux_platform; extern LIST_HEAD(futex_list, futex) futex_list; extern struct sx futex_sx; @@ -231,22 +237,30 @@ linux_fixup(register_t **stack_base, struct image_params *imgp) **stack_base = (intptr_t)(void *)argv; (*stack_base)--; **stack_base = imgp->args->argc; - return 0; + return (0); } static int elf_linux_fixup(register_t **stack_base, struct image_params *imgp) { + struct proc *p; Elf32_Auxargs *args; + Elf32_Addr *uplatform; + struct ps_strings *arginfo; register_t *pos; KASSERT(curthread->td_proc == imgp->proc, ("unsafe elf_linux_fixup(), should be curproc")); + + p = imgp->proc; + arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings; + uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szsigcode - + linux_szplatform); args = (Elf32_Auxargs *)imgp->auxargs; pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2); - if (args->execfd != -1) - AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); + AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature); + AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, hz); AUXARGS_ENTRY(pos, AT_PHDR, args->phdr); AUXARGS_ENTRY(pos, AT_PHENT, args->phent); AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum); @@ -254,10 +268,14 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp) AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY(pos, AT_BASE, args->base); - AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid); - AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid); - AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid); - AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid); + AUXARGS_ENTRY(pos, LINUX_AT_SECURE, 0); + AUXARGS_ENTRY(pos, LINUX_AT_UID, imgp->proc->p_ucred->cr_ruid); + AUXARGS_ENTRY(pos, LINUX_AT_EUID, imgp->proc->p_ucred->cr_svuid); + AUXARGS_ENTRY(pos, LINUX_AT_GID, imgp->proc->p_ucred->cr_rgid); + AUXARGS_ENTRY(pos, LINUX_AT_EGID, imgp->proc->p_ucred->cr_svgid); + AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(uplatform)); + if (args->execfd != -1) + AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); @@ -265,9 +283,125 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp) (*stack_base)--; **stack_base = (register_t)imgp->args->argc; - return 0; + return (0); +} + +/* + * Copied from kern/kern_exec.c + */ +static register_t * +linux_copyout_strings(struct image_params *imgp) +{ + int argc, envc; + char **vectp; + char *stringp, *destp; + register_t *stack_base; + struct ps_strings *arginfo; + struct proc *p; + + /* + * Calculate string base and vector table pointers. + * Also deal with signal trampoline code for this exec type. + */ + p = imgp->proc; + arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings; + destp = (caddr_t)arginfo - linux_szsigcode - SPARE_USRSPACE - + linux_szplatform - roundup((ARG_MAX - imgp->args->stringspace), + sizeof(char *)); + + /* + * install sigcode + */ + copyout(p->p_sysent->sv_sigcode, ((caddr_t)arginfo - + linux_szsigcode), linux_szsigcode); + + /* + * install LINUX_PLATFORM + */ + copyout(linux_platform, ((caddr_t)arginfo - linux_szsigcode - + linux_szplatform), linux_szplatform); + + /* + * If we have a valid auxargs ptr, prepare some room + * on the stack. + */ + if (imgp->auxargs) { + /* + * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for + * lower compatibility. + */ + imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size : + (LINUX_AT_COUNT * 2); + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets,and imgp->auxarg_size is room + * for argument of Runtime loader. + */ + vectp = (char **)(destp - (imgp->args->argc + + imgp->args->envc + 2 + imgp->auxarg_size) * sizeof(char *)); + } else { + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets + */ + vectp = (char **)(destp - (imgp->args->argc + imgp->args->envc + 2) * + sizeof(char *)); + } + + /* + * vectp also becomes our initial stack base + */ + stack_base = (register_t *)vectp; + + stringp = imgp->args->begin_argv; + argc = imgp->args->argc; + envc = imgp->args->envc; + + /* + * Copy out strings - arguments and environment. + */ + copyout(stringp, destp, ARG_MAX - imgp->args->stringspace); + + /* + * Fill in "ps_strings" struct for ps, w, etc. + */ + suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp); + suword(&arginfo->ps_nargvstr, argc); + + /* + * Fill in argument portion of vector table. + */ + for (; argc > 0; --argc) { + suword(vectp++, (long)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* a null vector table pointer separates the argp's from the envp's */ + suword(vectp++, 0); + + suword(&arginfo->ps_envstr, (long)(intptr_t)vectp); + suword(&arginfo->ps_nenvstr, envc); + + /* + * Fill in environment portion of vector table. + */ + for (; envc > 0; --envc) { + suword(vectp++, (long)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* end of vector table is a null pointer */ + suword(vectp, 0); + + return (stack_base); } + + extern int _ucodesel, _udatasel; extern unsigned long linux_sznonrtsigcode; @@ -808,6 +942,29 @@ exec_linux_setregs(struct thread *td, u_long entry, fldcw(&control); } +static int +linux_get_machine(const char **dst) +{ + const char *class; + + switch (cpu_class) { + case CPUCLASS_686: + class = "i686"; + break; + case CPUCLASS_586: + class = "i586"; + break; + case CPUCLASS_486: + class = "i486"; + break; + default: + class = "i386"; + } + *dst = class; + return (0); +} + + struct sysentvec linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, @@ -863,7 +1020,7 @@ struct sysentvec elf_linux_sysvec = { .sv_usrstack = USRSTACK, .sv_psstrings = PS_STRINGS, .sv_stackprot = VM_PROT_ALL, - .sv_copyout_strings = exec_copyout_strings, + .sv_copyout_strings = linux_copyout_strings, .sv_setregs = exec_linux_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, @@ -929,6 +1086,9 @@ linux_elf_modevent(module_t mod, int type, void *data) NULL, 1000); linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec, NULL, 1000); + linux_get_machine(&linux_platform); + linux_szplatform = roundup(strlen(linux_platform) + 1, + sizeof(char *)); if (bootverbose) printf("Linux ELF exec handler installed\n"); } else diff --git a/sys/ia64/include/elf.h b/sys/ia64/include/elf.h index faab8d1..982629c 100644 --- a/sys/ia64/include/elf.h +++ b/sys/ia64/include/elf.h @@ -82,16 +82,8 @@ __ElfType(Auxinfo); #define AT_BASE 7 /* Interpreter's base address. */ #define AT_FLAGS 8 /* Flags (unused for i386). */ #define AT_ENTRY 9 /* Where interpreter should transfer control. */ -/* - * The following non-standard values are used in Linux ELF binaries. - */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_COUNT 15 /* Count of defined aux entry types. */ +#define AT_COUNT 10 /* Count of defined aux entry types. */ /* * Values for e_flags. diff --git a/sys/powerpc/include/elf.h b/sys/powerpc/include/elf.h index 422a86a..d2b8e12 100644 --- a/sys/powerpc/include/elf.h +++ b/sys/powerpc/include/elf.h @@ -80,6 +80,9 @@ __ElfType(Auxinfo); #define AT_COUNT 13 /* Count of defined aux entry types. */ +/* Used in John Polstra's testbed stuff. */ +#define AT_DEBUG 14 /* Debugging level. */ + /* * Relocation types. */ diff --git a/sys/sparc64/include/elf.h b/sys/sparc64/include/elf.h index 108ade1..c826197 100644 --- a/sys/sparc64/include/elf.h +++ b/sys/sparc64/include/elf.h @@ -78,16 +78,8 @@ __ElfType(Auxinfo); #define AT_BASE 7 /* Interpreter's base address. */ #define AT_FLAGS 8 /* Flags (unused). */ #define AT_ENTRY 9 /* Where interpreter should transfer control. */ -/* - * The following non-standard values are used in Linux ELF binaries. - */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_COUNT 15 /* Count of defined aux entry types. */ +#define AT_COUNT 10 /* Count of defined aux entry types. */ /* Define "machine" characteristics */ #if __ELF_WORD_SIZE == 32 diff --git a/sys/sun4v/include/elf.h b/sys/sun4v/include/elf.h index 108ade1..c826197 100644 --- a/sys/sun4v/include/elf.h +++ b/sys/sun4v/include/elf.h @@ -78,16 +78,8 @@ __ElfType(Auxinfo); #define AT_BASE 7 /* Interpreter's base address. */ #define AT_FLAGS 8 /* Flags (unused). */ #define AT_ENTRY 9 /* Where interpreter should transfer control. */ -/* - * The following non-standard values are used in Linux ELF binaries. - */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_COUNT 15 /* Count of defined aux entry types. */ +#define AT_COUNT 10 /* Count of defined aux entry types. */ /* Define "machine" characteristics */ #if __ELF_WORD_SIZE == 32 -- Have fun! chd From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 21:39:42 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56720106564A; Wed, 17 Dec 2008 21:39:42 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 0C62E8FC12; Wed, 17 Dec 2008 21:39:41 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mBHLaurR079701; Wed, 17 Dec 2008 14:36:56 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 17 Dec 2008 14:37:02 -0700 (MST) Message-Id: <20081217.143702.-1286520955.imp@bsdimp.com> To: dchagin@freebsd.org From: "M. Warner Losh" In-Reply-To: <20081217172047.GA2884@dchagin.dialup.corbina.ru> References: <20081216212746.GA28834@freebsd.org> <20081216.161638.644659879.imp@bsdimp.com> <20081217172047.GA2884@dchagin.dialup.corbina.ru> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: Removing some cruft... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 21:39:42 -0000 In message: <20081217172047.GA2884@dchagin.dialup.corbina.ru> Chagin Dmitry writes: : Hi, I am ready to offer more radical patch :) : : Move all Linux aux entry types to a new file compat/linux/linux_elf.h : Add two new aux entries which improve work of futexes. : : Please review. thnx! : : diff --git a/sys/amd64/include/elf.h b/sys/amd64/include/elf.h : index a4c7f79..3c2cd20 100644 : --- a/sys/amd64/include/elf.h : +++ b/sys/amd64/include/elf.h : @@ -81,16 +81,8 @@ __ElfType(Auxinfo); : #define AT_BASE 7 /* Interpreter's base address. */ : #define AT_FLAGS 8 /* Flags (unused for i386). */ : #define AT_ENTRY 9 /* Where interpreter should transfer control. */ : -/* : - * The following non-standard values are used in Linux ELF binaries. : - */ : -#define AT_NOTELF 10 /* Program is not ELF ?? */ : -#define AT_UID 11 /* Real uid. */ : -#define AT_EUID 12 /* Effective uid. */ : -#define AT_GID 13 /* Real gid. */ : -#define AT_EGID 14 /* Effective gid. */ : : -#define AT_COUNT 15 /* Count of defined aux entry types. */ It turns out that these are not non-standard Linux values. SYSV also uses these, and the MIPS ABI defines them as well. Let's leave them in place. It may make sense to move these AT_ definitions to a more central location, however, since I think they are the same on all platforms. A quick grep of the Binutils directory seems to support this, but I only have the MIPS ABI specs. I also think that we should be exporting them in the normal path, but that may open up a can of warms so needs to be tested/reviewed carefully before we pull the trigger. Warner From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 21:58:50 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA854106564A for ; Wed, 17 Dec 2008 21:58:50 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.233]) by mx1.freebsd.org (Postfix) with ESMTP id 9A43F8FC08 for ; Wed, 17 Dec 2008 21:58:50 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id b25so235490rvf.43 for ; Wed, 17 Dec 2008 13:58:50 -0800 (PST) Received: by 10.140.194.21 with SMTP id r21mr582659rvf.256.1229551130175; Wed, 17 Dec 2008 13:58:50 -0800 (PST) Received: from ?10.0.1.199? (udp005586uds.hawaiiantel.net [72.234.105.237]) by mx.google.com with ESMTPS id b8sm10739261rvf.3.2008.12.17.13.58.47 (version=SSLv3 cipher=RC4-MD5); Wed, 17 Dec 2008 13:58:48 -0800 (PST) Date: Wed, 17 Dec 2008 11:57:47 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Paul Saab In-Reply-To: <5c0ff6a70812162349n38395f84o45020f334cd09853@mail.gmail.com> Message-ID: <20081217115632.V960@desktop> References: <20081209155714.K960@desktop> <5c0ff6a70812162349n38395f84o45020f334cd09853@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org Subject: Re: UMA & mbuf cache utilization. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 21:58:51 -0000 On Tue, 16 Dec 2008, Paul Saab wrote: > So far testing has shown in a pure transmit test, that this doesn't hurt > performance at all. It would appear that our stack at present is not concurrent enough for this optimization to help as it does elsewhere. Rather than needlessly complicate things at this time I'm going to go ahead and commit the uma portion so that this work isn't lost and leave the mbuf changes until such time that they are advantageous. This will allow for further experimentation as well. Thanks, Jeff > > On Tue, Dec 9, 2008 at 6:22 PM, Jeff Roberson wrote: > >> Hello, >> >> Nokia has graciously allowed me to release a patch which I developed to >> improve general mbuf and cluster cache behavior. This is based on others >> observations that due to simple alignment at 2k and 256k we achieve a poor >> cache distribution for the header area of packets and the most heavily used >> mbuf header fields. In addition, modern machines stripe memory access >> across several memories and even memory controllers. Accessing heavily >> aligned locations such as these can also create load imbalances among >> memories. >> >> To solve this problem I have added two new features to UMA. The first is >> the zone flag UMA_ZONE_CACHESPREAD. This flag modifies the meaning of the >> alignment field such that start addresses are staggered by at least align + >> 1 bytes. In the case of clusters and mbufs this means adding >> uma_cache_align + 1 bytes to the amount of storage allocated. This creates >> a certain constant amount of waste, 3% and 12% respectively. It also means >> we must use contiguous physical and virtual memory consisting of several >> pages to efficiently use the memory and land on as many cache lines as >> possible. >> >> Because contiguous physical memory is not always available, the allocator >> had to have a fallback mechanism. We don't simply want to have all mbuf >> allocations check two zones as once we deplete available contiguous memory >> the check on the first zone will always fail using the most expensive code >> path. >> >> To resolve this issue, I added the ability for secondary zones to stack on >> top of multiple primary zones. Secondary zones are zones which get their >> storage from another zone but handle their own caching, ctors, dtors, etc. >> By adding this feature a secondary zone can be created that can allocate >> either from the contiguous memory pool or the non-contiguous single-page >> pool depending on availability. It is also much faster to fail between them >> deep in the allocator because it is only required when we exhaust the >> already available mbuf memory. >> >> For mbufs and clusters there are now three zones each. A contigmalloc >> backed zone, a single-page allocator zone, and a secondary zone with the >> original zome_mbuf or zone_clust name. The packet zone also takes from both >> available mbuf zones. The individual backend zones are not exposed outside >> of kern_mbuf.c. >> >> Currently, each backend zone can have its own limit. The secondary zone >> only blocks when both are full. Statistic wise the limit should be reported >> as the sum of the backend limits, however, that isn't presently done. The >> secondary zone can not have its own limit independent of the backends at >> this time. I'm not sure if that's valuable or not. >> >> I have test results from nokia which show a dramatic improvement in several >> workloads but which I am probably not at liberty to discuss. I'm in the >> process of convincing Kip to help me get some benchmark data on our stack. >> >> Also as part of the patch I renamed a few functions since many were >> non-obvious and grew new keg abstractions to tidy things up a bit. I >> suspect those of you with UMA experience (robert, bosko) will find the >> renaming a welcome improvement. >> >> The patch is available at: >> http://people.freebsd.org/~jeff/mbuf_contig.diff >> >> I would love to hear any feedback you may have. I have been developing >> this and testing various version off and on for months, however, this is a >> fresh port to current and it is a little green so should be considered >> experimental. >> >> In particular, I'm most nervous about how the vm will respond to new >> pressure on contig physical pages. I'm also interested in hearing from >> embedded/limited memory people about how we might want to limit or tune >> this. >> >> Thanks, >> Jeff >> _______________________________________________ >> freebsd-arch@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-arch >> To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" >> >> > From owner-freebsd-arch@FreeBSD.ORG Thu Dec 18 06:19:11 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04E201065674 for ; Thu, 18 Dec 2008 06:19:11 +0000 (UTC) (envelope-from andy.lavr@reactor-xg.kiev.ua) Received: from mail.reactor-xg.kiev.ua (reactor-xg.kiev.ua [77.87.33.247]) by mx1.freebsd.org (Postfix) with ESMTP id 7D8608FC17 for ; Thu, 18 Dec 2008 06:19:10 +0000 (UTC) (envelope-from andy.lavr@reactor-xg.kiev.ua) Received: from mail.reactor-xg.kiev.ua (mail.reactor-xg.kiev.ua [77.87.33.247]) by mail.reactor-xg.kiev.ua (Reactor-XG Mailer System) with ESMTP id mBI64HEY039832; Thu, 18 Dec 2008 08:04:18 +0200 (EET) (envelope-from andy.lavr@reactor-xg.kiev.ua) Authentication-Results: mail.reactor-xg.kiev.ua; sender-id=pass header.from=andy.lavr@reactor-xg.kiev.ua; auth=pass (PLAIN); spf=pass smtp.mfrom=andy.lavr@reactor-xg.kiev.ua Message-ID: <4949E7E1.8050802@reactor-xg.kiev.ua> Date: Thu, 18 Dec 2008 08:04:17 +0200 From: "Andrei V. Lavreniyuk" Organization: Technica-03, Inc. User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: freebsd-arch@freebsd.org, jroberson@jroberson.net X-Enigmail-Version: 0.95.6 OpenPGP: Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.94.2/8777/Wed Dec 17 19:36:59 2008 on mail.reactor-xg.kiev.ua X-Virus-Status: Clean Cc: Subject: UMA & mbuf cache utilization. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: andy.lavr@gmail.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2008 06:19:11 -0000 Hi! ----------------------------- My system: # uname -a FreeBSD datacenter.technica-03.local 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Wed Dec 17 17:39:46 EET 2008 root@datacenter.technica-03.local:/usr/obj/usr/src/sys/SMP-DATACENTER i386 + SSP +ZFS + mbuf_contig.diff --------------------------- The system works 1-2 hours and hangs up. Without a patch mbuf works stably. What information is yet needed for my hand? -- Best regards, Andrei V. Lavreniyuk. From owner-freebsd-arch@FreeBSD.ORG Thu Dec 18 13:39:19 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 95DAC1065674 for ; Thu, 18 Dec 2008 13:39:19 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mx1.freebsd.org (Postfix) with ESMTP id 506CA8FC08 for ; Thu, 18 Dec 2008 13:39:19 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: by yx-out-2324.google.com with SMTP id 8so547459yxb.13 for ; Thu, 18 Dec 2008 05:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=e+E5MJSsXmpGwdNhZYoUQC5N4EhBnbtUf7QHSHcBpSQ=; b=tqfsY7k6SYzRB1+CObMNZnhyyTshSy9ixxFN6jAZy5xwwuGINHUGDC4fb7+3R3+Ikj 7+wxw6ceM1l9xn9mCeTe7awPnhtSKYv4IiYciqHsESL4dp/3sCIu4WIZQgQTAcXQkPsv UVUwXTn38Z3s0vxFGxV5jhEXsuc4VbmX1kH0g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=RTa6H90GQEwd1y+rigsS7600fd1lZtQJiymn9OkY3uZx56LNFG2MrE25NQzZfjiqNI JUtUx+gSB56bQdcL4VtSP+tJmRmR/aSyg5ISFNuhSCIdyyoKnt9VaHHY4g9uaPXpGvwa fnmVPiWndu601X2P70I+IlrJbI3oFT48dZZVU= Received: by 10.90.98.12 with SMTP id v12mr1059519agb.64.1229607558652; Thu, 18 Dec 2008 05:39:18 -0800 (PST) Received: by 10.90.91.14 with HTTP; Thu, 18 Dec 2008 05:39:17 -0800 (PST) Message-ID: Date: Thu, 18 Dec 2008 16:39:17 +0300 From: pluknet To: andy.lavr@gmail.com In-Reply-To: <4949E7E1.8050802@reactor-xg.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4949E7E1.8050802@reactor-xg.kiev.ua> Cc: freebsd-arch@freebsd.org Subject: Re: UMA & mbuf cache utilization. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2008 13:39:19 -0000 2008/12/18 Andrei V. Lavreniyuk : > Hi! > > > > ----------------------------- > My system: > > > # uname -a > FreeBSD datacenter.technica-03.local 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE > #0: Wed Dec 17 17:39:46 EET 2008 > root@datacenter.technica-03.local:/usr/obj/usr/src/sys/SMP-DATACENTER i386 > > + SSP > > +ZFS > > + mbuf_contig.diff > --------------------------- > > > > The system works 1-2 hours and hangs up. Without a patch mbuf works stably. > > What information is yet needed for my hand? > See http://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug.html At first you need those options in the kernel config to extract a useful info. options KDB # Enable kernel debugger support. options DDB # Support DDB. options GDB # Support remote GDB. options INVARIANTS # Enable calls of extra sanity checking options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed -- wbr, pluknet From owner-freebsd-arch@FreeBSD.ORG Thu Dec 18 23:24:24 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F41771065673 for ; Thu, 18 Dec 2008 23:24:23 +0000 (UTC) (envelope-from apache@cauquenes.cl) Received: from cauquenes.cl (200-54-154-10.static.tie.cl [200.54.154.10]) by mx1.freebsd.org (Postfix) with ESMTP id 7E23A8FC16 for ; Thu, 18 Dec 2008 23:24:23 +0000 (UTC) (envelope-from apache@cauquenes.cl) Received: from cauquenes.cl (alhost.localdomain [127.0.0.1]) by cauquenes.cl (8.12.8/8.12.8) with ESMTP id mBIK3TC9029660 for ; Thu, 18 Dec 2008 17:03:29 -0300 Received: (from apache@localhost) by cauquenes.cl (8.12.8/8.12.8/Submit) id mBIK3SJb029658; Thu, 18 Dec 2008 17:03:28 -0300 Date: Thu, 18 Dec 2008 17:03:28 -0300 Message-Id: <200812182003.mBIK3SJb029658@cauquenes.cl> To: arch@freebsd.org From: GADGETS LIMITED (UK) MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit Cc: Subject: Get Your Blackberry Storm9500/$350 or Apple iphone 16GB/$250 or Blackberry Bold/$300 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gadgetsltd2@gmail.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2008 23:24:24 -0000 eND OF YR bONUS: Blackberry Storm,Apple iPhone,Samsung Omnia GSM PHONES Apple iPhone 16GB............$250 USD Blackberry Bold..............$300 USD Blackberry Storm.............$350 USD Samsung Omnia i900 (16GB)....$470 USD HTC Touch Pro................$400 USD HTC Diamond .................$400 USD Nokia N96....................$350 USD Nokia N85....................$350 USD Nokia E71....................$300 USD Nokia E66....................$300 USD Motorola V3i D&G......$250 USD Nokia N95......... ...$320 USD Nokia N93......... ...$260 USD Nokia N93i ...........$280 USD Nokia N70 ............$160 USD Nokia N73 ............$250 USD Nokia N80 ............$200 USD Nokia N90 ............$200 USD Nokia N91 ............$200 USD BUY ANY 5 UNITS AND GET 2 FREE All GSM Phones,Brand New,Tri- Band and Video Games are also Brand new with Complete Accessories plus Int'l Warranty . e-mail us for more enquiry gadgetsltd2@gmail.com Robert Johnson GADGETS LIMITED (UK) LTD Registered No. 05881519 THE OLD STABLES, ARUNDEL ROAD, POLING, ARUNDEL, WEST SUSSEX, BN18 9QA, UK From owner-freebsd-arch@FreeBSD.ORG Fri Dec 19 06:47:30 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A97041065674 for ; Fri, 19 Dec 2008 06:47:30 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.232]) by mx1.freebsd.org (Postfix) with ESMTP id 89E558FC08 for ; Fri, 19 Dec 2008 06:47:30 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id b25so2216100rvf.43 for ; Thu, 18 Dec 2008 22:47:30 -0800 (PST) Received: by 10.140.139.6 with SMTP id m6mr1383803rvd.242.1229667664583; Thu, 18 Dec 2008 22:21:04 -0800 (PST) Received: from ?10.0.1.199? (udp005586uds.hawaiiantel.net [72.234.105.237]) by mx.google.com with ESMTPS id f21sm7992365rvb.7.2008.12.18.22.21.01 (version=SSLv3 cipher=RC4-MD5); Thu, 18 Dec 2008 22:21:03 -0800 (PST) Date: Thu, 18 Dec 2008 20:20:09 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: andy.lavr@gmail.com In-Reply-To: <4949E7E1.8050802@reactor-xg.kiev.ua> Message-ID: <20081218201934.Q960@desktop> References: <4949E7E1.8050802@reactor-xg.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-arch@freebsd.org Subject: Re: UMA & mbuf cache utilization. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2008 06:47:30 -0000 On Thu, 18 Dec 2008, Andrei V. Lavreniyuk wrote: > Hi! > > > > ----------------------------- > My system: > > > # uname -a > FreeBSD datacenter.technica-03.local 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE > #0: Wed Dec 17 17:39:46 EET 2008 > root@datacenter.technica-03.local:/usr/obj/usr/src/sys/SMP-DATACENTER i386 > > + SSP > > +ZFS > > + mbuf_contig.diff > --------------------------- > > > > The system works 1-2 hours and hangs up. Without a patch mbuf works stably. > > What information is yet needed for my hand? Did you apply this to -CURRENT or 7.1? It is not safe for use in 7.1. There is also currently a problem with ipx that must be fixed. Thanks, Jeff > > > > > -- > Best regards, Andrei V. Lavreniyuk. >