Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cec2447 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo
Browse files

perf symbol: Create block_info structure



'perf diff' currently can only diff symbols(functions).

We should expand it to diff cycles of individual programs blocks as
reported by timed LBR.  This would allow to identify changes in specific
code accurately.

We need a new structure to maintain the basic block information, such as,
symbol(function), start/end address of this block, cycles. This patch
creates this structure and with some ops.

Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1561713784-30533-2-git-send-email-yao.jin@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0c69b931
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2351,3 +2351,25 @@ struct mem_info *mem_info__new(void)
		refcount_set(&mi->refcnt, 1);
	return mi;
}

struct block_info *block_info__get(struct block_info *bi)
{
	if (bi)
		refcount_inc(&bi->refcnt);
	return bi;
}

void block_info__put(struct block_info *bi)
{
	if (bi && refcount_dec_and_test(&bi->refcnt))
		free(bi);
}

struct block_info *block_info__new(void)
{
	struct block_info *bi = zalloc(sizeof(*bi));

	if (bi)
		refcount_set(&bi->refcnt, 1);
	return bi;
}
+23 −0
Original line number Diff line number Diff line
@@ -131,6 +131,17 @@ struct mem_info {
	refcount_t		refcnt;
};

struct block_info {
	struct symbol		*sym;
	u64			start;
	u64			end;
	u64			cycles;
	u64			cycles_aggr;
	int			num;
	int			num_aggr;
	refcount_t		refcnt;
};

struct addr_location {
	struct machine *machine;
	struct thread *thread;
@@ -332,4 +343,16 @@ static inline void __mem_info__zput(struct mem_info **mi)

#define mem_info__zput(mi) __mem_info__zput(&mi)

struct block_info *block_info__new(void);
struct block_info *block_info__get(struct block_info *bi);
void   block_info__put(struct block_info *bi);

static inline void __block_info__zput(struct block_info **bi)
{
	block_info__put(*bi);
	*bi = NULL;
}

#define block_info__zput(bi) __block_info__zput(&bi)

#endif /* __PERF_SYMBOL */