From owner-svn-src-head@FreeBSD.ORG Sat Jun 4 10:23:08 2011 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 C47E0106566C; Sat, 4 Jun 2011 10:23:08 +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 5B4858FC08; Sat, 4 Jun 2011 10:23:08 +0000 (UTC) Received: from core.vx.sk (localhost [127.0.0.1]) by mail.vx.sk (Postfix) with ESMTP id 83879177F61; Sat, 4 Jun 2011 12:23:07 +0200 (CEST) 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 BoRSDHy8mEWt; Sat, 4 Jun 2011 12:23:01 +0200 (CEST) Received: from [10.9.8.1] (chello085216231078.chello.sk [85.216.231.78]) by mail.vx.sk (Postfix) with ESMTPSA id 88178177F47; Sat, 4 Jun 2011 12:23:01 +0200 (CEST) Message-ID: <4DEA0785.3040707@FreeBSD.org> Date: Sat, 04 Jun 2011 12:23:01 +0200 From: Martin Matuska User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; sk; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: Andriy Gapon References: <201106040702.p54726O6098336@svn.freebsd.org> In-Reply-To: <201106040702.p54726O6098336@svn.freebsd.org> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek Subject: Re: svn commit: r222670 - in head/sys/cddl/compat/opensolaris: kern sys 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: Sat, 04 Jun 2011 10:23:09 -0000 If we are "fixing" this, what about following pjd's rules and moving in direction vendor code (reducing diff)? Or is it too expensive? If that way: a) the nsec_per_tick is defined in vendor code "usr/src/uts/common/conf/param.c". Maybe we should define it at least in sys/cddl/compat/opensolaris/sys/param.h and not in time.h b) sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c might contain the functions as in vendor code (uts/common/os/sunddi.c): clock_t ddi_get_lbolt(void) { return ((clock_t)lbolt_hybrid()); } int64_t ddi_get_lbolt64(void) { return (lbolt_hybrid()); } c) sys/cddl/compat/opensolaris/sys/time.h: extern clock_t ddi_get_lbolt(void); extern int64_t ddi_get_lbolt64(void); d) we might want a new file called sys/cddl/compat/opensolaris/kern/opensolaris_clock.c (uts/common/os/clock.c): int64_t lbolt_hybrid(void) { return (gethrtime() / nsec_per_tick); } The d) step with lbolt_hybrid might be omitted and the function result integrated directly into opensolaris_sunddi.c. Bud regardless of that, notice the clock_t cast in ddi_get_lbolt(). mm Dňa 04.06.2011 09:02, Andriy Gapon wrote / napísal(a): > Author: avg > Date: Sat Jun 4 07:02:06 2011 > New Revision: 222670 > URL: http://svn.freebsd.org/changeset/base/222670 > > Log: > opensolaris compat / zfs: avoid early overflow in ddi_get_lbolt* > > Reported by: David P. Discher > Tested by: will > Reviewed by: art > Discussed with: dwhite > MFC after: 2 weeks > > Modified: > head/sys/cddl/compat/opensolaris/kern/opensolaris.c > head/sys/cddl/compat/opensolaris/sys/time.h > > Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris.c > ============================================================================== > --- head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 04:35:12 2011 (r222669) > +++ head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 07:02:06 2011 (r222670) > @@ -40,6 +40,7 @@ > cpu_core_t cpu_core[MAXCPU]; > kmutex_t cpu_lock; > solaris_cpu_t solaris_cpu[MAXCPU]; > +int nsec_per_tick; > > /* > * OpenSolaris subsystem initialisation. > @@ -60,6 +61,8 @@ opensolaris_load(void *dummy) > } > > mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL); > + > + nsec_per_tick = NANOSEC / hz; > } > > SYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_load, NULL); > > Modified: head/sys/cddl/compat/opensolaris/sys/time.h > ============================================================================== > --- head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 04:35:12 2011 (r222669) > +++ head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 07:02:06 2011 (r222670) > @@ -62,8 +62,21 @@ gethrtime(void) { > #define gethrestime(ts) getnanotime(ts) > #define gethrtime_waitfree() gethrtime() > > -#define ddi_get_lbolt() ((gethrtime() * hz) / NANOSEC) > -#define ddi_get_lbolt64() (int64_t)((gethrtime() * hz) / NANOSEC) > +extern int nsec_per_tick; /* nanoseconds per clock tick */ > + > +static __inline int64_t > +ddi_get_lbolt64(void) > +{ > + > + return (gethrtime() / nsec_per_tick); > +} > + > +static __inline clock_t > +ddi_get_lbolt(void) > +{ > + > + return (ddi_get_lbolt64()); > +} > > #else >