diff options
author | stephane eranian <eranian@hpl.hp.com> | 2005-04-18 14:42:00 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2005-05-03 18:47:58 -0400 |
commit | a5a70b75d93b26e14c0c5e759099d602a480b9e2 (patch) | |
tree | 4cd2f4f47cccb8f59e54433ab642e187cbf5e291 /arch/ia64/kernel | |
parent | 8df5a500a3e97f7811cdce0f553ca1917ccd4220 (diff) |
[IA64] another perfmon fix (take2)
- pfm_context_load(): change return value from EINVAL to EBUSY
when context is already loaded.
- pfm_check_task_state(): pass test if context state is MASKED.
It is safe to give access on PFM_CTX_MASKED because the PMU
state (PMD) is stable and saved in software state.
This helps multiplexing programs such as the example given
in libpfm-3.1.
Signed-off-by: stephane eranian <eranian@hpl.hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64/kernel')
-rw-r--r-- | arch/ia64/kernel/perfmon.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index fd4f3be6e856..71c101601e3e 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -4215,7 +4215,7 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) | |||
4215 | DPRINT(("cannot load to [%d], invalid ctx_state=%d\n", | 4215 | DPRINT(("cannot load to [%d], invalid ctx_state=%d\n", |
4216 | req->load_pid, | 4216 | req->load_pid, |
4217 | ctx->ctx_state)); | 4217 | ctx->ctx_state)); |
4218 | return -EINVAL; | 4218 | return -EBUSY; |
4219 | } | 4219 | } |
4220 | 4220 | ||
4221 | DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg)); | 4221 | DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg)); |
@@ -4717,16 +4717,26 @@ recheck: | |||
4717 | if (task == current || ctx->ctx_fl_system) return 0; | 4717 | if (task == current || ctx->ctx_fl_system) return 0; |
4718 | 4718 | ||
4719 | /* | 4719 | /* |
4720 | * if context is UNLOADED we are safe to go | 4720 | * we are monitoring another thread |
4721 | */ | ||
4722 | if (state == PFM_CTX_UNLOADED) return 0; | ||
4723 | |||
4724 | /* | ||
4725 | * no command can operate on a zombie context | ||
4726 | */ | 4721 | */ |
4727 | if (state == PFM_CTX_ZOMBIE) { | 4722 | switch(state) { |
4728 | DPRINT(("cmd %d state zombie cannot operate on context\n", cmd)); | 4723 | case PFM_CTX_UNLOADED: |
4729 | return -EINVAL; | 4724 | /* |
4725 | * if context is UNLOADED we are safe to go | ||
4726 | */ | ||
4727 | return 0; | ||
4728 | case PFM_CTX_ZOMBIE: | ||
4729 | /* | ||
4730 | * no command can operate on a zombie context | ||
4731 | */ | ||
4732 | DPRINT(("cmd %d state zombie cannot operate on context\n", cmd)); | ||
4733 | return -EINVAL; | ||
4734 | case PFM_CTX_MASKED: | ||
4735 | /* | ||
4736 | * PMU state has been saved to software even though | ||
4737 | * the thread may still be running. | ||
4738 | */ | ||
4739 | if (cmd != PFM_UNLOAD_CONTEXT) return 0; | ||
4730 | } | 4740 | } |
4731 | 4741 | ||
4732 | /* | 4742 | /* |