Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf lock: Sort map info based on class name

Instead of the random order, sort it by lock class name.

Before:

# perf lock info -m
Address of instance: name of class
0xffffa0d940ac5310: &dentry->d_lockref.lock
0xffffa0c20b0e1cb0: &dentry->d_lockref.lock
0xffffa0d8e051cc48: &base->lock
0xffffa0d94f992110: &anon_vma->rwsem
0xffffa0d947a4f278: (null)
0xffffa0c208f6e108: &map->lock
0xffffa0c213ad32c8: &cfs_rq->removed.lock
0xffffa0c20d695888: &parent->list_lock
0xffffa0c278775278: (null)
0xffffa0c212ad4690: &dentry->d_lockref.lock

After:

# perf lock info -m
Address of instance: name of class
0xffffa0c20d538800: &(&sig->stats_lock)->lock
0xffffa0c216d4ec40: &(&sig->stats_lock)->lock
0xffffa1fe4cb04610: &(__futex_data.queues)[i].lock
0xffffa1fe4cb07750: &(__futex_data.queues)[i].lock
0xffffa1fe4cb07b50: &(__futex_data.queues)[i].lock
0xffffa1fe4cb0b850: &(__futex_data.queues)[i].lock
0xffffa1fe4cb0bcd0: &(__futex_data.queues)[i].lock
0xffffa1fe4cb0e5d0: &(__futex_data.queues)[i].lock
0xffffa1fe4cb11ad0: &(__futex_data.queues)[i].lock

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220127000050.3011493-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
f4cf2d75 e1c3177b

+19 -1
+19 -1
tools/perf/builtin-lock.c
··· 757 757 } 758 758 } 759 759 760 + static int compare_maps(struct lock_stat *a, struct lock_stat *b) 761 + { 762 + int ret; 763 + 764 + if (a->name && b->name) 765 + ret = strcmp(a->name, b->name); 766 + else 767 + ret = !!a->name - !!b->name; 768 + 769 + if (!ret) 770 + return a->addr < b->addr; 771 + else 772 + return ret < 0; 773 + } 774 + 760 775 static void dump_map(void) 761 776 { 762 777 unsigned int i; ··· 780 765 pr_info("Address of instance: name of class\n"); 781 766 for (i = 0; i < LOCKHASH_SIZE; i++) { 782 767 hlist_for_each_entry(st, &lockhash_table[i], hash_entry) { 783 - pr_info(" %#llx: %s\n", (unsigned long long)st->addr, st->name); 768 + insert_to_result(st, compare_maps); 784 769 } 785 770 } 771 + 772 + while ((st = pop_from_result())) 773 + pr_info(" %#llx: %s\n", (unsigned long long)st->addr, st->name); 786 774 } 787 775 788 776 static int dump_info(void)