perf maps: Reduce scope of map_rb_node and maps internals
Avoid exposing the implementation of maps so that the internals can be refactored. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Colin Ian King <colin.i.king@gmail.com> Cc: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: German Gomez <german.gomez@arm.com> Cc: Guilherme Amadio <amadio@gentoo.org> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Li Dong <lidong@vivo.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nick Terrell <terrelln@fb.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Vincent Whitchurch <vincent.whitchurch@axis.com> Cc: Wenyu Liu <liuwenyu7@huawei.com> Cc: Yang Jihong <yangjihong1@huawei.com> Link: https://lore.kernel.org/r/20231207011722.1220634-22-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
75858007d1
commit
631bb236aa
@ -10,6 +10,11 @@
|
||||
#include "ui/ui.h"
|
||||
#include "unwind.h"
|
||||
|
||||
struct map_rb_node {
|
||||
struct rb_node rb_node;
|
||||
struct map *map;
|
||||
};
|
||||
|
||||
#define maps__for_each_entry(maps, map) \
|
||||
for (map = maps__first(maps); map; map = map_rb_node__next(map))
|
||||
|
||||
@ -17,6 +22,56 @@
|
||||
for (map = maps__first(maps), next = map_rb_node__next(map); map; \
|
||||
map = next, next = map_rb_node__next(map))
|
||||
|
||||
static struct rb_root *maps__entries(struct maps *maps)
|
||||
{
|
||||
return &RC_CHK_ACCESS(maps)->entries;
|
||||
}
|
||||
|
||||
static struct rw_semaphore *maps__lock(struct maps *maps)
|
||||
{
|
||||
return &RC_CHK_ACCESS(maps)->lock;
|
||||
}
|
||||
|
||||
static struct map **maps__maps_by_name(struct maps *maps)
|
||||
{
|
||||
return RC_CHK_ACCESS(maps)->maps_by_name;
|
||||
}
|
||||
|
||||
static struct map_rb_node *maps__first(struct maps *maps)
|
||||
{
|
||||
struct rb_node *first = rb_first(maps__entries(maps));
|
||||
|
||||
if (first)
|
||||
return rb_entry(first, struct map_rb_node, rb_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct map_rb_node *map_rb_node__next(struct map_rb_node *node)
|
||||
{
|
||||
struct rb_node *next;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
next = rb_next(&node->rb_node);
|
||||
|
||||
if (!next)
|
||||
return NULL;
|
||||
|
||||
return rb_entry(next, struct map_rb_node, rb_node);
|
||||
}
|
||||
|
||||
static struct map_rb_node *maps__find_node(struct maps *maps, struct map *map)
|
||||
{
|
||||
struct map_rb_node *rb_node;
|
||||
|
||||
maps__for_each_entry(maps, rb_node) {
|
||||
if (rb_node->RC_CHK_ACCESS(map) == RC_CHK_ACCESS(map))
|
||||
return rb_node;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void maps__init(struct maps *maps, struct machine *machine)
|
||||
{
|
||||
refcount_set(maps__refcnt(maps), 1);
|
||||
@ -485,17 +540,6 @@ out_unlock:
|
||||
return err;
|
||||
}
|
||||
|
||||
struct map_rb_node *maps__find_node(struct maps *maps, struct map *map)
|
||||
{
|
||||
struct map_rb_node *rb_node;
|
||||
|
||||
maps__for_each_entry(maps, rb_node) {
|
||||
if (rb_node->RC_CHK_ACCESS(map) == RC_CHK_ACCESS(map))
|
||||
return rb_node;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct map *maps__find(struct maps *maps, u64 ip)
|
||||
{
|
||||
struct rb_node *p;
|
||||
@ -521,30 +565,6 @@ out:
|
||||
return m ? m->map : NULL;
|
||||
}
|
||||
|
||||
struct map_rb_node *maps__first(struct maps *maps)
|
||||
{
|
||||
struct rb_node *first = rb_first(maps__entries(maps));
|
||||
|
||||
if (first)
|
||||
return rb_entry(first, struct map_rb_node, rb_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct map_rb_node *map_rb_node__next(struct map_rb_node *node)
|
||||
{
|
||||
struct rb_node *next;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
next = rb_next(&node->rb_node);
|
||||
|
||||
if (!next)
|
||||
return NULL;
|
||||
|
||||
return rb_entry(next, struct map_rb_node, rb_node);
|
||||
}
|
||||
|
||||
static int map__strcmp(const void *a, const void *b)
|
||||
{
|
||||
const struct map *map_a = *(const struct map **)a;
|
||||
|
@ -15,11 +15,6 @@ struct machine;
|
||||
struct map;
|
||||
struct maps;
|
||||
|
||||
struct map_rb_node {
|
||||
struct rb_node rb_node;
|
||||
struct map *map;
|
||||
};
|
||||
|
||||
struct map_list_node {
|
||||
struct list_head node;
|
||||
struct map *map;
|
||||
@ -30,9 +25,6 @@ static inline struct map_list_node *map_list_node__new(void)
|
||||
return malloc(sizeof(struct map_list_node));
|
||||
}
|
||||
|
||||
struct map_rb_node *maps__first(struct maps *maps);
|
||||
struct map_rb_node *map_rb_node__next(struct map_rb_node *node);
|
||||
struct map_rb_node *maps__find_node(struct maps *maps, struct map *map);
|
||||
struct map *maps__find(struct maps *maps, u64 addr);
|
||||
|
||||
DECLARE_RC_STRUCT(maps) {
|
||||
@ -78,26 +70,11 @@ int maps__for_each_map(struct maps *maps, int (*cb)(struct map *map, void *data)
|
||||
/* Iterate over map removing an entry if cb returns true. */
|
||||
void maps__remove_maps(struct maps *maps, bool (*cb)(struct map *map, void *data), void *data);
|
||||
|
||||
static inline struct rb_root *maps__entries(struct maps *maps)
|
||||
{
|
||||
return &RC_CHK_ACCESS(maps)->entries;
|
||||
}
|
||||
|
||||
static inline struct machine *maps__machine(struct maps *maps)
|
||||
{
|
||||
return RC_CHK_ACCESS(maps)->machine;
|
||||
}
|
||||
|
||||
static inline struct rw_semaphore *maps__lock(struct maps *maps)
|
||||
{
|
||||
return &RC_CHK_ACCESS(maps)->lock;
|
||||
}
|
||||
|
||||
static inline struct map **maps__maps_by_name(struct maps *maps)
|
||||
{
|
||||
return RC_CHK_ACCESS(maps)->maps_by_name;
|
||||
}
|
||||
|
||||
static inline unsigned int maps__nr_maps(const struct maps *maps)
|
||||
{
|
||||
return RC_CHK_ACCESS(maps)->nr_maps;
|
||||
|
Loading…
Reference in New Issue
Block a user