Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jan 2011 16:36:39 +0100
From:      Martin Matuska <mm@FreeBSD.org>
To:        Artem Belevich <fbsdlist@src.cx>
Cc:        freebsd-fs <freebsd-fs@freebsd.org>
Subject:   Re: ZFS: clock_t overflow in l2arc_feed_thread
Message-ID:  <4D443407.7010604@FreeBSD.org>
In-Reply-To: <AANLkTikciV_XHvrurytr0-r11W4u=_p5bRi-xfX3S%2BQm@mail.gmail.com>
References:  <AANLkTikciV_XHvrurytr0-r11W4u=_p5bRi-xfX3S%2BQm@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D443407.7010604>