From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUN3z-0005aq-Oj for qemu-devel@nongnu.org; Tue, 25 Aug 2015 18:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUN3y-0000GC-SF for qemu-devel@nongnu.org; Tue, 25 Aug 2015 18:51:31 -0400 Date: Tue, 25 Aug 2015 18:51:08 -0400 (EDT) From: Paolo Bonzini Message-ID: <285075347.18984776.1440543068614.JavaMail.zimbra@redhat.com> In-Reply-To: <1440535491-4511-1-git-send-email-lvivier@redhat.com> References: <1440535491-4511-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 0/7] remove useless muldiv64() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: Peter Maydell , Jia Liu , "Michael S . Tsirkin" , qemu-trivial , Jason Wang , qemu-devel@nongnu.org, Stefan Hajnoczi , Leon Alrae , Aurelien Jarno > Originally, timers were ticks based, and it made sense to > add ticks to current time to know when to trigger an alarm. > > But since commit: > > 7447545 change all other clock references to use nanosecond resolution > accessors > > All timers use nanoseconds and we need to convert ticks to nanoseconds, by > doing something like: > > y = muldiv64(x, get_ticks_per_sec(), TIMER_FREQ) > > where x is the number of device ticks and y the number of system ticks. > > y is used as nanoseconds in timer functions, > it works because 1 tick is 1 nanosecond. > (get_ticks_per_sec() is 10^9) > > But if get_ticks_per_sec() / TIMER_FREQ is an integer, we can do: > > y = x * TIMER_PERIOD; Cc: qemu-trivial@nongnu.org Paolo