perf: Deadcode - the P's
cover perf: Deadcode - the P's
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is another set of perf deadcode, this is my set
all starting with 'p'. It was built on top of perf-tools-next as of a few days ago (7788ad59d1d9).
Dave
Dr. David Alan Gilbert (6):
perf core: Remove perf_event_attrs and perf_event_refresh perf util: Remove unused perf_color_default_config perf util: Remove unused pstack__pop
perf util: Remove unused perf_data__update_dir perf util: Remove unused perf_pmus__default_pmu_name perf util: Remove unused perf_config__refresh
include/linux/perf_event.h | 10 ---------- kernel/events/core.c | 24 ------------------------ tools/perf/util/color.h | 5 ----- tools/perf/util/color_config.c | 11 ----------- tools/perf/util/config.c | 6 ------ tools/perf/util/config.h | 1 - tools/perf/util/data.c | 20 -------------------- tools/perf/util/data.h | 1 - tools/perf/util/pmus.c | 29 ----------------------------- tools/perf/util/pmus.h | 1 - tools/perf/util/pstack.c | 14 -------------- tools/perf/util/pstack.h | 1 - 12 files changed, 123 deletions(-)
Signature · 1 line
2.48.1
PATCH 1/6 perf core: Remove perf_event_attrs and perf_event_refresh
From: "Dr. David Alan Gilbert" <[email protected]>
perf_event_refresh() has been unused since the 2015 commit f63a8daa5812 ("perf: Fix event->ctx locking")
perf_event_attrs() has been unused since the 2017
commit f91840a32dee ("perf, bpf: Add BPF support to all perf_event types") (Note the _ prefix version is still used)
Remove them.
--- include/linux/perf_event.h | 10 ---------- kernel/events/core.c | 24 ------------------------ 2 files changed, 34 deletions(-)
include/linux/perf_event.h +0 -10
@@ -1136,7 +1136,6 @@ extern void perf_event_free_task(struct task_struct *task);extern void perf_event_delayed_put (struct task_struct *task);extern struct file *perf_event_get (unsigned int fd);extern const struct perf_event *perf_get_event (struct file *file); -extern const struct perf_event_attr *perf_event_attrs (struct perf_event *event);extern void perf_event_print_debug (void );extern void perf_pmu_disable (struct pmu *pmu);extern void perf_pmu_enable (struct pmu *pmu);
@@ -1147,7 +1146,6 @@ extern int perf_event_task_enable(void);extern void perf_pmu_resched (struct pmu *pmu); -extern int perf_event_refresh (struct perf_event *event,int refresh);extern void perf_event_update_userpage (struct perf_event *event);extern int perf_event_release_kernel (struct perf_event *event); extern struct perf_event *
@@ -1841,10 +1839,6 @@ static inline const struct perf_event *perf_get_event(struct file *file) {return ERR_PTR (-EINVAL ); } -static inline const struct perf_event_attr *perf_event_attrs (struct perf_event *event) -{ -return ERR_PTR (-EINVAL ); -}static inline int perf_event_read_local (struct perf_event *event,u64 *value,u64 *enabled,u64 *running) {
@@ -1853,10 +1847,6 @@ static inline int perf_event_read_local(struct perf_event *event, u64 *value,static inline void perf_event_print_debug (void ) { }static inline int perf_event_task_disable (void ) {return -EINVAL ; }static inline int perf_event_task_enable (void ) {return -EINVAL ; } -static inline int perf_event_refresh (struct perf_event *event,int refresh) -{ -return -EINVAL ; -}static inline void perf_sw_event (u32 event_id,u64 nr,struct pt_regs *regs,u64 addr) { }
kernel/events/core.c +0 -24
@@ -3224,22 +3224,6 @@ static int _perf_event_refresh(struct perf_event *event, int refresh)return 0 ; } -/* -* See perf_event_disable() -*/ -int perf_event_refresh (struct perf_event *event,int refresh) -{ -struct perf_event_context *ctx; -int ret; - - ctx =perf_event_ctx_lock (event); - ret =_perf_event_refresh (event, refresh); -perf_event_ctx_unlock (event, ctx); - -return ret; -} -EXPORT_SYMBOL_GPL (perf_event_refresh); -static int perf_event_modify_breakpoint (struct perf_event *bp,struct perf_event_attr *attr) {
@@ -13639,14 +13623,6 @@ const struct perf_event *perf_get_event(struct file *file)return file->private_data; } -const struct perf_event_attr *perf_event_attrs (struct perf_event *event) -{ -if (!event) -return ERR_PTR (-EINVAL ); - -return &event->attr; -} -int perf_allow_kernel (struct perf_event_attr *attr) {if (sysctl_perf_event_paranoid >1 && !perfmon_capable ())
Signature · 1 line
2.48.1
PATCH 2/6 perf util: Remove unused perf_color_default_config
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
perf_color_default_config() was added in 2009 by
commit 8fc0321f1ad0 ("perf_counter tools: Add color terminal output support")
but has remained unused.
Remove it.
--- tools/perf/util/color.h | 5 ----- tools/perf/util/color_config.c | 11 ----------- 2 files changed, 16 deletions(-)
tools/perf/util/color.h +0 -5
@@ -30,11 +30,6 @@extern int perf_use_color_default; -/* -* Use this instead of perf_default_config if you need the value of color.ui. -*/ -int perf_color_default_config (const char *var,const char *value,void *cb); -int perf_config_colorbool (const char *var,const char *value,int stdout_is_tty);int color_vsnprintf (char *bf,size_t size,const char *color,const char *fmt,va_list args);
tools/perf/util/color_config.c +0 -11
@@ -35,14 +35,3 @@ int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty) }return 0 ; } - -int perf_color_default_config (const char *var,const char *value, -void *cb__maybe_unused ) -{ -if (!strcmp (var,"color.ui" )) { - perf_use_color_default =perf_config_colorbool (var, value,-1 ); -return 0 ; - } - -return 0 ; -}
Signature · 1 line
2.48.1
PATCH 3/6 perf util: Remove unused pstack__pop
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
The last use of pstack__pop() was removed in 2015 by commit 6422184b087f ("perf hists browser: Simplify zooming code using pstack_peek()")
Remove it.
--- tools/perf/util/pstack.c | 14 -------------- tools/perf/util/pstack.h | 1 - 2 files changed, 15 deletions(-)
tools/perf/util/pstack.c +0 -14
@@ -63,20 +63,6 @@ void pstack__push(struct pstack *pstack, void *key) pstack->entries[pstack->top++] = key; } -void *pstack__pop (struct pstack *pstack) -{ -void *ret; - -if (pstack->top ==0 ) { -pr_err ("%s: underflow!\n" , __func__); -return NULL ; - } - - ret = pstack->entries[--pstack->top]; - pstack->entries[pstack->top] =NULL ; -return ret; -} -void *pstack__peek (struct pstack *pstack) {if (pstack->top ==0 )
tools/perf/util/pstack.h +0 -1
@@ -10,7 +10,6 @@ void pstack__delete(struct pstack *pstack);bool pstack__empty (const struct pstack *pstack);void pstack__remove (struct pstack *pstack,void *key);void pstack__push (struct pstack *pstack,void *key); -void *pstack__pop (struct pstack *pstack);void *pstack__peek (struct pstack *pstack);#endif /* _PERF_PSTACK_ */
Signature · 1 line
2.48.1
PATCH 4/6 perf util: Remove unused perf_data__update_dir
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
perf_data__update_dir() was added in 2019's
commit e8be135751f2 ("perf data: Add perf_data__update_dir() function") but has never been used.
Remove it.
--- tools/perf/util/data.c | 20 -------------------- tools/perf/util/data.h | 1 - 2 files changed, 21 deletions(-)
tools/perf/util/data.c +0 -20
@@ -158,26 +158,6 @@ int perf_data__open_dir(struct perf_data *data)return ret; } -int perf_data__update_dir (struct perf_data *data) -{ -int i; - -if (WARN_ON (!data->is_dir)) -return -EINVAL ; - -for (i =0 ; i < data->dir.nr; i++) { -struct perf_data_file *file = &data->dir.files[i]; -struct stat st; - -if (fstat (file->fd, &st)) -return -1 ; - - file->size = st.st_size; - } - -return 0 ; -} -static bool check_pipe (struct perf_data *data) {struct stat st;
tools/perf/util/data.h +0 -1
@@ -97,7 +97,6 @@ int perf_data__switch(struct perf_data *data,int perf_data__create_dir (struct perf_data *data,int nr);int perf_data__open_dir (struct perf_data *data);void perf_data__close_dir (struct perf_data *data); -int perf_data__update_dir (struct perf_data *data);unsigned long perf_data__size (struct perf_data *data);int perf_data__make_kcore_dir (struct perf_data *data,char *buf,size_t buf_sz);bool has_kcore_dir (const char *path);
Signature · 1 line
2.48.1
PATCH 5/6 perf util: Remove unused perf_pmus__default_pmu_name
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
perf_pmus__default_pmu_name() last use was removed by 2023's commit e3edd6cf6399 ("perf pmu-events: Reduce processed events by passing PMU")
Remove it.
--- tools/perf/util/pmus.c | 29 ----------------------------- tools/perf/util/pmus.h | 1 - 2 files changed, 30 deletions(-)
tools/perf/util/pmus.c +0 -29
@@ -714,35 +714,6 @@ bool perf_pmus__supports_extended_type(void)return perf_pmus__do_support_extended_type; } -char *perf_pmus__default_pmu_name (void ) -{ -int fd; -struct io_dir dir; -struct io_dirent64 *dent; -char *result =NULL ; - -if (!list_empty (&core_pmus)) - return strdup(list_first_entry(&core_pmus, struct perf_pmu, list)->name); - - fd =perf_pmu__event_source_devices_fd (); -if (fd <0 ) -return strdup ("cpu" ); - -io_dir__init (&dir, fd); - -while ((dent =io_dir__readdir (&dir)) !=NULL ) { -if (!strcmp (dent->d_name,"." ) || !strcmp (dent->d_name,".." )) -continue ; -if (is_pmu_core (dent->d_name)) { - result =strdup (dent->d_name); -break ; - } - } - -close (fd); -return result ?:strdup ("cpu" ); -} -struct perf_pmu *evsel__find_pmu (const struct evsel *evsel) {struct perf_pmu *pmu = evsel->pmu;
tools/perf/util/pmus.h +0 -1
@@ -27,7 +27,6 @@ void perf_pmus__print_raw_pmu_events(const struct print_callbacks *print_cb, voibool perf_pmus__have_event (const char *pname,const char *name);int perf_pmus__num_core_pmus (void );bool perf_pmus__supports_extended_type (void ); -char *perf_pmus__default_pmu_name (void );struct perf_pmu *perf_pmus__add_test_pmu (int test_sysfs_dirfd,const char *name); struct perf_pmu *perf_pmus__add_test_hwmon_pmu(int hwmon_dir,
Signature · 1 line
2.48.1
PATCH 6/6 perf util: Remove unused perf_config__refresh
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
perf_config__refresh() was added in 2016 by
commit 8a0a9c7e9146 ("perf config: Introduce new init() and exit()") but has remained unused.
Remove it.
--- tools/perf/util/config.c | 6 ------ tools/perf/util/config.h | 1 - 2 files changed, 7 deletions(-)
tools/perf/util/config.c +0 -6
@@ -856,12 +856,6 @@ void perf_config__exit(void) config_set =NULL ; } -void perf_config__refresh (void ) -{ -perf_config__exit (); -perf_config__init (); -} -static void perf_config_item__delete (struct perf_config_item *item) {zfree (&item->name);
tools/perf/util/config.h +0 -1
@@ -49,7 +49,6 @@ void perf_config_set__delete(struct perf_config_set *set);int perf_config_set__collect (struct perf_config_set *set,const char *file_name,const char *var,const char *value);void perf_config__exit (void ); -void perf_config__refresh (void );int perf_config__set_variable (const char *var,const char *value);/**
Signature · 1 line
2.48.1
Quoted 8 lines · On Tue, Mar 4, 2025 at 6:32 PM <[email protected]> wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is another set of perf deadcode, this is my set
all starting with 'p'. It was built on top of perf-tools-next as of a few days ago (7788ad59d1d9).
Quoted 8 lines
Dave
Signed-off-by Dr. David Alan Gilbert <[email protected]>Dr. David Alan Gilbert (6):
perf core: Removeperf_event_attrsandperf_event_refresh
This will need to go into tip.git.
Quoted 5 lines
perf util: Remove unused
perf_color_default_configperf util: Remove unusedpstack__pop
perf util: Remove unusedperf_data__update_dirperf util: Remove unusedperf_pmus__default_pmu_nameperf util: Remove unusedperf_config__refresh
Thanks,
Ian
Quoted 17 lines
include/linux/perf_event.h | 10 ---------- kernel/events/core.c | 24 ------------------------ tools/perf/util/color.h | 5 ----- tools/perf/util/color_config.c | 11 ----------- tools/perf/util/config.c | 6 ------ tools/perf/util/config.h | 1 - tools/perf/util/data.c | 20 -------------------- tools/perf/util/data.h | 1 - tools/perf/util/pmus.c | 29 ----------------------------- tools/perf/util/pmus.h | 1 - tools/perf/util/pstack.c | 14 -------------- tools/perf/util/pstack.h | 1 - 12 files changed, 123 deletions(-)--
2.48.1
Quoted 1 line · * Ian Rogers ([email protected]) wrote:
On Tue, Mar 4, 2025 at 6:32 PM <[email protected]> wrote:
Hi Ian,
Thanks for the review,
Quoted 9 lines
Quoted 9 lines
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is another set of perf deadcode, this is my set
all starting with 'p'. It was built on top of perf-tools-next as of a few days ago (7788ad59d1d9).Dave
Quoted 8 lines
Quoted 6 lines
Signed-off-by Dr. David Alan Gilbert <[email protected]>Dr. David Alan Gilbert (6):
perf core: Removeperf_event_attrsandperf_event_refreshThis will need to go into tip.git.
OK, do I need to split that out of the series, resend or do anything else?
Quoted 7 lines
Quoted 5 lines
perf util: Remove unused
perf_color_default_configperf util: Remove unusedpstack__pop
perf util: Remove unusedperf_data__update_dirperf util: Remove unusedperf_pmus__default_pmu_nameperf util: Remove unusedperf_config__refreshReviewed-by Ian Rogers <[email protected]>
Thanks,
Dave
Quoted 21 lines
Thanks,
IanQuoted 17 lines
include/linux/perf_event.h | 10 ---------- kernel/events/core.c | 24 ------------------------ tools/perf/util/color.h | 5 ----- tools/perf/util/color_config.c | 11 ----------- tools/perf/util/config.c | 6 ------ tools/perf/util/config.h | 1 - tools/perf/util/data.c | 20 -------------------- tools/perf/util/data.h | 1 - tools/perf/util/pmus.c | 29 ----------------------------- tools/perf/util/pmus.h | 1 - tools/perf/util/pstack.c | 14 -------------- tools/perf/util/pstack.h | 1 - 12 files changed, 123 deletions(-)--
2.48.1
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 |_______/
Re: (subset) [PATCH 0/6] perf: Deadcode - the P's
In reply to [email protected]Quoted 8 lines · On Wed, 05 Mar 2025 02:31:14 +0000, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is another set of perf deadcode, this is my set
all starting with 'p'. It was built on top of perf-tools-next as of a few days ago (7788ad59d1d9).[...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung