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: Add flags field in the lock_stat

For lock contention tracepoint analysis, it needs to keep the flags.
As nr_readlock and nr_trylock fields are not used for it, let's make
it a union.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20220725183124.368304-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
fb87158b 6923397c

+13 -9
+13 -9
tools/perf/builtin-lock.c
··· 59 59 unsigned int nr_contended; 60 60 unsigned int nr_release; 61 61 62 - unsigned int nr_readlock; 62 + union { 63 + unsigned int nr_readlock; 64 + unsigned int flags; 65 + }; 63 66 unsigned int nr_trylock; 64 67 65 68 /* these times are in nano sec. */ ··· 519 516 return NULL; 520 517 } 521 518 522 - static struct lock_stat *lock_stat_findnew(u64 addr, const char *name) 519 + static struct lock_stat *lock_stat_findnew(u64 addr, const char *name, int flags) 523 520 { 524 521 struct hlist_head *entry = lockhashentry(addr); 525 522 struct lock_stat *ret, *new; ··· 534 531 goto alloc_failed; 535 532 536 533 new->addr = addr; 537 - new->name = zalloc(sizeof(char) * strlen(name) + 1); 534 + new->name = strdup(name); 538 535 if (!new->name) { 539 536 free(new); 540 537 goto alloc_failed; 541 538 } 542 539 543 - strcpy(new->name, name); 540 + new->flags = flags; 544 541 new->wait_time_min = ULLONG_MAX; 545 542 546 543 hlist_add_head(&new->hash_entry, entry); ··· 627 624 if (show_thread_stats) 628 625 addr = sample->tid; 629 626 630 - ls = lock_stat_findnew(addr, name); 627 + ls = lock_stat_findnew(addr, name, 0); 631 628 if (!ls) 632 629 return -ENOMEM; 633 630 ··· 699 696 if (show_thread_stats) 700 697 addr = sample->tid; 701 698 702 - ls = lock_stat_findnew(addr, name); 699 + ls = lock_stat_findnew(addr, name, 0); 703 700 if (!ls) 704 701 return -ENOMEM; 705 702 ··· 761 758 if (show_thread_stats) 762 759 addr = sample->tid; 763 760 764 - ls = lock_stat_findnew(addr, name); 761 + ls = lock_stat_findnew(addr, name, 0); 765 762 if (!ls) 766 763 return -ENOMEM; 767 764 ··· 816 813 if (show_thread_stats) 817 814 addr = sample->tid; 818 815 819 - ls = lock_stat_findnew(addr, name); 816 + ls = lock_stat_findnew(addr, name, 0); 820 817 if (!ls) 821 818 return -ENOMEM; 822 819 ··· 988 985 if (!ls) { 989 986 char buf[128]; 990 987 const char *caller = buf; 988 + unsigned int flags = evsel__intval(evsel, sample, "flags"); 991 989 992 990 if (lock_contention_caller(evsel, sample, buf, sizeof(buf)) < 0) 993 991 caller = "Unknown"; 994 992 995 - ls = lock_stat_findnew(addr, caller); 993 + ls = lock_stat_findnew(addr, caller, flags); 996 994 if (!ls) 997 995 return -ENOMEM; 998 996 }