From owner-freebsd-fs@FreeBSD.ORG Sat Jan 29 15:36:44 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 A1B08106566B for ; Sat, 29 Jan 2011 15:36:44 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from mail.vx.sk (mail.vx.sk [IPv6:2a01:4f8:100:1043::3]) by mx1.freebsd.org (Postfix) with ESMTP id 35F128FC17 for ; Sat, 29 Jan 2011 15:36:44 +0000 (UTC) Received: from core.vx.sk (localhost [127.0.0.1]) by mail.vx.sk (Postfix) with ESMTP id 6084F13838D; Sat, 29 Jan 2011 16:36:43 +0100 (CET) X-Virus-Scanned: amavisd-new at mail.vx.sk Received: from mail.vx.sk ([127.0.0.1]) by core.vx.sk (mail.vx.sk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id AtCQ43WVSDiK; Sat, 29 Jan 2011 16:36:41 +0100 (CET) Received: from [192.168.1.43] (bband-dyn5.178-40-80.t-com.sk [178.40.80.5]) by mail.vx.sk (Postfix) with ESMTPSA id C9C8A13837B; Sat, 29 Jan 2011 16:36:40 +0100 (CET) Message-ID: <4D443407.7010604@FreeBSD.org> Date: Sat, 29 Jan 2011 16:36:39 +0100 From: Martin Matuska User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Artem Belevich References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------010203040206090602080803" Cc: freebsd-fs Subject: Re: ZFS: clock_t overflow in l2arc_feed_thread 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: Sat, 29 Jan 2011 15:36:44 -0000 This is a multi-part message in MIME format. --------------010203040206090602080803 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I agree to you that we have different types and this may be an issue but I disagree to your patch. clock_t is not signed (int64_t) and this can be done in a much easier (and cleaner way) without touching the code, see attached patch. Dňa 29.01.2011 11:30, Artem Belevich wrote / napísal(a) > Hi, > > I'm using ZFS v15 on RELENG_8/amd64 box. Some time back I've noticed > that after a while ZFS starts to consume 100% of CPU time on one of > the cores. After a bit of digging it appears that the problem is due > to an integer overflow. > > On amd64 (as wel as most other FreeBSD platforms) clock_t is a signed > 32-bit integer. On OpenSolaris clock_t is long. > > In compat/opensolaris/sys/time.h LBOLT is defined as > #define LBOLT ((gethrtime() * hz) / NANOSEC) > > With HZ=1000 LBOLT overflows clock_t variables when uptime reaches > ~24days. This affects l2arc_write_interval() which calculates the time > when L2ARC feed thread should be woken up. The end result is that for > the next 24 days l2arc_feed_thread no longer sleeps as long as it > should have. > > Changing clock_t to a larger type globally looks somewhat risky to me. > It's probably easier to change those few places in ZFS code that use > clock_t to uint64_t instead. > > In case someone is interested, I've posted my patch here: > http://pastebin.com/Q2T3x2AB > > --Artem > _______________________________________________ > freebsd-fs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org" --------------010203040206090602080803 Content-Type: text/x-patch; name="opensolaris_types.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="opensolaris_types.patch" --- sys/cddl/compat/opensolaris/sys/types.h.orig 2011-01-29 16:25:48.857709276 +0100 +++ sys/cddl/compat/opensolaris/sys/types.h 2011-01-29 16:26:03.219594069 +0100 @@ -29,6 +29,9 @@ #ifndef _OPENSOLARIS_SYS_TYPES_H_ #define _OPENSOLARIS_SYS_TYPES_H_ +typedef long clock_t; +#define _CLOCK_T_DECLARED + /* * This is a bag of dirty hacks to keep things compiling. */ --------------010203040206090602080803--