summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/vm/page_owner_sort.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 9ebb84a9c731..5582d8454d3b 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -23,6 +23,7 @@
struct block_list {
char *txt;
+ char *stacktrace;
int len;
int num;
int page_num;
@@ -51,11 +52,11 @@ int read_block(char *buf, int buf_size, FILE *fin)
return -1; /* EOF or no space left in buf. */
}
-static int compare_txt(const void *p1, const void *p2)
+static int compare_stacktrace(const void *p1, const void *p2)
{
const struct block_list *l1 = p1, *l2 = p2;
- return strcmp(l1->txt, l2->txt);
+ return strcmp(l1->stacktrace, l2->stacktrace);
}
static int compare_num(const void *p1, const void *p2)
@@ -121,6 +122,7 @@ static void add_list(char *buf, int len)
list[list_size].page_num = get_page_num(buf);
memcpy(list[list_size].txt, buf, len);
list[list_size].txt[len] = 0;
+ list[list_size].stacktrace = strchr(list[list_size].txt, '\n') ?: "";
list_size++;
if (list_size % 1000 == 0) {
printf("loaded %d\r", list_size);
@@ -199,7 +201,7 @@ int main(int argc, char **argv)
printf("sorting ....\n");
- qsort(list, list_size, sizeof(list[0]), compare_txt);
+ qsort(list, list_size, sizeof(list[0]), compare_stacktrace);
list2 = malloc(sizeof(*list) * list_size);
if (!list2) {
@@ -211,7 +213,7 @@ int main(int argc, char **argv)
for (i = count = 0; i < list_size; i++) {
if (count == 0 ||
- strcmp(list2[count-1].txt, list[i].txt) != 0) {
+ strcmp(list2[count-1].stacktrace, list[i].stacktrace) != 0) {
list2[count++] = list[i];
} else {
list2[count-1].num += list[i].num;