diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-05-07 01:09:00 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-07 15:46:35 -0400 |
commit | 60bbddaaa33865633efa2800702e3b02495a0e94 (patch) | |
tree | 52c177c76c7c22a96e77c61d374e1ee52105e8a2 /tools | |
parent | 55261f46702cec96911a81aacfb3cba13434d304 (diff) |
perf target: Introduce perf_target_errno
The perf_target_errno enumerations are used to indicate specific error
cases on perf target operations. It'd help libperf being a more generic
library.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Reviewed-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1336367344-28071-4-git-send-email-namhyung.kim@lge.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/target.c | 33 | ||||
-rw-r--r-- | tools/perf/util/target.h | 25 |
2 files changed, 46 insertions, 12 deletions
diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c index 3fadf85dd7e3..5c59dcfc8f8d 100644 --- a/tools/perf/util/target.c +++ b/tools/perf/util/target.c | |||
@@ -10,36 +10,47 @@ | |||
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | 11 | ||
12 | 12 | ||
13 | void perf_target__validate(struct perf_target *target) | 13 | enum perf_target_errno perf_target__validate(struct perf_target *target) |
14 | { | 14 | { |
15 | enum perf_target_errno ret = PERF_ERRNO_TARGET__SUCCESS; | ||
16 | |||
15 | if (target->pid) | 17 | if (target->pid) |
16 | target->tid = target->pid; | 18 | target->tid = target->pid; |
17 | 19 | ||
18 | /* CPU and PID are mutually exclusive */ | 20 | /* CPU and PID are mutually exclusive */ |
19 | if (target->tid && target->cpu_list) { | 21 | if (target->tid && target->cpu_list) { |
20 | ui__warning("WARNING: PID switch overriding CPU\n"); | ||
21 | sleep(1); | ||
22 | target->cpu_list = NULL; | 22 | target->cpu_list = NULL; |
23 | if (ret == PERF_ERRNO_TARGET__SUCCESS) | ||
24 | ret = PERF_ERRNO_TARGET__PID_OVERRIDE_CPU; | ||
23 | } | 25 | } |
24 | 26 | ||
25 | /* UID and PID are mutually exclusive */ | 27 | /* UID and PID are mutually exclusive */ |
26 | if (target->tid && target->uid_str) { | 28 | if (target->tid && target->uid_str) { |
27 | ui__warning("PID/TID switch overriding UID\n"); | ||
28 | sleep(1); | ||
29 | target->uid_str = NULL; | 29 | target->uid_str = NULL; |
30 | if (ret == PERF_ERRNO_TARGET__SUCCESS) | ||
31 | ret = PERF_ERRNO_TARGET__PID_OVERRIDE_UID; | ||
30 | } | 32 | } |
31 | 33 | ||
32 | /* UID and CPU are mutually exclusive */ | 34 | /* UID and CPU are mutually exclusive */ |
33 | if (target->uid_str && target->cpu_list) { | 35 | if (target->uid_str && target->cpu_list) { |
34 | ui__warning("UID switch overriding CPU\n"); | ||
35 | sleep(1); | ||
36 | target->cpu_list = NULL; | 36 | target->cpu_list = NULL; |
37 | if (ret == PERF_ERRNO_TARGET__SUCCESS) | ||
38 | ret = PERF_ERRNO_TARGET__UID_OVERRIDE_CPU; | ||
37 | } | 39 | } |
38 | 40 | ||
39 | /* PID/UID and SYSTEM are mutually exclusive */ | 41 | /* PID and SYSTEM are mutually exclusive */ |
40 | if ((target->tid || target->uid_str) && target->system_wide) { | 42 | if (target->tid && target->system_wide) { |
41 | ui__warning("PID/TID/UID switch overriding CPU\n"); | ||
42 | sleep(1); | ||
43 | target->system_wide = false; | 43 | target->system_wide = false; |
44 | if (ret == PERF_ERRNO_TARGET__SUCCESS) | ||
45 | ret = PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM; | ||
44 | } | 46 | } |
47 | |||
48 | /* UID and SYSTEM are mutually exclusive */ | ||
49 | if (target->uid_str && target->system_wide) { | ||
50 | target->system_wide = false; | ||
51 | if (ret == PERF_ERRNO_TARGET__SUCCESS) | ||
52 | ret = PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM; | ||
53 | } | ||
54 | |||
55 | return ret; | ||
45 | } | 56 | } |
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h index 218291f921ed..eb0d2101154a 100644 --- a/tools/perf/util/target.h +++ b/tools/perf/util/target.h | |||
@@ -13,6 +13,29 @@ struct perf_target { | |||
13 | bool system_wide; | 13 | bool system_wide; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | void perf_target__validate(struct perf_target *target); | 16 | enum perf_target_errno { |
17 | PERF_ERRNO_TARGET__SUCCESS = 0, | ||
18 | |||
19 | /* | ||
20 | * Choose an arbitrary negative big number not to clash with standard | ||
21 | * errno since SUS requires the errno has distinct positive values. | ||
22 | * See 'Issue 6' in the link below. | ||
23 | * | ||
24 | * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html | ||
25 | */ | ||
26 | __PERF_ERRNO_TARGET__START = -10000, | ||
27 | |||
28 | |||
29 | /* for perf_target__validate() */ | ||
30 | PERF_ERRNO_TARGET__PID_OVERRIDE_CPU = __PERF_ERRNO_TARGET__START, | ||
31 | PERF_ERRNO_TARGET__PID_OVERRIDE_UID, | ||
32 | PERF_ERRNO_TARGET__UID_OVERRIDE_CPU, | ||
33 | PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM, | ||
34 | PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM, | ||
35 | |||
36 | __PERF_ERRNO_TARGET__END, | ||
37 | }; | ||
38 | |||
39 | enum perf_target_errno perf_target__validate(struct perf_target *target); | ||
17 | 40 | ||
18 | #endif /* _PERF_TARGET_H */ | 41 | #endif /* _PERF_TARGET_H */ |