perf kmem: Fix statistics typo
[pandora-kernel.git] / tools / perf / builtin-kmem.c
index e79ecbc..7ceb741 100644 (file)
@@ -20,8 +20,6 @@ typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
 
 static char const              *input_name = "perf.data";
 
-static u64                     sample_type;
-
 static int                     alloc_flag;
 static int                     caller_flag;
 
@@ -139,7 +137,7 @@ static void insert_alloc_stat(unsigned long call_site, unsigned long ptr,
        if (data && data->ptr == ptr) {
                data->hit++;
                data->bytes_req += bytes_req;
-               data->bytes_alloc += bytes_req;
+               data->bytes_alloc += bytes_alloc;
        } else {
                data = malloc(sizeof(*data));
                if (!data)
@@ -179,7 +177,7 @@ static void insert_caller_stat(unsigned long call_site,
        if (data && data->call_site == call_site) {
                data->hit++;
                data->bytes_req += bytes_req;
-               data->bytes_alloc += bytes_req;
+               data->bytes_alloc += bytes_alloc;
        } else {
                data = malloc(sizeof(*data));
                if (!data)
@@ -321,7 +319,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
        data.cpu = -1;
        data.period = 1;
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
        dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
@@ -344,11 +342,9 @@ static int process_sample_event(event_t *event, struct perf_session *session)
        return 0;
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_RAW)) {
+       if (!(session->sample_type & PERF_SAMPLE_RAW)) {
                fprintf(stderr,
                        "No trace sample to read. Did you call perf record "
                        "without -R?");
@@ -509,8 +505,7 @@ static void sort_result(void)
 static int __cmd_kmem(void)
 {
        int err;
-       struct perf_session *session = perf_session__new(input_name, O_RDONLY,
-                                                        0, NULL);
+       struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
        if (session == NULL)
                return -ENOMEM;
 
@@ -771,13 +766,13 @@ static int __cmd_record(int argc, const char **argv)
 
 int cmd_kmem(int argc, const char **argv, const char *prefix __used)
 {
-       symbol__init(0);
-
        argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
 
        if (!argc)
                usage_with_options(kmem_usage, kmem_options);
 
+       symbol__init();
+
        if (!strncmp(argv[0], "rec", 3)) {
                return __cmd_record(argc, argv);
        } else if (!strcmp(argv[0], "stat")) {