Message ID | 20220711093218.10967-21-adrian.hunter@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | perf intel-pt: Add support for tracing virtual machine user space on the host | expand |
On Mon, Jul 11, 2022 at 2:33 AM Adrian Hunter <adrian.hunter@intel.com> wrote: > > Copies of /proc/kallsyms, /proc/modules and an extract of /proc/kcore can > be stored in the perf.data output directory under the subdirectory named > kcore_dir. Guest machines will have their files also under subdirectories > beginning kcore_dir__ followed by the machine pid. Remove these also when > removing kcore_dir. > > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ian Rogers <irogers@google.com> Thanks, Ian > --- > tools/perf/util/util.c | 37 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 35 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c > index eeb83c80f458..9b02edf9311d 100644 > --- a/tools/perf/util/util.c > +++ b/tools/perf/util/util.c > @@ -200,7 +200,7 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat) > return rmdir(path); > } > > -static int rm_rf_kcore_dir(const char *path) > +static int rm_rf_a_kcore_dir(const char *path, const char *name) > { > char kcore_dir_path[PATH_MAX]; > const char *pat[] = { > @@ -210,11 +210,44 @@ static int rm_rf_kcore_dir(const char *path) > NULL, > }; > > - snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/kcore_dir", path); > + snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/%s", path, name); > > return rm_rf_depth_pat(kcore_dir_path, 0, pat); > } > > +static bool kcore_dir_filter(const char *name __maybe_unused, struct dirent *d) > +{ > + const char *pat[] = { > + "kcore_dir", > + "kcore_dir__[1-9]*", > + NULL, > + }; > + > + return match_pat(d->d_name, pat); > +} > + > +static int rm_rf_kcore_dir(const char *path) > +{ > + struct strlist *kcore_dirs; > + struct str_node *nd; > + int ret; > + > + kcore_dirs = lsdir(path, kcore_dir_filter); > + > + if (!kcore_dirs) > + return 0; > + > + strlist__for_each_entry(nd, kcore_dirs) { > + ret = rm_rf_a_kcore_dir(path, nd->s); > + if (ret) > + return ret; > + } > + > + strlist__delete(kcore_dirs); > + > + return 0; > +} > + > int rm_rf_perf_data(const char *path) > { > const char *pat[] = { > -- > 2.25.1 >
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index eeb83c80f458..9b02edf9311d 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -200,7 +200,7 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat) return rmdir(path); } -static int rm_rf_kcore_dir(const char *path) +static int rm_rf_a_kcore_dir(const char *path, const char *name) { char kcore_dir_path[PATH_MAX]; const char *pat[] = { @@ -210,11 +210,44 @@ static int rm_rf_kcore_dir(const char *path) NULL, }; - snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/kcore_dir", path); + snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/%s", path, name); return rm_rf_depth_pat(kcore_dir_path, 0, pat); } +static bool kcore_dir_filter(const char *name __maybe_unused, struct dirent *d) +{ + const char *pat[] = { + "kcore_dir", + "kcore_dir__[1-9]*", + NULL, + }; + + return match_pat(d->d_name, pat); +} + +static int rm_rf_kcore_dir(const char *path) +{ + struct strlist *kcore_dirs; + struct str_node *nd; + int ret; + + kcore_dirs = lsdir(path, kcore_dir_filter); + + if (!kcore_dirs) + return 0; + + strlist__for_each_entry(nd, kcore_dirs) { + ret = rm_rf_a_kcore_dir(path, nd->s); + if (ret) + return ret; + } + + strlist__delete(kcore_dirs); + + return 0; +} + int rm_rf_perf_data(const char *path) { const char *pat[] = {
Copies of /proc/kallsyms, /proc/modules and an extract of /proc/kcore can be stored in the perf.data output directory under the subdirectory named kcore_dir. Guest machines will have their files also under subdirectories beginning kcore_dir__ followed by the machine pid. Remove these also when removing kcore_dir. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> --- tools/perf/util/util.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)