perf util: Remove kernel version deadcode
PATCH 1/1 perf util: Remove kernel version deadcode
From: "Dr. David Alan Gilbert" <[email protected]>
fetch_kernel_version() has been unused since Ian's 2013 commit 3d6dfae88917 ("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.
--- tools/perf/util/util.c | 85 ------------------------------------------ tools/perf/util/util.h | 8 ---- 2 files changed, 93 deletions(-)
tools/perf/util/util.c +0 -85
@@ -336,91 +336,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;
tools/perf/util/util.h +0 -8
@@ -43,14 +43,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
Signature · 1 line
2.47.0
Quoted 6 lines · On Sat, Nov 16, 2024 at 7:58 AM <[email protected]> wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
fetch_kernel_version()has been unused since Ian's 2013 commit3d6dfae88917("perf parse-events: Remove BPF event support")
Quoted 6 lines
Remove it, and it's helpers.
I noticed there are a bunch of kernel-version macros that are also unused nearby.
Also remove them.Signed-off-by Dr. David Alan Gilbert <[email protected]>
Thanks,
Ian
Quoted 123 lines
--- tools/perf/util/util.c | 85 ------------------------------------------ tools/perf/util/util.h | 8 ---- 2 files changed, 93 deletions(-)tools/perf/util/util.c +0
-85@@ -336,91 +336,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;tools/perf/util/util.h +0
-9@@ -43,14 +43,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 --2.47.0
Quoted 4 lines · Ian Rogers
Quoted 3 lines · On Sat, Nov 16, 2024 at 7:58 AM <[email protected]> wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
fetch_kernel_version()has been unused since Ian's 2013
2023
Quoted 10 lines
Quoted 8 lines
commit
3d6dfae88917("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.Signed-off-by Dr. David Alan Gilbert <[email protected]>Reviewed-by Ian Rogers <[email protected]>
Thanks, applied to perf-tools-next,
- Arnaldo
Quoted 15 lines · * Arnaldo Carvalho de Melo ([email protected]) wrote:
Quoted 4 lines · Ian Rogers
Quoted 3 lines · On Sat, Nov 16, 2024 at 7:58 AM <[email protected]> wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
fetch_kernel_version()has been unused since Ian's 20132023Quoted 7 lines
Quoted 7 lines
commit
3d6dfae88917("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.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Dr. David Alan Gilbert <[email protected]>Reviewed-by Ian Rogers <[email protected]>Thanks, applied to perf-tools-next,
Thanks!
Have you got:
[PATCH] perf: Remove unused del_perf_probe_events
https://lore.kernel.org/all/[email protected]/
from a few weeks back in there? I don't think I've had an email
response to that one.
Dave
Quoted 2 lines
- Arnaldo
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Arnaldo Carvalho de Melo
maintainerQuoted 10 lines · Dr. David Alan Gilbert
Quoted 1 line · * Arnaldo Carvalho de Melo ([email protected]) wrote:
Thanks, applied to perf-tools-next,
Thanks!
Have you got:
[PATCH] perf: Remove unuseddel_perf_probe_events
https://lore.kernel.org/all/[email protected]/from a few weeks back in there? I don't think I've had an email
response to that one.
Done now and pushed out, thanks for cleaning up the perf tools codebase!
- Arnaldo
Quoted 9 lines · * Arnaldo Carvalho de Melo ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 1 line · * Arnaldo Carvalho de Melo ([email protected]) wrote:
Thanks, applied to perf-tools-next,
Thanks!
Have you got:
[PATCH] perf: Remove unuseddel_perf_probe_events
https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
Quoted 2 lines
from a few weeks back in there? I don't think I've had an email
response to that one.Done now and pushed out, thanks for cleaning up the perf tools codebase!
Thanks!
Dave
Quoted 1 line
- Arnaldo
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/