perf machine: Use cached rbtrees
At the cost of an extra pointer, we can avoid the O(logN) cost of finding the first element in the tree (smallest node), which is something required for nearly every operation dealing with machine->guests and threads->entries. The conversion is straightforward, however, it's worth noticing that the rb_erase_init() calls have been replaced by rb_erase_cached() which has no _init() flavor, however, the node is explicitly cleared next anyway, which was redundant until now. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20181206191819.30182-3-dave@stgolabs.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
3aef2cad5d
commit
f3acb3a8a2
@@ -29,11 +29,11 @@ struct vdso_info;
|
||||
#define THREADS__TABLE_SIZE (1 << THREADS__TABLE_BITS)
|
||||
|
||||
struct threads {
|
||||
struct rb_root entries;
|
||||
struct rw_semaphore lock;
|
||||
unsigned int nr;
|
||||
struct list_head dead;
|
||||
struct thread *last_match;
|
||||
struct rb_root_cached entries;
|
||||
struct rw_semaphore lock;
|
||||
unsigned int nr;
|
||||
struct list_head dead;
|
||||
struct thread *last_match;
|
||||
};
|
||||
|
||||
struct machine {
|
||||
@@ -140,7 +140,7 @@ typedef void (*machine__process_t)(struct machine *machine, void *data);
|
||||
|
||||
struct machines {
|
||||
struct machine host;
|
||||
struct rb_root guests;
|
||||
struct rb_root_cached guests;
|
||||
};
|
||||
|
||||
void machines__init(struct machines *machines);
|
||||
|
Reference in New Issue
Block a user