xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Julien Grall <julien.grall@citrix.com>,
	ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com
Subject: [RFC 04/10] xen/arm64: Add an assembly macro for perf counter
Date: Tue, 15 Dec 2015 17:52:02 +0000	[thread overview]
Message-ID: <1450201928-4928-5-git-send-email-julien.grall@citrix.com> (raw)
In-Reply-To: <1450201928-4928-1-git-send-email-julien.grall@citrix.com>

Allow assembly code to use performance counter.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
---
 xen/include/asm-arm/arm64/asm_defns.h | 36 +++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/xen/include/asm-arm/arm64/asm_defns.h b/xen/include/asm-arm/arm64/asm_defns.h
index 7085c26..36442b8 100644
--- a/xen/include/asm-arm/arm64/asm_defns.h
+++ b/xen/include/asm-arm/arm64/asm_defns.h
@@ -20,6 +20,42 @@ stp     \xreg1, \xreg2, [sp, #-16]!
 ldp     \xreg1, \xreg2, [sp], #16
 .endm
 
+#ifdef PERF_COUNTERS
+
+.macro perfc_incr, name, idx
+push    x0, x1                  /* x0 and x1 are used by the macro -> save them */
+
+/*
+ * Compute the address of the perf counters
+ *
+ * Note that each perf counters are 4 bytes and stored percpu.
+ */
+mov     x0, \idx                /* x0 <- index from ASM_PERFC_* */
+add     x0, x0, #\name          /* x0 <- index in the percpu array */
+lsl     x0, x0, 2               /* x0 <- offset from per_cpu__perfcounters. */
+ldr     x1, =per_cpu__perfcounters
+add     x0, x0, x1              /* x0 <- offset in the percpu area */
+mrs     x1, TPIDR_EL2           /* x1 <- per cpu offset */
+add     x0, x0, x1              /* x0 <- address of the perf counter for this cpu */
+
+/*
+ * Increment the perf counters.
+ *
+ * Note it's not atomic so does the C version.
+ */
+ldr     x1, [x0]                /* x1 <- current value of the counter */
+add     x1, x1, 1               /* x1 <- increment the counter */
+str     x1, [x0]                /* Store the counters incremented */
+
+pop     x0, x1                  /* Restore x0, x1 */
+.endm
+
+#define PERFC_INCR(_name, _idx) perfc_incr  ASM_PERFC_##_name, _idx
+
+#else
+#define PERFC_INCR(_name, _idx)
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 
-- 
2.1.4

  parent reply	other threads:[~2015-12-15 17:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 17:51 [RFC 00/10] xen/arm: Implement the hypercall handling in assembly Julien Grall
2015-12-15 17:51 ` [RFC 01/10] xen/arm: move lr, push and pop in a separate header Julien Grall
2015-12-15 17:52 ` [RFC 02/10] xen/arm: Drop unused defines in asm/bug.h Julien Grall
2015-12-15 17:52 ` [RFC 03/10] xen/arm: Implement assembly version of WARN/BUG/ASSERT_FAILED Julien Grall
2015-12-15 17:52 ` Julien Grall [this message]
2015-12-15 17:52 ` [RFC 05/10] xen/arm: gic_inject: Introduce a local variable to store current Julien Grall
2015-12-15 17:52 ` [RFC 06/10] xen/arm: gic: Allow the LRs to be cleared lazily Julien Grall
2015-12-15 17:52 ` [RFC 07/10] xen/arm: Implement the code to dispatch the hypercall in assembly Julien Grall
2015-12-15 17:52 ` [RFC 08/10] xen/arm64: Implement the hypercall handing fully " Julien Grall
2015-12-15 17:52 ` [RFC 09/10] xen/arm: Remove the C version of do_trap_hypercall Julien Grall
2015-12-15 17:52 ` [RFC 10/10] xen/arm: Factorize the C code to dispatch HVC Julien Grall
2015-12-15 18:33 ` [RFC 00/10] xen/arm: Implement the hypercall handling in assembly Andrew Cooper
2015-12-16 11:19   ` Ian Campbell

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=1450201928-4928-5-git-send-email-julien.grall@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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;
as well as URLs for NNTP newsgroup(s).