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: Convert lockhash_table to use hlist

The hlist_head has a single entry so we can save some memory.

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-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
7672d00a 40b0c5fd

+8 -8
+8 -8
tools/perf/builtin-lock.c
··· 38 38 #define LOCKHASH_BITS 12 39 39 #define LOCKHASH_SIZE (1UL << LOCKHASH_BITS) 40 40 41 - static struct list_head lockhash_table[LOCKHASH_SIZE]; 41 + static struct hlist_head lockhash_table[LOCKHASH_SIZE]; 42 42 43 43 #define __lockhashfn(key) hash_long((unsigned long)key, LOCKHASH_BITS) 44 44 #define lockhashentry(key) (lockhash_table + __lockhashfn((key))) 45 45 46 46 struct lock_stat { 47 - struct list_head hash_entry; 47 + struct hlist_node hash_entry; 48 48 struct rb_node rb; /* used for sorting */ 49 49 50 50 /* ··· 317 317 318 318 static struct lock_stat *lock_stat_findnew(void *addr, const char *name) 319 319 { 320 - struct list_head *entry = lockhashentry(addr); 320 + struct hlist_head *entry = lockhashentry(addr); 321 321 struct lock_stat *ret, *new; 322 322 323 - list_for_each_entry(ret, entry, hash_entry) { 323 + hlist_for_each_entry(ret, entry, hash_entry) { 324 324 if (ret->addr == addr) 325 325 return ret; 326 326 } ··· 339 339 strcpy(new->name, name); 340 340 new->wait_time_min = ULLONG_MAX; 341 341 342 - list_add(&new->hash_entry, entry); 342 + hlist_add_head(&new->hash_entry, entry); 343 343 return new; 344 344 345 345 alloc_failed: ··· 781 781 782 782 pr_info("Address of instance: name of class\n"); 783 783 for (i = 0; i < LOCKHASH_SIZE; i++) { 784 - list_for_each_entry(st, &lockhash_table[i], hash_entry) { 784 + hlist_for_each_entry(st, &lockhash_table[i], hash_entry) { 785 785 pr_info(" %p: %s\n", st->addr, st->name); 786 786 } 787 787 } ··· 838 838 struct lock_stat *st; 839 839 840 840 for (i = 0; i < LOCKHASH_SIZE; i++) { 841 - list_for_each_entry(st, &lockhash_table[i], hash_entry) { 841 + hlist_for_each_entry(st, &lockhash_table[i], hash_entry) { 842 842 insert_to_result(st, compare); 843 843 } 844 844 } ··· 990 990 int rc = 0; 991 991 992 992 for (i = 0; i < LOCKHASH_SIZE; i++) 993 - INIT_LIST_HEAD(lockhash_table + i); 993 + INIT_HLIST_HEAD(lockhash_table + i); 994 994 995 995 argc = parse_options_subcommand(argc, argv, lock_options, lock_subcommands, 996 996 lock_usage, PARSE_OPT_STOP_AT_NON_OPTION);