perf buildid-cache: Apply force option to copying kcore
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 14 Jul 2014 10:02:38 +0000 (13:02 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 16 Jul 2014 20:57:35 +0000 (17:57 -0300)
Currently a copy of kcore is not made if there is one already with the
same modules at the same addresses.

Change this to make a copy anyway if the force (-f) option is also used.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1405332185-4050-15-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-buildid-cache.c

index b22dbb16f8776112f335e9185740a85645f2cf86..2a2c78f8087663852292d1220e51a41694ce0f3c 100644 (file)
@@ -125,7 +125,8 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
        return ret;
 }
 
-static int build_id_cache__add_kcore(const char *filename, const char *debugdir)
+static int build_id_cache__add_kcore(const char *filename, const char *debugdir,
+                                    bool force)
 {
        char dir[32], sbuildid[BUILD_ID_SIZE * 2 + 1];
        char from_dir[PATH_MAX], to_dir[PATH_MAX];
@@ -144,7 +145,8 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir)
        scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
                  debugdir, sbuildid);
 
-       if (!build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) {
+       if (!force &&
+           !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) {
                pr_debug("same kcore found in %s\n", to_dir);
                return 0;
        }
@@ -389,7 +391,7 @@ int cmd_buildid_cache(int argc, const char **argv,
        }
 
        if (kcore_filename &&
-           build_id_cache__add_kcore(kcore_filename, debugdir))
+           build_id_cache__add_kcore(kcore_filename, debugdir, force))
                pr_warning("Couldn't add %s\n", kcore_filename);
 
        return ret;