Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-block.git] / tools / perf / builtin-lock.c
index 1e93179c2d3020593059723d31599900d29c7420..821c1586a22b7da92cd732ad1a4ee4e05b037085 100644 (file)
@@ -397,6 +397,11 @@ enum broken_state {
 
 static int bad_hist[BROKEN_MAX];
 
+enum acquire_flags {
+       TRY_LOCK = 1,
+       READ_LOCK = 2,
+};
+
 static void
 report_lock_acquire_event(struct trace_acquire_event *acquire_event,
                        struct event *__event __used,
@@ -421,9 +426,9 @@ report_lock_acquire_event(struct trace_acquire_event *acquire_event,
                if (!acquire_event->flag) {
                        seq->state = SEQ_STATE_ACQUIRING;
                } else {
-                       if (acquire_event->flag & 1)
+                       if (acquire_event->flag & TRY_LOCK)
                                ls->nr_trylock++;
-                       if (acquire_event->flag & 2)
+                       if (acquire_event->flag & READ_LOCK)
                                ls->nr_readlock++;
                        seq->state = SEQ_STATE_READ_ACQUIRED;
                        seq->read_count = 1;
@@ -431,7 +436,7 @@ report_lock_acquire_event(struct trace_acquire_event *acquire_event,
                }
                break;
        case SEQ_STATE_READ_ACQUIRED:
-               if (acquire_event->flag & 2) {
+               if (acquire_event->flag & READ_LOCK) {
                        seq->read_count++;
                        ls->nr_acquired++;
                        goto end;
@@ -491,7 +496,7 @@ report_lock_acquired_event(struct trace_acquired_event *acquired_event,
                ls->wait_time_total += contended_term;
                if (contended_term < ls->wait_time_min)
                        ls->wait_time_min = contended_term;
-               else if (ls->wait_time_max < contended_term)
+               if (ls->wait_time_max < contended_term)
                        ls->wait_time_max = contended_term;
                break;
        case SEQ_STATE_RELEASED:
@@ -728,8 +733,8 @@ static void print_bad_events(int bad, int total)
                { "acquire", "acquired", "contended", "release" };
 
        pr_info("\n=== output for debug===\n\n");
-       pr_info("bad:%d, total:%d\n", bad, total);
-       pr_info("bad rate:%f\n", (double)(bad / total));
+       pr_info("bad: %d, total: %d\n", bad, total);
+       pr_info("bad rate: %f %%\n", (double)bad / (double)total * 100);
        pr_info("histogram of events caused bad sequence\n");
        for (i = 0; i < BROKEN_MAX; i++)
                pr_info(" %10s: %d\n", name[i], bad_hist[i]);
@@ -787,8 +792,7 @@ static void print_result(void)
        print_bad_events(bad, total);
 }
 
-static int                     info_threads;
-static int                     info_map;
+static bool info_threads, info_map;
 
 static void dump_threads(void)
 {
@@ -925,7 +929,6 @@ static const struct option lock_options[] = {
 
 static const char *record_args[] = {
        "record",
-       "-a",
        "-R",
        "-f",
        "-m", "1024",