The pfm_create_evtsets() system call allows modifying an existing event set
as well as creating a new one. So allow the create_eventset command to take
an existing event-set ID. Only allocate a new one if the specified ID is
not found.
Signed-off-by: Kevin Corry <[EMAIL PROTECTED]>
--- libpfm-a/examples/pfmsetup.c 24 Apr 2007 04:46:33 -0000
+++ libpfm-b/examples/pfmsetup.c 26 Apr 2007 19:27:12 -0000
@@ -1307,6 +1307,7 @@
int switch_on_timeout = FALSE;
int explicit_next_set = FALSE;
int exclude_idle = FALSE;
+ int new_set = FALSE;
int system_wide,c, rc;
struct option long_opts[] = {
{"next-set", required_argument, NULL, 1},
@@ -1373,17 +1374,15 @@
}
evt = find_event_set(ctx, event_set_id);
- if (evt) {
- LOG_ERROR("Event-set with ID %d already exists in context %d.",
- event_set_id, ctx_id);
- return EINVAL;
- }
-
- evt = calloc(1, sizeof(*evt));
if (!evt) {
- LOG_ERROR("Can't allocate structure for new event-set %d in "
- "context %d.", event_set_id, ctx_id);
- return ENOMEM;
+ evt = calloc(1, sizeof(*evt));
+ if (!evt) {
+ LOG_ERROR("Can't allocate structure for new event-set "
+ "%d in context %d.", event_set_id, ctx_id);
+ return ENOMEM;
+ }
+ evt->id = event_set_id;
+ new_set = TRUE;
}
set_arg.set_id = event_set_id;
@@ -1415,10 +1414,12 @@
revert_affinity(&old_cpu_set);
}
- evt->id = event_set_id;
- insert_event_set(ctx, evt);
+ if (new_set) {
+ insert_event_set(ctx, evt);
+ }
- LOG_INFO("Created event-set %d in context %d.", event_set_id, ctx_id);
+ LOG_INFO("%s event-set %d in context %d.",
+ new_set ? "Created" : "Modified", event_set_id, ctx_id);
return 0;
}
_______________________________________________
perfmon mailing list
[email protected]
http://www.hpl.hp.com/hosted/linux/mail-archives/perfmon/