From: Mike Kravetz <kravetz@us.ibm.com>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [RFC] asm code for Hypervisor Call Instrumentation
Date: Fri, 11 Aug 2006 11:30:30 -0700 [thread overview]
Message-ID: <20060811183029.GA4535@monkey.ibm.com> (raw)
In-Reply-To: <17622.56592.41532.206800@cargo.ozlabs.ibm.com>
On Mon, Aug 07, 2006 at 04:26:24PM +1000, Paul Mackerras wrote:
> Hmmm, doing the update in assembly would avoid the need to create a
> stack frame, which would be nice... Maybe we need to add some macros
> to include/asm-powerpc/percpu.h to make it easier to access per-cpu
> variables from assembly code.
>
> Alternatively, we could put a pointer to the hcall_stats array for
> each cpu in its paca. That's very easily accessed from assembly code.
I finally got around to doing the update in assembly. I have attached
the code in question below. Macros were added (elsewhere) for things like
stat structure and offsets within the structure. No macros for per-cpu
data. Rather, I just used some existing definitions and based code on
descriptions in asm-powerpc/percpu.h. Let me know if this introduces too
many (unchecked at compile time assumptions) into the code.
The many comments are mostly for my benefit. :)
Thanks,
--
Mike
#define STK_PARM(i) (48 + ((i)-3)*8)
#ifdef CONFIG_HCALL_STATS
/*
* precall must preserve all registers. use unused STK_PARM()
* areas to save snapshots and opcode.
*/
#define HCALL_INST_PRECALL \
std r3,STK_PARM(r3)(r1); /* save opcode */ \
mftb r3; /* get timebase and */ \
std r3,STK_PARM(r5)(r1); /* save for later */ \
BEGIN_FTR_SECTION; \
mfspr r3,SPRN_PURR; /* get PURR and */ \
END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
std r3,STK_PARM(r6)(r1); /* save for later */ \
ld r3,STK_PARM(r3)(r1); /* opcode back in r3 */
/*
* postcall is performed immediately before function return which
* allows liberal use of non-volital registers.
*/
#define HCALL_INST_POSTCALL \
/* get time and PURR snapshots after hcall */ \
mftb r7; /* timebase after */ \
BEGIN_FTR_SECTION; \
mfspr r8,SPRN_PURR; /* PURR after */ \
END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
\
/* calculate time and PURR deltas for call */ \
ld r5,STK_PARM(r5)(r1); /* timebase before */ \
subf r5,r5,r7; \
ld r6,STK_PARM(r6)(r1); /* PURR before */ \
subf r6,r6,r8; \
\
/* calculate address of stat structure */ \
ld r4,STK_PARM(r3)(r1); /* use opcode as */ \
rldicl r4,r4,62,2; /* index into array */ \
mulli r4,r4,HCALL_STAT_SIZE; \
LOAD_REG_ADDR(r7, per_cpu__hcall_stats); \
add r4,r4,r7; \
ld r7,PACA_DATA_OFFSET(r13); /* per cpu offset */ \
add r4,r4,r7; \
\
/* update stats */ \
ld r7,HCALL_STAT_CALLS(r4); /* count */ \
addi r7,r7,1; \
std r7,HCALL_STAT_CALLS(r4); \
ld r7,HCALL_STAT_TB(r4); /* timebase */ \
add r7,r7,r5; \
std r7,HCALL_STAT_TB(r4); \
ld r7,HCALL_STAT_PURR(r4); /* PURR */ \
add r7,r7,r6; \
std r7,HCALL_STAT_PURR(r4);
#else
#define HCALL_INST_PRECALL
#define HCALL_INST_POSTCALL
#endif
prev parent reply other threads:[~2006-08-11 18:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-02 17:59 [RFC] asm code for Hypervisor Call Instrumentation Mike Kravetz
2006-08-03 3:57 ` Stephen Rothwell
2006-08-03 4:05 ` Mike Kravetz
2006-08-03 17:40 ` Mike Kravetz
2006-08-03 23:25 ` Stephen Rothwell
2006-08-04 0:08 ` Mike Kravetz
2006-08-07 6:26 ` Paul Mackerras
2006-08-11 18:30 ` Mike Kravetz [this message]
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=20060811183029.GA4535@monkey.ibm.com \
--to=kravetz@us.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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).