Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169735
b: refs/heads/master
c: f3ced7c
h: refs/heads/master
i:
  169733: 0cd852a
  169731: dfa8d20
  169727: bee6342
v: v3
  • Loading branch information
Pekka Enberg authored and Ingo Molnar committed Nov 22, 2009
1 parent fc84ae5 commit 38e16d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 96b02d78a7e47cd189f6b307c5513fec6b2155dc
refs/heads/master: f3ced7cdb24e7968a353d828955fa2daf4167e72
29 changes: 28 additions & 1 deletion trunk/tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ static int callsite_cmp(struct alloc_stat *l, struct alloc_stat *r)
return 0;
}

static int hit_cmp(struct alloc_stat *l, struct alloc_stat *r)
{
if (l->hit < r->hit)
return -1;
else if (l->hit > r->hit)
return 1;
return 0;
}

static int bytes_cmp(struct alloc_stat *l, struct alloc_stat *r)
{
if (l->bytes_alloc < r->bytes_alloc)
Expand All @@ -452,6 +461,20 @@ static int bytes_cmp(struct alloc_stat *l, struct alloc_stat *r)
return 0;
}

static int frag_cmp(struct alloc_stat *l, struct alloc_stat *r)
{
double x, y;

x = fragmentation(l->bytes_req, l->bytes_alloc);
y = fragmentation(r->bytes_req, r->bytes_alloc);

if (x < y)
return -1;
else if (x > y)
return 1;
return 0;
}

static int parse_sort_opt(const struct option *opt __used,
const char *arg, int unset __used)
{
Expand All @@ -464,8 +487,12 @@ static int parse_sort_opt(const struct option *opt __used,
sort_fn = ptr_cmp;
else if (strcmp(arg, "call_site") == 0)
sort_fn = callsite_cmp;
else if (strcmp(arg, "hit") == 0)
sort_fn = hit_cmp;
else if (strcmp(arg, "bytes") == 0)
sort_fn = bytes_cmp;
else if (strcmp(arg, "frag") == 0)
sort_fn = frag_cmp;
else
return -1;

Expand Down Expand Up @@ -517,7 +544,7 @@ static const struct option kmem_options[] = {
"stat selector, Pass 'alloc' or 'caller'.",
parse_stat_opt),
OPT_CALLBACK('s', "sort", NULL, "key",
"sort by key: ptr, call_site, hit, bytes",
"sort by key: ptr, call_site, hit, bytes, frag",
parse_sort_opt),
OPT_CALLBACK('l', "line", NULL, "num",
"show n lins",
Expand Down

0 comments on commit 38e16d1

Please sign in to comment.