git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perf kmem: Fix statistics typo
[pandora-kernel.git]
/
tools
/
perf
/
builtin-kmem.c
diff --git
a/tools/perf/builtin-kmem.c
b/tools/perf/builtin-kmem.c
index
5f20951
..
7ceb741
100644
(file)
--- a/
tools/perf/builtin-kmem.c
+++ b/
tools/perf/builtin-kmem.c
@@
-6,12
+6,12
@@
#include "util/symbol.h"
#include "util/thread.h"
#include "util/header.h"
#include "util/symbol.h"
#include "util/thread.h"
#include "util/header.h"
+#include "util/session.h"
#include "util/parse-options.h"
#include "util/trace-event.h"
#include "util/debug.h"
#include "util/parse-options.h"
#include "util/trace-event.h"
#include "util/debug.h"
-#include "util/data_map.h"
#include <linux/rbtree.h>
#include <linux/rbtree.h>
@@
-20,9
+20,6
@@
typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
static char const *input_name = "perf.data";
static char const *input_name = "perf.data";
-static struct perf_header *header;
-static u64 sample_type;
-
static int alloc_flag;
static int caller_flag;
static int alloc_flag;
static int caller_flag;
@@
-140,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;
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)
} else {
data = malloc(sizeof(*data));
if (!data)
@@
-180,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;
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)
} else {
data = malloc(sizeof(*data));
if (!data)
@@
-312,7
+309,7
@@
process_raw_event(event_t *raw_event __used, void *data,
}
}
}
}
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event
, struct perf_session *session
)
{
struct sample_data data;
struct thread *thread;
{
struct sample_data data;
struct thread *thread;
@@
-322,7
+319,7
@@
static int process_sample_event(event_t *event)
data.cpu = -1;
data.period = 1;
data.cpu = -1;
data.period = 1;
- event__parse_sample(event, sample_type, &data);
+ event__parse_sample(event, s
ession->s
ample_type, &data);
dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
event->header.misc,
dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
event->header.misc,
@@
-330,7
+327,7
@@
static int process_sample_event(event_t *event)
(void *)(long)data.ip,
(long long)data.period);
(void *)(long)data.ip,
(long long)data.period);
- thread =
threads__findnew(
event->ip.pid);
+ thread =
perf_session__findnew(session,
event->ip.pid);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n",
event->header.type);
@@
-345,11
+342,9
@@
static int process_sample_event(event_t *event)
return 0;
}
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?");
fprintf(stderr,
"No trace sample to read. Did you call perf record "
"without -R?");
@@
-359,21
+354,12
@@
static int sample_type_check(u64 type)
return 0;
}
return 0;
}
-static struct perf_
file_handler file_handler
= {
+static struct perf_
event_ops event_ops
= {
.process_sample_event = process_sample_event,
.process_comm_event = event__process_comm,
.sample_type_check = sample_type_check,
};
.process_sample_event = process_sample_event,
.process_comm_event = event__process_comm,
.sample_type_check = sample_type_check,
};
-static int read_events(void)
-{
- register_idle_thread();
- register_perf_file_handler(&file_handler);
-
- return mmap_dispatch_perf_file(&header, input_name, 0, 0,
- &event__cwdlen, &event__cwd);
-}
-
static double fragmentation(unsigned long n_req, unsigned long n_alloc)
{
if (n_alloc == 0)
static double fragmentation(unsigned long n_req, unsigned long n_alloc)
{
if (n_alloc == 0)
@@
-382,7
+368,8
@@
static double fragmentation(unsigned long n_req, unsigned long n_alloc)
return 100.0 - (100.0 * n_req / n_alloc);
}
return 100.0 - (100.0 * n_req / n_alloc);
}
-static void __print_result(struct rb_root *root, int n_lines, int is_caller)
+static void __print_result(struct rb_root *root, struct perf_session *session,
+ int n_lines, int is_caller)
{
struct rb_node *next;
{
struct rb_node *next;
@@
-403,7
+390,7
@@
static void __print_result(struct rb_root *root, int n_lines, int is_caller)
if (is_caller) {
addr = data->call_site;
if (!raw_ip)
if (is_caller) {
addr = data->call_site;
if (!raw_ip)
- sym =
thread__find_function(kthread
, addr, NULL);
+ sym =
map_groups__find_function(&session->kmaps, session
, addr, NULL);
} else
addr = data->ptr;
} else
addr = data->ptr;
@@
-444,12
+431,12
@@
static void print_summary(void)
printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
}
printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
}
-static void print_result(
void
)
+static void print_result(
struct perf_session *session
)
{
if (caller_flag)
{
if (caller_flag)
- __print_result(&root_caller_sorted, caller_lines, 1);
+ __print_result(&root_caller_sorted,
session,
caller_lines, 1);
if (alloc_flag)
if (alloc_flag)
- __print_result(&root_alloc_sorted, alloc_lines, 0);
+ __print_result(&root_alloc_sorted,
session,
alloc_lines, 0);
print_summary();
}
print_summary();
}
@@
-517,12
+504,20
@@
static void sort_result(void)
static int __cmd_kmem(void)
{
static int __cmd_kmem(void)
{
+ int err;
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
+ if (session == NULL)
+ return -ENOMEM;
+
setup_pager();
setup_pager();
- read_events();
+ err = perf_session__process_events(session, &event_ops);
+ if (err != 0)
+ goto out_delete;
sort_result();
sort_result();
- print_result();
-
- return 0;
+ print_result(session);
+out_delete:
+ perf_session__delete(session);
+ return err;
}
static const char * const kmem_usage[] = {
}
static const char * const kmem_usage[] = {
@@
-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)
{
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);
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")) {
if (!strncmp(argv[0], "rec", 3)) {
return __cmd_record(argc, argv);
} else if (!strcmp(argv[0], "stat")) {