Commit 59119c09 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo
Browse files

perf lock contention: Factor out lock_type_table



Move it out of get_type_str() so that we can reuse the table for others
later.

Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Blake Jones <blakejones@google.com>
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: Song Liu <song@kernel.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221219201732.460111-2-namhyung@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8b269b75
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -1437,12 +1437,10 @@ static void sort_result(void)
	}
}

static const char *get_type_str(struct lock_stat *st)
{
static const struct {
	unsigned int flags;
	const char *name;
	} table[] = {
} lock_type_table[] = {
	{ 0,				"semaphore" },
	{ LCB_F_SPIN,			"spinlock" },
	{ LCB_F_SPIN | LCB_F_READ,	"rwlock:R" },
@@ -1458,9 +1456,11 @@ static const char *get_type_str(struct lock_stat *st)
	{ LCB_F_MUTEX | LCB_F_SPIN,	"mutex" },
};

	for (unsigned int i = 0; i < ARRAY_SIZE(table); i++) {
		if (table[i].flags == st->flags)
			return table[i].name;
static const char *get_type_str(unsigned int flags)
{
	for (unsigned int i = 0; i < ARRAY_SIZE(lock_type_table); i++) {
		if (lock_type_table[i].flags == flags)
			return lock_type_table[i].name;
	}
	return "unknown";
}
@@ -1514,7 +1514,7 @@ static void print_contention_result(struct lock_contention *con)

		switch (aggr_mode) {
		case LOCK_AGGR_CALLER:
			pr_info("  %10s   %s\n", get_type_str(st), st->name);
			pr_info("  %10s   %s\n", get_type_str(st->flags), st->name);
			break;
		case LOCK_AGGR_TASK:
			pid = st->addr;