From owner-svn-src-head@FreeBSD.ORG Fri Mar 26 13:37:50 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1255106564A; Fri, 26 Mar 2010 13:37:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5C3848FC19; Fri, 26 Mar 2010 13:37:50 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id E7EFF46B29; Fri, 26 Mar 2010 09:37:49 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id B63E38A026; Fri, 26 Mar 2010 09:37:48 -0400 (EDT) From: John Baldwin To: Alexander Leidinger Date: Fri, 26 Mar 2010 09:37:09 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201003261143.o2QBhFhK034688@svn.freebsd.org> In-Reply-To: <201003261143.o2QBhFhK034688@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201003260937.09848.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Fri, 26 Mar 2010 09:37:48 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.7 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r205683 - head/sys/compat/linprocfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2010 13:37:50 -0000 On Friday 26 March 2010 7:43:15 am Alexander Leidinger wrote: > Author: netchild > Date: Fri Mar 26 11:43:15 2010 > New Revision: 205683 > URL: http://svn.freebsd.org/changeset/base/205683 > > Log: > Fix some bogus values in linprocfs. > > Submitted by: Petr Salinger > Verified on: GNU/kFreeBSD debian 8.0-1-686 (by submitter) > PR: 144584 > > Modified: > head/sys/compat/linprocfs/linprocfs.c > > Modified: head/sys/compat/linprocfs/linprocfs.c > ============================================================================== > --- head/sys/compat/linprocfs/linprocfs.c Fri Mar 26 11:33:12 2010 (r205682) > +++ head/sys/compat/linprocfs/linprocfs.c Fri Mar 26 11:43:15 2010 (r205683) > @@ -110,13 +110,36 @@ __FBSDID("$FreeBSD$"); > /* > * Various conversion macros > */ > + > +/* The LINUX_USER_HZ is assumed 100 for now */ > + > +#if defined(__i386__) && defined(__GNUCLIKE_ASM) > +/* we need intermediate result as 64 bit, otherwise it overflows too early */ > +#define DO64_MULDIV(v,m,d) \ > +({ \ > + unsigned long rv0; \ > + unsigned long rv1; \ > + __asm__ __volatile__( \ > + "mull %1\n\t" \ > + "divl %2\n\t" \ > + :"=a" (rv0), "=d" (rv1) \ > + :"r" (d), "0" (v), "1" (m) \ > + :"cc" ); \ > + rv0; \ > +}) > + > +#define T2J(x) DO64_MULDIV((x), 100UL, (stathz ? stathz : hz)) /* ticks to jiffies */ > +#else > #define T2J(x) (((x) * 100UL) / (stathz ? stathz : hz)) /* ticks to jiffies */ > +#endif This is very bogus. Just use a uint64_t cast or the like. Extraneous ()'s around (x)->tv_sec and (x)->tv_usec in TV2J() as well. > @@ -502,12 +525,24 @@ linprocfs_douptime(PFS_FILL_ARGS) > { > long cp_time[CPUSTATES]; > struct timeval tv; > + int cnt, i; > > getmicrouptime(&tv); > read_cpu_time(cp_time); > - sbuf_printf(sb, "%lld.%02ld %ld.%02ld\n", > + > + for (cnt = 0, i = 0; i <= mp_maxid; ++i) > + if (!(CPU_ABSENT(i))) > + cnt++; > + > + if (!cnt) > + cnt = 1; > + > + i = ((cp_time[CP_IDLE])/cnt) % (stathz ? stathz : hz); > + i = (i * 100) / (stathz ? stathz : hz); > + > + sbuf_printf(sb, "%lld.%02ld %ld.%02d\n", > (long long)tv.tv_sec, tv.tv_usec / 10000, > - T2S(cp_time[CP_IDLE]), T2J(cp_time[CP_IDLE]) % 100); > + T2S((cp_time[CP_IDLE]/cnt)), i); > return (0); What's wrong with mp_ncpus? Also, I don't understand how the machinations for i vs the original code (assuming you add in a divisor of the raw cp_time by mp_ncpus) give a different value. > @@ -613,9 +648,17 @@ linprocfs_doprocstat(PFS_FILL_ARGS) > struct kinfo_proc kp; > char state; > static int ratelimit = 0; > + unsigned long startcode, startdata; Why not make these a vm_offset_t and then print them with %j? -- John Baldwin