From owner-freebsd-fs@FreeBSD.ORG Tue May 31 16:56:54 2011 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FDC6106564A; Tue, 31 May 2011 16:56:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 499F58FC0C; Tue, 31 May 2011 16:56:52 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA15032; Tue, 31 May 2011 19:56:51 +0300 (EEST) (envelope-from avg@FreeBSD.org) Message-ID: <4DE51DD3.6040602@FreeBSD.org> Date: Tue, 31 May 2011 19:56:51 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110504 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Artem Belevich References: <0EFD28CD-F2E9-4AE2-B927-1D327EC99DB9@bitgravity.com> <4DE50811.5060606@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-fs@FreeBSD.org Subject: Re: ZFS: arc_reclaim_thread running 100%, 8.1-RELEASE, LBOLT related X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2011 16:56:54 -0000 on 31/05/2011 19:48 Artem Belevich said the following: > On Tue, May 31, 2011 at 8:24 AM, Andriy Gapon wrote: >>>> 65 nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec; >>> >>> Yup. This would indeed overflow in ~106.75 days. >> >> Have you referred to the LBOLT above? >> gethrtime() should have several hundred years before overflowing. > > hrtime_t is 64-bit. NANOSEC=1000000000. > > When it's time to use LBOLT, we further multiply number of seconds by HZ: >>> 41 #define LBOLT ((gethrtime() * hz) / NANOSEC) > > In the end we want 64-bit scalar to hold number of seconds times 10e12. > 0x7fffffffffffffff/1000000000000 = 9223372 # number of seconds before > signed overflow > 9223372/(24*60*60) --> 106 # .. or about 106 days Basically you used that many words to say "yes, I meant overflow in LBOLT"? :-) Because gethrtime alone would overflow in about 1000 * 100 days (~300 years). >> To summarize: >> 1. We must fix ddi_get_lbolt*() to avoid unnecessary overflow in multiplication > > Agreed. Okey. >> 2. We could fix 31-bit clock_t overflow by using Solaris-compatible definition of >> it (long), but that still won't help on i386. Maybe we should bring up this issue >> to the attention of upstream ZFS developers. Universally using ddi_get_lbolt64() >> seems like a safer bet. > > FYI, we've already changed clock_t for opensolaris code to int64_t in > r218169 regardless of $MACHINE. I think that's a good solution. I hope that we don't have any place where osol clock_t would somehow mix with fbsd clock_t with detrimental effects. -- Andriy Gapon