perf util: Remove kernel version deadcode
authorDr. David Alan Gilbert <linux@treblig.org>
Sat, 16 Nov 2024 15:58:50 +0000 (15:58 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 16 Nov 2024 19:30:39 +0000 (16:30 -0300)
fetch_kernel_version() has been unused since Ian's 2023 commit
3d6dfae889174340 ("perf parse-events: Remove BPF event support")

Remove it, and it's helpers.

I noticed there are a bunch of kernel-version macros that are also
unused nearby.

Also remove them.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20241116155850.113129-1-linux@treblig.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/util.c
tools/perf/util/util.h

index 280c86d..0f031eb 100644 (file)
@@ -342,91 +342,6 @@ bool perf_event_paranoid_check(int max_level)
        return perf_event_paranoid() <= max_level;
 }
 
-static int
-fetch_ubuntu_kernel_version(unsigned int *puint)
-{
-       ssize_t len;
-       size_t line_len = 0;
-       char *ptr, *line = NULL;
-       int version, patchlevel, sublevel, err;
-       FILE *vsig;
-
-       if (!puint)
-               return 0;
-
-       vsig = fopen("/proc/version_signature", "r");
-       if (!vsig) {
-               pr_debug("Open /proc/version_signature failed: %s\n",
-                        strerror(errno));
-               return -1;
-       }
-
-       len = getline(&line, &line_len, vsig);
-       fclose(vsig);
-       err = -1;
-       if (len <= 0) {
-               pr_debug("Reading from /proc/version_signature failed: %s\n",
-                        strerror(errno));
-               goto errout;
-       }
-
-       ptr = strrchr(line, ' ');
-       if (!ptr) {
-               pr_debug("Parsing /proc/version_signature failed: %s\n", line);
-               goto errout;
-       }
-
-       err = sscanf(ptr + 1, "%d.%d.%d",
-                    &version, &patchlevel, &sublevel);
-       if (err != 3) {
-               pr_debug("Unable to get kernel version from /proc/version_signature '%s'\n",
-                        line);
-               goto errout;
-       }
-
-       *puint = (version << 16) + (patchlevel << 8) + sublevel;
-       err = 0;
-errout:
-       free(line);
-       return err;
-}
-
-int
-fetch_kernel_version(unsigned int *puint, char *str,
-                    size_t str_size)
-{
-       struct utsname utsname;
-       int version, patchlevel, sublevel, err;
-       bool int_ver_ready = false;
-
-       if (access("/proc/version_signature", R_OK) == 0)
-               if (!fetch_ubuntu_kernel_version(puint))
-                       int_ver_ready = true;
-
-       if (uname(&utsname))
-               return -1;
-
-       if (str && str_size) {
-               strncpy(str, utsname.release, str_size);
-               str[str_size - 1] = '\0';
-       }
-
-       if (!puint || int_ver_ready)
-               return 0;
-
-       err = sscanf(utsname.release, "%d.%d.%d",
-                    &version, &patchlevel, &sublevel);
-
-       if (err != 3) {
-               pr_debug("Unable to get kernel version from uname '%s'\n",
-                        utsname.release);
-               return -1;
-       }
-
-       *puint = (version << 16) + (patchlevel << 8) + sublevel;
-       return 0;
-}
-
 int perf_tip(char **strp, const char *dirpath)
 {
        struct strlist *tips;
index 2359362..3423778 100644 (file)
@@ -46,14 +46,6 @@ int sysctl__max_stack(void);
 
 bool sysctl__nmi_watchdog_enabled(void);
 
-int fetch_kernel_version(unsigned int *puint,
-                        char *str, size_t str_sz);
-#define KVER_VERSION(x)                (((x) >> 16) & 0xff)
-#define KVER_PATCHLEVEL(x)     (((x) >> 8) & 0xff)
-#define KVER_SUBLEVEL(x)       ((x) & 0xff)
-#define KVER_FMT       "%d.%d.%d"
-#define KVER_PARAM(x)  KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
-
 int perf_tip(char **strp, const char *dirpath);
 
 #ifndef HAVE_SCHED_GETCPU_SUPPORT