Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Feb 2012 19:58:59 -0500 (EST)
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        Maxim Konovalov <maxim@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r232156 - head/sys/kern
Message-ID:  <788625604.124085.1330217939168.JavaMail.root@erie.cs.uoguelph.ca>
In-Reply-To: <201202251206.q1PC6eaF016823@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Maxim Konovalov wrote:
> Author: maxim
> Date: Sat Feb 25 12:06:40 2012
> New Revision: 232156
> URL: http://svn.freebsd.org/changeset/base/232156
> 
> Log:
> o Reduce chances for integer overflow.
> o More verbose sysctl description added.
> 
> MFC after: 2 weeks
> Sponsored by: Nginx, Inc.
> 
> Modified:
> head/sys/kern/vfs_cache.c
> 
> Modified: head/sys/kern/vfs_cache.c
> ==============================================================================
> --- head/sys/kern/vfs_cache.c Sat Feb 25 11:07:32 2012 (r232155)
> +++ head/sys/kern/vfs_cache.c Sat Feb 25 12:06:40 2012 (r232156)
> @@ -369,7 +369,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
> maxlength = count;
> }
> n_nchash = nchash + 1;
> - pct = (used * 100 * 100) / n_nchash;
> + pct = (used * 100) / (n_nchash / 100);

You might want to consider a sanity check to make
sure n_nchash is >= 100, to avoid a "divide by zero".

There was an NFS PR# a while back, where "desiredvnodes" was
set very small and resulted in a "divide by zero" in the NFS code.

Just a suggestion, rick

> error = SYSCTL_OUT(req, &n_nchash, sizeof(n_nchash));
> if (error)
> return (error);
> @@ -386,7 +386,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
> }
> SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD|
> CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I",
> - "nchash chain lengths");
> + "nchash statistics (number of total/used buckets, maximum chain
> length, usage percentage)");
> #endif
> 
> /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?788625604.124085.1330217939168.JavaMail.root>