Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/dsos.c | 29 +++++++++++++++++++++++++++++
tools/perf/util/dsos.h | 3 +++
tools/perf/util/machine.c | 29 -----------------------------
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c
index 2bd23e4cf19e..90a800625110 100644
--- a/tools/perf/util/dsos.c
+++ b/tools/perf/util/dsos.c
@@ -12,6 +12,35 @@
#include <symbol.h> // filename__read_build_id
#include <unistd.h>
+void dsos__init(struct dsos *dsos)
+{
+ INIT_LIST_HEAD(&dsos->head);
+ dsos->root = RB_ROOT;
+ init_rwsem(&dsos->lock);
+}
+
+static void dsos__purge(struct dsos *dsos)
+{
+ struct dso *pos, *n;
+
+ down_write(&dsos->lock);
+
+ list_for_each_entry_safe(pos, n, &dsos->head, node) {
+ RB_CLEAR_NODE(&pos->rb_node);
+ pos->root = NULL;
+ list_del_init(&pos->node);
+ dso__put(pos);
+ }
+
+ up_write(&dsos->lock);
+}
+
+void dsos__exit(struct dsos *dsos)
+{
+ dsos__purge(dsos);
+ exit_rwsem(&dsos->lock);
+}
+
static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)
{
if (a->maj > b->maj) return -1;
diff --git a/tools/perf/util/dsos.h b/tools/perf/util/dsos.h
index 5dbec2bc6966..49f448f106f8 100644
--- a/tools/perf/util/dsos.h
+++ b/tools/perf/util/dsos.h
@@ -21,6 +21,9 @@ struct dsos {
struct rw_semaphore lock;
};
+void dsos__init(struct dsos *dsos);
+void dsos__exit(struct dsos *dsos);
+
void __dsos__add(struct dsos *dsos, struct dso *dso);
void dsos__add(struct dsos *dsos, struct dso *dso);
struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 2a16cae28407..4c5540f5c753 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -50,13 +50,6 @@ static struct dso *machine__kernel_dso(struct machine *machine)
return machine->vmlinux_map->dso;
}
-static void dsos__init(struct dsos *dsos)
-{
- INIT_LIST_HEAD(&dsos->head);
- dsos->root = RB_ROOT;
- init_rwsem(&dsos->lock);
-}
-
static void machine__threads_init(struct machine *machine)
{
int i;
@@ -181,28 +174,6 @@ struct machine *machine__new_kallsyms(void)
return machine;
}
-static void dsos__purge(struct dsos *dsos)
-{
- struct dso *pos, *n;
-
- down_write(&dsos->lock);
-
- list_for_each_entry_safe(pos, n, &dsos->head, node) {
- RB_CLEAR_NODE(&pos->rb_node);
- pos->root = NULL;
- list_del_init(&pos->node);
- dso__put(pos);
- }
-
- up_write(&dsos->lock);
-}
-
-static void dsos__exit(struct dsos *dsos)
-{
- dsos__purge(dsos);
- exit_rwsem(&dsos->lock);
-}
-
void machine__delete_threads(struct machine *machine)
{
struct rb_node *nd;
--
2.37.3.968.ga6b4b080e4-goog
On 16/09/22 20:58, Namhyung Kim wrote:
Maybe say why the move.
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/dsos.c | 29 +++++++++++++++++++++++++++++
> tools/perf/util/dsos.h | 3 +++
> tools/perf/util/machine.c | 29 -----------------------------
> 3 files changed, 32 insertions(+), 29 deletions(-)
>
> diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c
> index 2bd23e4cf19e..90a800625110 100644
> --- a/tools/perf/util/dsos.c
> +++ b/tools/perf/util/dsos.c
> @@ -12,6 +12,35 @@
> #include <symbol.h> // filename__read_build_id
> #include <unistd.h>
>
> +void dsos__init(struct dsos *dsos)
> +{
> + INIT_LIST_HEAD(&dsos->head);
> + dsos->root = RB_ROOT;
> + init_rwsem(&dsos->lock);
> +}
> +
> +static void dsos__purge(struct dsos *dsos)
> +{
> + struct dso *pos, *n;
> +
> + down_write(&dsos->lock);
> +
> + list_for_each_entry_safe(pos, n, &dsos->head, node) {
> + RB_CLEAR_NODE(&pos->rb_node);
> + pos->root = NULL;
> + list_del_init(&pos->node);
> + dso__put(pos);
> + }
> +
> + up_write(&dsos->lock);
> +}
> +
> +void dsos__exit(struct dsos *dsos)
> +{
> + dsos__purge(dsos);
> + exit_rwsem(&dsos->lock);
> +}
> +
> static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)
> {
> if (a->maj > b->maj) return -1;
> diff --git a/tools/perf/util/dsos.h b/tools/perf/util/dsos.h
> index 5dbec2bc6966..49f448f106f8 100644
> --- a/tools/perf/util/dsos.h
> +++ b/tools/perf/util/dsos.h
> @@ -21,6 +21,9 @@ struct dsos {
> struct rw_semaphore lock;
> };
>
> +void dsos__init(struct dsos *dsos);
> +void dsos__exit(struct dsos *dsos);
> +
> void __dsos__add(struct dsos *dsos, struct dso *dso);
> void dsos__add(struct dsos *dsos, struct dso *dso);
> struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 2a16cae28407..4c5540f5c753 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -50,13 +50,6 @@ static struct dso *machine__kernel_dso(struct machine *machine)
> return machine->vmlinux_map->dso;
> }
>
> -static void dsos__init(struct dsos *dsos)
> -{
> - INIT_LIST_HEAD(&dsos->head);
> - dsos->root = RB_ROOT;
> - init_rwsem(&dsos->lock);
> -}
> -
> static void machine__threads_init(struct machine *machine)
> {
> int i;
> @@ -181,28 +174,6 @@ struct machine *machine__new_kallsyms(void)
> return machine;
> }
>
> -static void dsos__purge(struct dsos *dsos)
> -{
> - struct dso *pos, *n;
> -
> - down_write(&dsos->lock);
> -
> - list_for_each_entry_safe(pos, n, &dsos->head, node) {
> - RB_CLEAR_NODE(&pos->rb_node);
> - pos->root = NULL;
> - list_del_init(&pos->node);
> - dso__put(pos);
> - }
> -
> - up_write(&dsos->lock);
> -}
> -
> -static void dsos__exit(struct dsos *dsos)
> -{
> - dsos__purge(dsos);
> - exit_rwsem(&dsos->lock);
> -}
> -
> void machine__delete_threads(struct machine *machine)
> {
> struct rb_node *nd;
Hi Adrian, On Tue, Sep 20, 2022 at 6:51 AM Adrian Hunter <adrian.hunter@intel.com> wrote: > > On 16/09/22 20:58, Namhyung Kim wrote: > > Maybe say why the move. Sure, I'll add something like this. "The dsos routines will be used in other places soon. As they have a separate file already, let's move them to a proper place." Thanks for your review! Namhyung
© 2016 - 2026 Red Hat, Inc.