mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
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>
This commit is contained in:
parent
6923397cb7
commit
fb87158bab
1 changed files with 13 additions and 9 deletions
|
@ -59,7 +59,10 @@ struct lock_stat {
|
||||||
unsigned int nr_contended;
|
unsigned int nr_contended;
|
||||||
unsigned int nr_release;
|
unsigned int nr_release;
|
||||||
|
|
||||||
unsigned int nr_readlock;
|
union {
|
||||||
|
unsigned int nr_readlock;
|
||||||
|
unsigned int flags;
|
||||||
|
};
|
||||||
unsigned int nr_trylock;
|
unsigned int nr_trylock;
|
||||||
|
|
||||||
/* these times are in nano sec. */
|
/* these times are in nano sec. */
|
||||||
|
@ -516,7 +519,7 @@ static struct lock_stat *lock_stat_find(u64 addr)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct lock_stat *lock_stat_findnew(u64 addr, const char *name)
|
static struct lock_stat *lock_stat_findnew(u64 addr, const char *name, int flags)
|
||||||
{
|
{
|
||||||
struct hlist_head *entry = lockhashentry(addr);
|
struct hlist_head *entry = lockhashentry(addr);
|
||||||
struct lock_stat *ret, *new;
|
struct lock_stat *ret, *new;
|
||||||
|
@ -531,13 +534,13 @@ static struct lock_stat *lock_stat_findnew(u64 addr, const char *name)
|
||||||
goto alloc_failed;
|
goto alloc_failed;
|
||||||
|
|
||||||
new->addr = addr;
|
new->addr = addr;
|
||||||
new->name = zalloc(sizeof(char) * strlen(name) + 1);
|
new->name = strdup(name);
|
||||||
if (!new->name) {
|
if (!new->name) {
|
||||||
free(new);
|
free(new);
|
||||||
goto alloc_failed;
|
goto alloc_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new->name, name);
|
new->flags = flags;
|
||||||
new->wait_time_min = ULLONG_MAX;
|
new->wait_time_min = ULLONG_MAX;
|
||||||
|
|
||||||
hlist_add_head(&new->hash_entry, entry);
|
hlist_add_head(&new->hash_entry, entry);
|
||||||
|
@ -624,7 +627,7 @@ static int report_lock_acquire_event(struct evsel *evsel,
|
||||||
if (show_thread_stats)
|
if (show_thread_stats)
|
||||||
addr = sample->tid;
|
addr = sample->tid;
|
||||||
|
|
||||||
ls = lock_stat_findnew(addr, name);
|
ls = lock_stat_findnew(addr, name, 0);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -696,7 +699,7 @@ static int report_lock_acquired_event(struct evsel *evsel,
|
||||||
if (show_thread_stats)
|
if (show_thread_stats)
|
||||||
addr = sample->tid;
|
addr = sample->tid;
|
||||||
|
|
||||||
ls = lock_stat_findnew(addr, name);
|
ls = lock_stat_findnew(addr, name, 0);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -758,7 +761,7 @@ static int report_lock_contended_event(struct evsel *evsel,
|
||||||
if (show_thread_stats)
|
if (show_thread_stats)
|
||||||
addr = sample->tid;
|
addr = sample->tid;
|
||||||
|
|
||||||
ls = lock_stat_findnew(addr, name);
|
ls = lock_stat_findnew(addr, name, 0);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -813,7 +816,7 @@ static int report_lock_release_event(struct evsel *evsel,
|
||||||
if (show_thread_stats)
|
if (show_thread_stats)
|
||||||
addr = sample->tid;
|
addr = sample->tid;
|
||||||
|
|
||||||
ls = lock_stat_findnew(addr, name);
|
ls = lock_stat_findnew(addr, name, 0);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -985,11 +988,12 @@ static int report_lock_contention_begin_event(struct evsel *evsel,
|
||||||
if (!ls) {
|
if (!ls) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
const char *caller = buf;
|
const char *caller = buf;
|
||||||
|
unsigned int flags = evsel__intval(evsel, sample, "flags");
|
||||||
|
|
||||||
if (lock_contention_caller(evsel, sample, buf, sizeof(buf)) < 0)
|
if (lock_contention_caller(evsel, sample, buf, sizeof(buf)) < 0)
|
||||||
caller = "Unknown";
|
caller = "Unknown";
|
||||||
|
|
||||||
ls = lock_stat_findnew(addr, caller);
|
ls = lock_stat_findnew(addr, caller, flags);
|
||||||
if (!ls)
|
if (!ls)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue