All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: george.dunlap@eu.citrix.com
Subject: [PATCH 5 of 8] xenalyze: Rework math to remove two 64-bit divisions
Date: Thu, 26 Jan 2012 17:21:02 +0000	[thread overview]
Message-ID: <4b3639bd32550d40bfc4.1327598462@elijah> (raw)
In-Reply-To: <patchbomb.1327598457@elijah>

abs_cycles_to_time is called on every record for dump mode; it has
four 64-bit divisions (well, 3 divisions and 1 mod), which map to
library functions on a 32-bit platform.  A simple rework of the math
can eliminate two of those.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>

diff -r 0663e3e8f69d -r 4b3639bd3255 xenalyze.c
--- a/xenalyze.c	Thu Jan 26 17:16:59 2012 +0000
+++ b/xenalyze.c	Thu Jan 26 17:17:19 2012 +0000
@@ -1976,16 +1976,19 @@ void cpumask_union(cpu_mask_t *d, const 
 /* -- Time code -- */
 
 void cycles_to_time(unsigned long long c, struct time_struct *t) {
-    t->time = ((c) * 1000) / (opt.cpu_hz / 1000000 );    
-    t->s = t->time / 1000000000;                        
-    t->ns = t->time % 1000000000;                       
+    t->time = ((c - P.f.first_tsc) * 1000 * 1000000) / opt.cpu_hz;
+    t->s = t->time / 1000000000;
+    t->ns = t->time - (t->s * 1000000000);
 }
 
 void abs_cycles_to_time(unsigned long long ac, struct time_struct *t) {
     if(ac > P.f.first_tsc) {
-        t->time = ((ac - P.f.first_tsc) * 1000) / (opt.cpu_hz / 1000000 );    
-        t->s = t->time / 1000000000;                        
-        t->ns = t->time % 1000000000;
+        /* t->time = ((ac - P.f.first_tsc) * 1000) / (opt.cpu_hz / 1000000 );     */
+        /* t->s = t->time / 1000000000;                         */
+        /* t->ns = t->time % 1000000000; */
+        t->time = ((ac - P.f.first_tsc) * 1000 * 1000000) / opt.cpu_hz;
+        t->s = t->time / 1000000000;
+        t->ns = t->time - (t->s * 1000000000);
     } else {
         t->time = t->s = t->ns = 0;
     }

  parent reply	other threads:[~2012-01-26 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 17:20 [PATCH 0 of 8] xenalyze: Optimizations George Dunlap
2012-01-26 17:20 ` [PATCH 1 of 8] xenalyze: Improve record-sorting algorithm George Dunlap
2012-01-26 17:20 ` [PATCH 2 of 8] xenalyze: Remove spurious dump_header construction George Dunlap
2012-01-26 17:21 ` [PATCH 3 of 8] xenalyze: Remove --dump-cooked George Dunlap
2012-01-26 17:21 ` [PATCH 4 of 8] xenalyze: Enable -O2 optimization level George Dunlap
2012-01-26 17:21 ` George Dunlap [this message]
2012-01-26 17:21 ` [PATCH 6 of 8] xenalyze: Eliminate unnecessary cycles_to_time calculation George Dunlap
2012-01-26 17:21 ` [PATCH 7 of 8] xenalyze: Introduce more efficient read mechanism George Dunlap
2012-01-26 17:21 ` [PATCH 8 of 8] xenalyze: Get rid of redundant hvm dump_header George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b3639bd32550d40bfc4.1327598462@elijah \
    --to=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.