]> err.no Git - linux-2.6/commitdiff
[IA64] another perfmon fix (take2)
authorstephane eranian <eranian@hpl.hp.com>
Mon, 18 Apr 2005 18:42:00 +0000 (11:42 -0700)
committerTony Luck <tony.luck@intel.com>
Tue, 3 May 2005 22:47:58 +0000 (15:47 -0700)
- 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>
arch/ia64/kernel/perfmon.c

index fd4f3be6e8563c323a5fb8fc8b5ecfdfb30fa560..71c101601e3ef060a33d416904c57021d1501c01 100644 (file)
@@ -4215,7 +4215,7 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
                DPRINT(("cannot load to [%d], invalid ctx_state=%d\n",
                        req->load_pid,
                        ctx->ctx_state));
-               return -EINVAL;
+               return -EBUSY;
        }
 
        DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg));
@@ -4717,16 +4717,26 @@ recheck:
        if (task == current || ctx->ctx_fl_system) return 0;
 
        /*
-        * if context is UNLOADED we are safe to go
-        */
-       if (state == PFM_CTX_UNLOADED) return 0;
-
-       /*
-        * no command can operate on a zombie context
+        * we are monitoring another thread
         */
-       if (state == PFM_CTX_ZOMBIE) {
-               DPRINT(("cmd %d state zombie cannot operate on context\n", cmd));
-               return -EINVAL;
+       switch(state) {
+               case PFM_CTX_UNLOADED:
+                       /*
+                        * if context is UNLOADED we are safe to go
+                        */
+                       return 0;
+               case PFM_CTX_ZOMBIE:
+                       /*
+                        * no command can operate on a zombie context
+                        */
+                       DPRINT(("cmd %d state zombie cannot operate on context\n", cmd));
+                       return -EINVAL;
+               case PFM_CTX_MASKED:
+                       /*
+                        * PMU state has been saved to software even though
+                        * the thread may still be running.
+                        */
+                       if (cmd != PFM_UNLOAD_CONTEXT) return 0;
        }
 
        /*