aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2022-07-11 12:32:03 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-07-20 11:08:30 -0300
commit386e0d83d351a4461525b06b845ffcd58235381e (patch)
treef1419388352f1cc1a173b2a4129cfdfc1b48f057
parentperf script python: intel-pt-events: Add machine_pid and vcpu (diff)
downloadlinux-dev-386e0d83d351a4461525b06b845ffcd58235381e.tar.xz
linux-dev-386e0d83d351a4461525b06b845ffcd58235381e.zip
perf tools: Remove also guest kcore_dir with host kcore_dir
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> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: kvm@vger.kernel.org Link: https://lore.kernel.org/r/20220711093218.10967-21-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/util.c37
1 files 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[] = {