From owner-freebsd-audit Sun Jan 20 14:35:42 2002 Delivered-To: freebsd-audit@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 2CAE137B419 for ; Sun, 20 Jan 2002 14:35:39 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id JAA02162 for ; Mon, 21 Jan 2002 09:35:37 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01KDBTU9XBDCVFMUFG@cim.alcatel.com.au> for freebsd-audit@freebsd.org; Mon, 21 Jan 2002 09:35:46 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.6/8.11.6) id g0KMZXU63643 for freebsd-audit@freebsd.org; Mon, 21 Jan 2002 09:35:33 +1100 Content-return: prohibited Date: Mon, 21 Jan 2002 09:35:33 +1100 From: Peter Jeremy Subject: systat(1) bugs To: freebsd-audit@freebsd.org Mail-Followup-To: freebsd-audit@freebsd.org Message-id: <20020121093532.D72285@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Please cc me on replies, I don't normally read -audit] I've found some elements of the "systat -vmstat" display to be unclear or misleading (particularly the placement of the "count" and "pages" to the left of the PAGER columns to which they refer - making them appear to relate to the VM stats to their left). It is also possible for several numeric columns to run together in some conditions. There are also a number of discrepancies between the man page and the actual behaviour. I am currently (but slowly) working on a patch to clean this up, but don't want to duplicate anyone elses work. If anyone else is working on systat, they might like to get in touch. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jan 20 16: 1:30 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailout08.sul.t-online.com (mailout08.sul.t-online.com [194.25.134.20]) by hub.freebsd.org (Postfix) with ESMTP id 1EE7137B400; Sun, 20 Jan 2002 16:01:27 -0800 (PST) Received: from fwd05.sul.t-online.de by mailout08.sul.t-online.com with smtp id 16SRtm-0007hy-02; Mon, 21 Jan 2002 01:01:18 +0100 Received: from Gatekeeper.FreeBSD.org (520047440004-0001@[80.132.243.249]) by fmrl05.sul.t-online.com with esmtp id 16SRtl-09nz8KC; Mon, 21 Jan 2002 01:01:17 +0100 Received: from StefanEsser.FreeBSD.org (StefanEsser [10.0.0.1]) by Gatekeeper.FreeBSD.org (Postfix) with ESMTP id BDA935F0F; Mon, 21 Jan 2002 01:01:40 +0100 (CET) Received: by StefanEsser.FreeBSD.org (Postfix, from userid 200) id A4C05C05; Mon, 21 Jan 2002 01:04:58 +0100 (CET) Date: Mon, 21 Jan 2002 01:04:58 +0100 From: Stefan Esser To: Peter Jeremy Cc: freebsd-audit@FreeBSD.ORG, Stefan Esser Subject: Re: systat(1) bugs Message-ID: <20020121000458.GA95702@StefanEsser.FreeBSD.org> Reply-To: Stefan Esser References: <20020121093532.D72285@gsmx07.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020121093532.D72285@gsmx07.alcatel.com.au> User-Agent: Mutt/1.3.26i X-Sender: 520047440004-0001@t-dialin.net Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-01-21 09:35 +1100, Peter Jeremy wrote: > I am currently (but slowly) working on a patch to clean this up, but > don't want to duplicate anyone elses work. If anyone else is working > on systat, they might like to get in touch. The namei Dir-cache % display is wrong, since it calculates the percentage based on the total number of requests, not based on the number of Name-cache misses. (I.e. with 1000 calls to namei, 950 of them name-cache hits, 30 dir-cache hits, the percentage will be calculated as 3% (30/1000), while it actually should come out as 60% (30/(1000-950)) ...) Fix appended! Regards, STefan Index: vmstat.c =================================================================== RCS file: /usr/cvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.50 diff -u -3 -r1.50 vmstat.c --- vmstat.c 12 Dec 2001 00:13:37 -0000 1.50 +++ vmstat.c 21 Jan 2002 00:03:30 -0000 @@ -565,7 +565,8 @@ 100.0 / nz(s.nchcount), NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1); putint(nchtotal.ncs_pass2, NAMEIROW + 2, NAMEICOL + 23, 9); - putfloat(nchtotal.ncs_pass2 * 100.0 / nz(s.nchcount), + putfloat(nchtotal.ncs_pass2 * + 100.0 / nz(s.nchcount-(nchtotal.ncs_goodhits+nchtotal.ncs_neghits)), NAMEIROW + 2, NAMEICOL + 33, 4, 0, 1); #undef nz } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Jan 21 16: 5:26 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 7B6AC37B400 for ; Mon, 21 Jan 2002 16:05:23 -0800 (PST) Received: from hades.hell.gr (patr530-b165.otenet.gr [212.205.244.173]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id g0M05K417626 for ; Tue, 22 Jan 2002 02:05:20 +0200 (EET) Received: by hades.hell.gr (Postfix, from userid 1001) id 9BECD3E; Tue, 22 Jan 2002 01:54:42 +0200 (EET) Date: Tue, 22 Jan 2002 01:54:41 +0200 From: Giorgos Keramidas To: audit@FreeBSD.org Subject: minor sys/sys/errno.h style change? Message-ID: <20020121235440.GA644@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.25i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG What do you all think of this small change to sys/sys/errno.h ? ENOTSUP is the only error code that is not indented with a tab after the #define statement. All others use a tab. You can quickly check this at your copy of errno.h, with `set ts=15' while editing in vi(1). - Giorgos Index: errno.h =================================================================== RCS file: /home/ncvs/src/sys/sys/errno.h,v retrieving revision 1.17 diff -2 -u -r1.17 errno.h --- errno.h 27 Aug 2001 17:05:29 -0000 1.17 +++ errno.h 21 Jan 2002 23:47:48 -0000 @@ -109,5 +109,5 @@ #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ #define EOPNOTSUPP 45 /* Operation not supported */ -#define ENOTSUP EOPNOTSUPP /* Operation not supported */ +#define ENOTSUP EOPNOTSUPP /* Operation not supported */ #define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Jan 21 16:55: 7 2002 Delivered-To: freebsd-audit@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id B534A37B402; Mon, 21 Jan 2002 16:55:01 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g0M0pmZ10877; Mon, 21 Jan 2002 19:51:48 -0500 (EST) (envelope-from mike) Date: Mon, 21 Jan 2002 19:51:48 -0500 From: Mike Barcroft To: Giorgos Keramidas Cc: audit@FreeBSD.org Subject: Re: minor sys/sys/errno.h style change? Message-ID: <20020121195148.F68881@espresso.q9media.com> References: <20020121235440.GA644@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020121235440.GA644@hades.hell.gr>; from keramida@FreeBSD.org on Tue, Jan 22, 2002 at 01:54:41AM +0200 Organization: The FreeBSD Project Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Giorgos Keramidas writes: > What do you all think of this small change to sys/sys/errno.h ? > ENOTSUP is the only error code that is not indented with a tab after > the #define statement. All others use a tab. You can quickly check > this at your copy of errno.h, with `set ts=15' while editing in vi(1). The patch is correct. Go ahead and commit it. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Jan 22 4:37:27 2002 Delivered-To: freebsd-audit@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id E658837B402; Tue, 22 Jan 2002 04:37:19 -0800 (PST) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 22 Jan 2002 12:28:39 +0000 (GMT) To: freebsd-audit@freebsd.org Cc: peter@freebsd.org, clemej@alum.rpi.edu Subject: Athlon SSE patch. X-Request-Do: Date: Tue, 22 Jan 2002 12:28:38 +0000 From: David Malone Message-ID: <200201221228.ab83863@salmon.maths.tcd.ie> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG It seems that Athlon processors need the BIOS to enable SSE if it is present on your processor. It also seems that some BIOS writers don't do this for all processors (I have a ASUS A7A266 which claims to support my Athlon XP, but doesn't enable SSE). Based on a description of the problem which I found at: http://www.deater.net/john/PavilionN5430.html I've produced a patch for FreeBSD-current. Since AMD doc 21656 doesn't seem to be publically available I can't really check the patch is exactly right, but it does work on my processor. I'd like to commit this patch in a few days. If someone else has a recent Athlon which doesn't show SSE in the list of features I'd be greatful if they could test the patch for me. (This involved rebuilding your kernel with "option CPU_ATHLON_SSE_HACK" and rebooting). David. Index: conf/options.i386 =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/conf/options.i386,v retrieving revision 1.163 diff -u -r1.163 options.i386 --- conf/options.i386 21 Dec 2001 21:46:55 -0000 1.163 +++ conf/options.i386 22 Jan 2002 11:02:45 -0000 @@ -64,6 +64,7 @@ CYRIX_CACHE_REALLY_WORKS opt_cpu.h NO_MEMORY_HOLE opt_cpu.h CPU_ENABLE_SSE opt_cpu.h +CPU_ATHLON_SSE_HACK opt_cpu.h # The CPU type affects the endian conversion functions all over the kernel. I386_CPU opt_global.h Index: conf/options.pc98 =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/conf/options.pc98,v retrieving revision 1.137 diff -u -r1.137 options.pc98 --- conf/options.pc98 22 Dec 2001 00:48:39 -0000 1.137 +++ conf/options.pc98 22 Jan 2002 11:22:56 -0000 @@ -64,6 +64,7 @@ CYRIX_CACHE_REALLY_WORKS opt_cpu.h NO_MEMORY_HOLE opt_cpu.h CPU_ENABLE_SSE opt_cpu.h +CPU_ATHLON_SSE_HACK opt_cpu.h # The CPU type affects the endian conversion functions all over the kernel. I386_CPU opt_global.h Index: i386/conf/NOTES =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/i386/conf/NOTES,v retrieving revision 1.992 diff -u -r1.992 NOTES --- i386/conf/NOTES 20 Jan 2002 08:51:07 -0000 1.992 +++ i386/conf/NOTES 22 Jan 2002 11:24:44 -0000 @@ -198,6 +198,9 @@ # # CPU_ENABLE_SSE enables SSE/MMX2 instructions support. # +# CPU_ATHLON_SSE_HACK tries of enable SSE instructions when the BIOS has +# forgotten to enable them. +# # CPU_FASTER_5X86_FPU enables faster FPU exception handler. # # CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products @@ -262,6 +265,7 @@ options CPU_DIRECT_MAPPED_CACHE options CPU_DISABLE_5X86_LSSER options CPU_ENABLE_SSE +options CPU_ATHLON_SSE_HACK options CPU_FASTER_5X86_FPU options CPU_I486_ON_386 options CPU_IORT Index: i386/i386/identcpu.c =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/i386/i386/identcpu.c,v retrieving revision 1.97 diff -u -r1.97 identcpu.c --- i386/i386/identcpu.c 16 Jan 2002 02:22:19 -0000 1.97 +++ i386/i386/identcpu.c 20 Jan 2002 18:01:31 -0000 @@ -80,7 +80,6 @@ static void print_AMD_assoc(int i); static void print_transmeta_info(void); static void setup_tmx86_longrun(void); -static void do_cpuid(u_int ax, u_int *p); u_int cyrix_did; /* Device ID of Cyrix CPU */ int cpu_class = CPUCLASS_386; /* least common denominator */ @@ -111,16 +110,6 @@ { "Pentium III", CPUCLASS_686 }, /* CPU_PIII */ { "Pentium 4", CPUCLASS_686 }, /* CPU_P4 */ }; - -static void -do_cpuid(u_int ax, u_int *p) -{ - __asm __volatile( - "cpuid" - : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) - : "0" (ax) - ); -} #if defined(I586_CPU) && !defined(NO_F00F_HACK) int has_f00f_bug = 0; Index: i386/i386/initcpu.c =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/i386/i386/initcpu.c,v retrieving revision 1.33 diff -u -r1.33 initcpu.c --- i386/i386/initcpu.c 18 Dec 2001 00:27:15 -0000 1.33 +++ i386/i386/initcpu.c 22 Jan 2002 11:26:17 -0000 @@ -575,6 +575,24 @@ init_mendocino(); break; } + } else if (strcmp(cpu_vendor, "AuthenticAMD") == 0) { +#if defined(I686_CPU) && defined(CPU_ATHLON_SSE_HACK) + /* + * Sometimes the BIOS doesn't enable SSE instructions. + * According to AMD document 20734 these the mobile + * Duron, the (mobile) Athlon 4 and the Athlon MP + * support SSE. These corrispond to cpu_id 0x66X + * or 0x67X. + */ + if ((cpu_feature & CPUID_XMM) == 0 && + ((cpu_id & ~0xf) == 0x660 || + (cpu_id & ~0xf) == 0x670)) { + u_int regs[4]; + wrmsr(0xC0010015, rdmsr(0xC0010015) & ~0x08000); + do_cpuid(1, regs); + cpu_feature = regs[3]; + } +#endif } break; #endif Index: i386/include/cpufunc.h =================================================================== RCS file: /cvs/FreeBSD-CVS/src/sys/i386/include/cpufunc.h,v retrieving revision 1.107 diff -u -r1.107 cpufunc.h --- i386/include/cpufunc.h 18 Dec 2001 08:54:39 -0000 1.107 +++ i386/include/cpufunc.h 22 Jan 2002 11:56:47 -0000 @@ -365,6 +365,16 @@ return (ef); } +static __inline void +do_cpuid(u_int ax, u_int *p) +{ + __asm __volatile( + "cpuid" + : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) + : "0" (ax) + ); +} + static __inline u_int64_t rdmsr(u_int msr) { @@ -572,6 +582,7 @@ u_int bsfl __P((u_int mask)); u_int bsrl __P((u_int mask)); void disable_intr __P((void)); +void do_cpuid __P((u_int ax, u_int *p)); void enable_intr __P((void)); u_char inb __P((u_int port)); u_int inl __P((u_int port)); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Jan 22 11:54: 8 2002 Delivered-To: freebsd-audit@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 2C4FF37B402; Tue, 22 Jan 2002 11:54:05 -0800 (PST) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id GAA01758; Wed, 23 Jan 2002 06:54:03 +1100 (EDT) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37641) with ESMTP id <01KDEGSMAJ4WVFN3PH@cim.alcatel.com.au>; Wed, 23 Jan 2002 06:54:11 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.6/8.11.6) id g0MJs0A16108; Wed, 23 Jan 2002 06:54:00 +1100 Content-return: prohibited Date: Wed, 23 Jan 2002 06:53:59 +1100 From: Peter Jeremy Subject: Re: systat(1) bugs In-reply-to: <20020121000458.GA95702@StefanEsser.FreeBSD.org>; from se@FreeBSD.org on Mon, Jan 21, 2002 at 01:04:58AM +0100 To: Stefan Esser Cc: freebsd-audit@FreeBSD.org Mail-Followup-To: Stefan Esser , freebsd-audit@FreeBSD.org Message-id: <20020123065359.P72285@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <20020121093532.D72285@gsmx07.alcatel.com.au> <20020121000458.GA95702@StefanEsser.FreeBSD.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-Jan-21 01:04:58 +0100, Stefan Esser wrote: >The namei Dir-cache % display is wrong, since it calculates the >percentage based on the total number of requests, not based on >the number of Name-cache misses. (I.e. with 1000 calls to namei, >950 of them name-cache hits, 30 dir-cache hits, the percentage >will be calculated as 3% (30/1000), while it actually should come >out as 60% (30/(1000-950)) ...) I'm not sure this is as clear-cut. I believe the current behaviour is more correct: To use your numbers, of the 1000 namei() calls, 95% were found in the name-cache and 3% were found in the dir-cache, with the remaining 2% requiring physical reads. This is consistent with my reading on systat(1). I don't see that defining dir-cache as "percent of namei() requests not found in the system wide name translation cache but handled by the per process name translation cache" is an improvement. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Jan 22 12:37:35 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by hub.freebsd.org (Postfix) with ESMTP id 9A5B537B404; Tue, 22 Jan 2002 12:37:31 -0800 (PST) Received: from fwd01.sul.t-online.de by mailout05.sul.t-online.com with smtp id 16T7Tg-0002i7-0G; Tue, 22 Jan 2002 21:25:08 +0100 Received: from Gatekeeper.FreeBSD.org (520047440004-0001@[217.227.243.248]) by fmrl01.sul.t-online.com with esmtp id 16T7Tb-107g2qC; Tue, 22 Jan 2002 21:25:03 +0100 Received: from StefanEsser.FreeBSD.org (StefanEsser [10.0.0.1]) by Gatekeeper.FreeBSD.org (Postfix) with ESMTP id BC7FB5F0F; Tue, 22 Jan 2002 21:25:21 +0100 (CET) Received: by StefanEsser.FreeBSD.org (Postfix, from userid 200) id C12B2A9B; Tue, 22 Jan 2002 21:28:39 +0100 (CET) Date: Tue, 22 Jan 2002 21:28:39 +0100 From: Stefan Esser To: freebsd-audit@FreeBSD.org Cc: Peter Jeremy , Stefan Esser Subject: Re: Re: systat(1) bugs Message-ID: <20020122202839.GA73384@StefanEsser.FreeBSD.org> Reply-To: Stefan Esser References: <20020121093532.D72285@gsmx07.alcatel.com.au> <20020121000458.GA95702@StefanEsser.FreeBSD.org> <20020123065359.P72285@gsmx07.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020123065359.P72285@gsmx07.alcatel.com.au> User-Agent: Mutt/1.3.26i X-Sender: 520047440004-0001@t-dialin.net Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-01-23 06:53 +1100, Peter Jeremy wrote: > On 2002-Jan-21 01:04:58 +0100, Stefan Esser wrote: > >The namei Dir-cache % display is wrong, since it calculates the > >percentage based on the total number of requests, not based on > >the number of Name-cache misses. (I.e. with 1000 calls to namei, > >950 of them name-cache hits, 30 dir-cache hits, the percentage > >will be calculated as 3% (30/1000), while it actually should come > >out as 60% (30/(1000-950)) ...) > > I'm not sure this is as clear-cut. I believe the current behaviour is > more correct: To use your numbers, of the 1000 namei() calls, 95% were > found in the name-cache and 3% were found in the dir-cache, with the > remaining 2% requiring physical reads. This is consistent with my > reading on systat(1). I don't see that defining dir-cache as "percent > of namei() requests not found in the system wide name translation > cache but handled by the per process name translation cache" is an > improvement. Hmmm, there are two possible meanings of the hit percentage: 1) Percentage of namei() calls that hit either the namei or dir cache 2) Cache efficiency of each cache I'm obviously prefering the latter, since the dir cache is only queried for a small fraction (few percent) of all namei calls, and it appears to have a hit ratio of near zero (hardly ever 2%, haven't observed 1% too often). With my patch, I see that the namei() cache speeds up, say, 90% of all namei calls (i.e. a speed factor of 10), while the dir cache provides an answer in another 20% of cases (for another factor of 1.25). If the numbers given by the current display are used, the effect of the dir cache can't really be calculated so easily. (Ok, you can add the two percentages, but since the second number is very small, the result is always dominated by the namei percentage.) Just try systat with and without the patch on a system under various load situations. I just do not consider always printing 0% into the dir cache percentage column too useful ;-) Regards, STefan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 24 11:55:21 2002 Delivered-To: freebsd-audit@freebsd.org Received: from gate-internal.sim.ionidea.com (ion.so-com.net [212.110.132.83]) by hub.freebsd.org (Postfix) with ESMTP id 4FC3637B417; Thu, 24 Jan 2002 11:54:43 -0800 (PST) Received: (from phantom@localhost) by gate-internal.sim.ionidea.com (8.11.6/8.11.1) id g0OJwae58303; Thu, 24 Jan 2002 21:58:36 +0200 (EET) (envelope-from phantom) Date: Thu, 24 Jan 2002 21:58:35 +0200 From: Alexey Zelkin To: audit@freebsd.org, ache@freebsd.org Subject: CFR: strncpy -> strlcpy in setlocale() Message-ID: <20020124215835.A58294@gate.sim.ionidea.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.20i X-Operating-System: FreeBSD 4.2-RELEASE i386 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi, Any objections against this patch ? It's based on rev 1.23 of NetBSD's setlocale.c. --- setlocale.c~ Thu Jan 24 18:13:03 2002 +++ setlocale.c Thu Jan 24 21:56:23 2002 @@ -132,33 +132,35 @@ if (!env || !*env || strchr(env, '/')) env = "C"; - (void) strncpy(new_categories[category], env, ENCODING_LEN); - new_categories[category][ENCODING_LEN] = '\0'; + (void)strlcpy(new_categories[category], env, + sizeof(new_categories[category])); if (category == LC_ALL) { for (i = 1; i < _LC_LAST; ++i) { if (!(env = getenv(categories[i])) || !*env) env = new_categories[LC_ALL]; - (void)strncpy(new_categories[i], env, ENCODING_LEN); - new_categories[i][ENCODING_LEN] = '\0'; + (void)strlcpy(new_categories[i], env, + sizeof(new_categories[category])); } } } else if (category != LC_ALL) { - (void)strncpy(new_categories[category], locale, ENCODING_LEN); - new_categories[category][ENCODING_LEN] = '\0'; + (void)strlcpy(new_categories[category], locale, + sizeof(new_categories[category])); } else { if ((r = strchr(locale, '/')) == NULL) { for (i = 1; i < _LC_LAST; ++i) { - (void)strncpy(new_categories[i], locale, ENCODING_LEN); - new_categories[i][ENCODING_LEN] = '\0'; + (void)strlcpy(new_categories[i], locale, + sizeof(new_categories[category])); } } else { - for (i = 1; r[1] == '/'; ++r); + for (i = 1; r[1] == '/'; ++r) + ; if (!r[1]) return (NULL); /* Hmm, just slashes... */ do { - len = r - locale > ENCODING_LEN ? ENCODING_LEN : r - locale; - (void)strncpy(new_categories[i], locale, len); - new_categories[i][len] = '\0'; + len = r - locale > sizeof(new_categories[i]) + ? sizeof(new_categories[i]) + : r - locale; + (void)strlcpy(new_categories[i], locale, len); i++; locale = r; while (*locale == '/') @@ -167,7 +169,7 @@ } while (*locale); while (i < _LC_LAST) { (void)strcpy(new_categories[i], - new_categories[i-1]); + new_categories[i - 1]); i++; } } @@ -201,8 +203,8 @@ for (i = 2; i < _LC_LAST; ++i) if (strcmp(current_categories[1], current_categories[i])) { for (i = 2; i < _LC_LAST; ++i) { - (void) strcat(current_locale_string, "/"); - (void) strcat(current_locale_string, current_categories[i]); + (void)strcat(current_locale_string, "/"); + (void)strcat(current_locale_string, current_categories[i]); } break; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 24 13:37:45 2002 Delivered-To: freebsd-audit@freebsd.org Received: from nagual.pp.ru (pobrecita.freebsd.ru [194.87.13.42]) by hub.freebsd.org (Postfix) with ESMTP id DBDCA37B402 for ; Thu, 24 Jan 2002 13:37:41 -0800 (PST) Received: (from ache@localhost) by nagual.pp.ru (8.11.6/8.11.6) id g0OLbY787029; Fri, 25 Jan 2002 00:37:34 +0300 (MSK) (envelope-from ache) Date: Fri, 25 Jan 2002 00:37:31 +0300 From: "Andrey A. Chernov" To: Alexey Zelkin Cc: audit@freebsd.org Subject: Re: CFR: strncpy -> strlcpy in setlocale() Message-ID: <20020124213730.GA87013@nagual.pp.ru> References: <20020124215835.A58294@gate.sim.ionidea.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020124215835.A58294@gate.sim.ionidea.com> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jan 24, 2002 at 21:58:35 +0200, Alexey Zelkin wrote: > hi, > > Any objections against this patch ? It's based on > rev 1.23 of NetBSD's setlocale.c. Ok. -- Andrey A. Chernov http://ache.pp.ru/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 24 13:43:11 2002 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id F39BE37B400 for ; Thu, 24 Jan 2002 13:43:07 -0800 (PST) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.6/8.11.5) with SMTP id g0OLgUf65234; Thu, 24 Jan 2002 16:42:31 -0500 (EST) (envelope-from arr@FreeBSD.org) X-Authentication-Warning: fledge.watson.org: arr owned process doing -bs Date: Thu, 24 Jan 2002 16:42:30 -0500 (EST) From: "Andrew R. Reiter" X-Sender: arr@fledge.watson.org To: "Andrey A. Chernov" Cc: Alexey Zelkin , audit@FreeBSD.org Subject: Re: CFR: strncpy -> strlcpy in setlocale() In-Reply-To: <20020124213730.GA87013@nagual.pp.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 25 Jan 2002, Andrey A. Chernov wrote: :On Thu, Jan 24, 2002 at 21:58:35 +0200, Alexey Zelkin wrote: :> hi, :> :> Any objections against this patch ? It's based on :> rev 1.23 of NetBSD's setlocale.c. : :Ok. I know strlcpy() makes more sense than strncpy(), but is there any difference in terms of speed? This being said, if strlcpy() is slower and the strncpy() usage is correct, is there really a need for a change? I guess readability and possible future mistakes in usage are a bonus for strlcpy. Cheers, Andrew -- Andrew R. Reiter arr@watson.org arr@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 24 13:48:45 2002 Delivered-To: freebsd-audit@freebsd.org Received: from xerxes.courtesan.com (courtesan.com [206.168.103.86]) by hub.freebsd.org (Postfix) with ESMTP id 60C9637B41C; Thu, 24 Jan 2002 13:48:37 -0800 (PST) Received: from xerxes.courtesan.com (IDENT:millert@localhost.courtesan.com [127.0.0.1]) by xerxes.courtesan.com (8.12.2/8.12.1) with ESMTP id g0OLmHJi006634; Thu, 24 Jan 2002 14:48:17 -0700 (MST) Message-Id: <200201242148.g0OLmHJi006634@xerxes.courtesan.com> To: "Andrew R. Reiter" Cc: "Andrey A. Chernov" , Alexey Zelkin , audit@FreeBSD.ORG Subject: Re: CFR: strncpy -> strlcpy in setlocale() In-reply-to: Your message of "Thu, 24 Jan 2002 16:42:30 EST." References: Date: Thu, 24 Jan 2002 14:48:17 -0700 From: "Todd C. Miller" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message so spake "Andrew R. Reiter" (arr): > I know strlcpy() makes more sense than strncpy(), but is there any > difference in terms of speed? This being said, if strlcpy() is slower and > the strncpy() usage is correct, is there really a need for a change? I > guess readability and possible future mistakes in usage are a bonus for > strlcpy. strlcpy() is generally faster since strncpy() does NUL fill and so will also write "len" bytes even when the source string is much smaller. - todd To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 24 13:51: 4 2002 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id DF29E37B416 for ; Thu, 24 Jan 2002 13:51:01 -0800 (PST) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.6/8.11.5) with SMTP id g0OLoYb65339; Thu, 24 Jan 2002 16:50:34 -0500 (EST) (envelope-from arr@FreeBSD.org) X-Authentication-Warning: fledge.watson.org: arr owned process doing -bs Date: Thu, 24 Jan 2002 16:50:34 -0500 (EST) From: "Andrew R. Reiter" X-Sender: arr@fledge.watson.org To: "Todd C. Miller" Cc: "Andrey A. Chernov" , Alexey Zelkin , audit@FreeBSD.org Subject: Re: CFR: strncpy -> strlcpy in setlocale() In-Reply-To: <200201242148.g0OLmHJi006634@xerxes.courtesan.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 24 Jan 2002, Todd C. Miller wrote: : :strlcpy() is generally faster since strncpy() does NUL fill and so :will also write "len" bytes even when the source string is much :smaller. Ahh, very cool. Thanks for the information. -- Andrew R. Reiter arr@watson.org arr@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message