From: tuliom@linux.vnet.ibm.com (Tulio Magno Quites Machado Filho)
Subject: [ltt-dev] [URCU PATCH] Optimize caa_get_cycles() for PowerPC64
Date: Thu, 8 Sep 2011 13:02:32 -0300 [thread overview]
Message-ID: <1315497752-4742-1-git-send-email-tuliom@linux.vnet.ibm.com> (raw)
Make caa_get_cycles() read from the Time Base register with only 1 instruction.
Signed-off-by: Tulio Magno Quites Machado Filho <tuliom at linux.vnet.ibm.com>
---
urcu/arch/ppc.h | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h
index d7317bb..2b606d0 100644
--- a/urcu/arch/ppc.h
+++ b/urcu/arch/ppc.h
@@ -48,10 +48,20 @@ extern "C" {
rval; \
})
+#define mftb() \
+ ({ \
+ unsigned long long rval; \
+ asm volatile("mftb %0" : "=r" (rval)); \
+ rval; \
+ })
+
typedef unsigned long long cycles_t;
static inline cycles_t caa_get_cycles (void)
{
+#ifdef __powerpc64__
+ return (cycles_t) mftb();
+#else
long h, l;
for (;;) {
@@ -62,6 +72,7 @@ static inline cycles_t caa_get_cycles (void)
if (mftbu() == h)
return (((cycles_t) h) << 32) + l;
}
+#endif
}
#ifdef __cplusplus
--
1.7.4.4
next reply other threads:[~2011-09-08 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-08 16:02 Tulio Magno Quites Machado Filho [this message]
2011-09-09 5:34 ` Mathieu Desnoyers
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=1315497752-4742-1-git-send-email-tuliom@linux.vnet.ibm.com \
--to=tuliom@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox