* [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 13:40 ` kernel test robot
2023-05-02 18:07 ` kernel test robot
0 siblings, 2 replies; 10+ messages in thread
From: Ajay Kaher @ 2023-05-02 11:23 UTC (permalink / raw)
To: rostedt, mhiramat, shuah
Cc: linux-kernel, linux-trace-kernel, linux-kselftest, chinglinyu,
namit, srivatsab, srivatsa, amakhalov, vsirnapalli, tkundu,
er.ajay.kaher, Ajay Kaher
Till now /sys/kernel/debug/tracing/events is a part of tracefs,
with-in this patch creating 'events' and it's sub-dir as eventfs.
Basically replacing tracefs calls with eventfs calls for 'events'.
Signed-off-by: Ajay Kaher <akaher@vmware.com>
Co-developed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Tested-by: Ching-lin Yu <chinglinyu@google.com>
---
fs/tracefs/inode.c | 18 ++++++++++
include/linux/trace_events.h | 1 +
kernel/trace/trace.h | 2 +-
kernel/trace/trace_events.c | 66 +++++++++++++++++++-----------------
4 files changed, 55 insertions(+), 32 deletions(-)
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 76820d3e9..a098d7153 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -374,6 +374,23 @@ static const struct super_operations tracefs_super_operations = {
.show_options = tracefs_show_options,
};
+static void tracefs_dentry_iput(struct dentry *dentry, struct inode *inode)
+{
+ struct tracefs_inode *ti;
+
+ if (!dentry || !inode)
+ return;
+
+ ti = get_tracefs(inode);
+ if (ti && ti->flags & TRACEFS_EVENT_INODE)
+ eventfs_set_ef_status_free(dentry);
+ iput(inode);
+}
+
+static const struct dentry_operations tracefs_dentry_operations = {
+ .d_iput = tracefs_dentry_iput,
+};
+
static int trace_fill_super(struct super_block *sb, void *data, int silent)
{
static const struct tree_descr trace_files[] = {{""}};
@@ -396,6 +413,7 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent)
goto fail;
sb->s_op = &tracefs_super_operations;
+ sb->s_d_op = &tracefs_dentry_operations;
tracefs_apply_options(sb, false);
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 0e373222a..696843d46 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -635,6 +635,7 @@ struct trace_event_file {
struct list_head list;
struct trace_event_call *event_call;
struct event_filter __rcu *filter;
+ struct eventfs_file *ef;
struct dentry *dir;
struct trace_array *tr;
struct trace_subsystem_dir *system;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 3726725c8..ee9002852 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1308,7 +1308,7 @@ struct trace_subsystem_dir {
struct list_head list;
struct event_subsystem *subsystem;
struct trace_array *tr;
- struct dentry *entry;
+ struct eventfs_file *ef;
int ref_count;
int nr_events;
};
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 654ffa404..01bd3dda6 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -988,7 +988,8 @@ static void remove_subsystem(struct trace_subsystem_dir *dir)
return;
if (!--dir->nr_events) {
- tracefs_remove(dir->entry);
+ if (dir->ef)
+ eventfs_remove(dir->ef);
list_del(&dir->list);
__put_system_dir(dir);
}
@@ -1009,7 +1010,8 @@ static void remove_event_file_dir(struct trace_event_file *file)
tracefs_remove(dir);
}
-
+ if (file->ef)
+ eventfs_remove(file->ef);
list_del(&file->list);
remove_subsystem(file->system);
free_event_filter(file->filter);
@@ -2295,13 +2297,13 @@ create_new_subsystem(const char *name)
return NULL;
}
-static struct dentry *
+static struct eventfs_file *
event_subsystem_dir(struct trace_array *tr, const char *name,
struct trace_event_file *file, struct dentry *parent)
{
struct event_subsystem *system, *iter;
struct trace_subsystem_dir *dir;
- struct dentry *entry;
+ int res;
/* First see if we did not already create this dir */
list_for_each_entry(dir, &tr->systems, list) {
@@ -2309,7 +2311,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
if (strcmp(system->name, name) == 0) {
dir->nr_events++;
file->system = dir;
- return dir->entry;
+ return dir->ef;
}
}
@@ -2333,8 +2335,8 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
} else
__get_system(system);
- dir->entry = tracefs_create_dir(name, parent);
- if (!dir->entry) {
+ dir->ef = eventfs_add_subsystem_dir(name, parent, &tr->eventfs_rwsem);
+ if (IS_ERR(dir->ef)) {
pr_warn("Failed to create system directory %s\n", name);
__put_system(system);
goto out_free;
@@ -2349,22 +2351,22 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
/* the ftrace system is special, do not create enable or filter files */
if (strcmp(name, "ftrace") != 0) {
- entry = tracefs_create_file("filter", TRACE_MODE_WRITE,
- dir->entry, dir,
+ res = eventfs_add_file("filter", TRACE_MODE_WRITE,
+ dir->ef, dir,
&ftrace_subsystem_filter_fops);
- if (!entry) {
+ if (res) {
kfree(system->filter);
system->filter = NULL;
pr_warn("Could not create tracefs '%s/filter' entry\n", name);
}
- trace_create_file("enable", TRACE_MODE_WRITE, dir->entry, dir,
+ eventfs_add_file("enable", TRACE_MODE_WRITE, dir->ef, dir,
&ftrace_system_enable_fops);
}
list_add(&dir->list, &tr->systems);
- return dir->entry;
+ return dir->ef;
out_free:
kfree(dir);
@@ -2418,6 +2420,7 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
{
struct trace_event_call *call = file->event_call;
struct trace_array *tr = file->tr;
+ struct eventfs_file *ef_subsystem = NULL;
struct dentry *d_events;
const char *name;
int ret;
@@ -2427,26 +2430,26 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
* then the system would be called "TRACE_SYSTEM".
*/
if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
- d_events = event_subsystem_dir(tr, call->class->system, file, parent);
- if (!d_events)
+ ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
+ if (!ef_subsystem)
return -ENOMEM;
} else
d_events = parent;
name = trace_event_name(call);
- file->dir = tracefs_create_dir(name, d_events);
- if (!file->dir) {
+ file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem);
+ if (IS_ERR(file->ef)) {
pr_warn("Could not create tracefs '%s' directory\n", name);
return -1;
}
if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
- trace_create_file("enable", TRACE_MODE_WRITE, file->dir, file,
+ eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file,
&ftrace_enable_fops);
#ifdef CONFIG_PERF_EVENTS
if (call->event.type && call->class->reg)
- trace_create_file("id", TRACE_MODE_READ, file->dir,
+ eventfs_add_file("id", TRACE_MODE_READ, file->ef,
(void *)(long)call->event.type,
&ftrace_event_id_fops);
#endif
@@ -2462,27 +2465,27 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
* triggers or filters.
*/
if (!(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) {
- trace_create_file("filter", TRACE_MODE_WRITE, file->dir,
+ eventfs_add_file("filter", TRACE_MODE_WRITE, file->ef,
file, &ftrace_event_filter_fops);
- trace_create_file("trigger", TRACE_MODE_WRITE, file->dir,
+ eventfs_add_file("trigger", TRACE_MODE_WRITE, file->ef,
file, &event_trigger_fops);
}
#ifdef CONFIG_HIST_TRIGGERS
- trace_create_file("hist", TRACE_MODE_READ, file->dir, file,
+ eventfs_add_file("hist", TRACE_MODE_READ, file->ef, file,
&event_hist_fops);
#endif
#ifdef CONFIG_HIST_TRIGGERS_DEBUG
- trace_create_file("hist_debug", TRACE_MODE_READ, file->dir, file,
+ eventfs_add_file("hist_debug", TRACE_MODE_READ, file->ef, file,
&event_hist_debug_fops);
#endif
- trace_create_file("format", TRACE_MODE_READ, file->dir, call,
+ eventfs_add_file("format", TRACE_MODE_READ, file->ef, call,
&ftrace_event_format_fops);
#ifdef CONFIG_TRACE_EVENT_INJECT
if (call->event.type && call->class->reg)
- trace_create_file("inject", 0200, file->dir, file,
+ eventfs_add_file("inject", 0200, file->ef, file,
&event_inject_fops);
#endif
@@ -3635,21 +3638,22 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr)
{
struct dentry *d_events;
struct dentry *entry;
+ int error = 0;
entry = trace_create_file("set_event", TRACE_MODE_WRITE, parent,
tr, &ftrace_set_event_fops);
if (!entry)
return -ENOMEM;
- d_events = tracefs_create_dir("events", parent);
- if (!d_events) {
+ d_events = eventfs_create_events_dir("events", parent, &tr->eventfs_rwsem);
+ if (IS_ERR(d_events)) {
pr_warn("Could not create tracefs 'events' directory\n");
return -ENOMEM;
}
- entry = trace_create_file("enable", TRACE_MODE_WRITE, d_events,
+ error = eventfs_add_top_file("enable", TRACE_MODE_WRITE, d_events,
tr, &ftrace_tr_enable_fops);
- if (!entry)
+ if (error)
return -ENOMEM;
/* There are not as crucial, just warn if they are not created */
@@ -3662,11 +3666,11 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr)
&ftrace_set_event_notrace_pid_fops);
/* ring buffer internal formats */
- trace_create_file("header_page", TRACE_MODE_READ, d_events,
+ eventfs_add_top_file("header_page", TRACE_MODE_READ, d_events,
ring_buffer_print_page_header,
&ftrace_show_header_fops);
- trace_create_file("header_event", TRACE_MODE_READ, d_events,
+ eventfs_add_top_file("header_event", TRACE_MODE_READ, d_events,
ring_buffer_print_entry_header,
&ftrace_show_header_fops);
@@ -3754,7 +3758,7 @@ int event_trace_del_tracer(struct trace_array *tr)
down_write(&trace_event_sem);
__trace_remove_event_dirs(tr);
- tracefs_remove(tr->event_dir);
+ eventfs_remove_events_dir(tr->event_dir);
up_write(&trace_event_sem);
tr->event_dir = NULL;
--
2.39.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
@ 2023-05-02 13:40 ` kernel test robot
2023-05-02 18:07 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-05-02 13:40 UTC (permalink / raw)
To: Ajay Kaher, rostedt, mhiramat, shuah
Cc: oe-kbuild-all, linux-kernel, linux-trace-kernel, linux-kselftest,
chinglinyu, namit, srivatsab, srivatsa, amakhalov, vsirnapalli,
tkundu, er.ajay.kaher, Ajay Kaher
Hi Ajay,
kernel test robot noticed the following build warnings:
[auto build test WARNING on shuah-kselftest/next]
[also build test WARNING on shuah-kselftest/fixes linus/master]
[cannot apply to rostedt-trace/for-next-urgent]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ajay-Kaher/eventfs-introducing-struct-tracefs_inode/20230502-192949
base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
patch link: https://lore.kernel.org/r/1683026600-13485-9-git-send-email-akaher%40vmware.com
patch subject: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20230502/202305022138.cJMVU9RM-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/2fe2002efb23a715f5eb7a58891ff85f4e37b084
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ajay-Kaher/eventfs-introducing-struct-tracefs_inode/20230502-192949
git checkout 2fe2002efb23a715f5eb7a58891ff85f4e37b084
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash kernel/trace/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305022138.cJMVU9RM-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/trace/trace_events.c: In function 'event_create_dir':
>> kernel/trace/trace_events.c:2424:24: warning: variable 'd_events' set but not used [-Wunused-but-set-variable]
2424 | struct dentry *d_events;
| ^~~~~~~~
vim +/d_events +2424 kernel/trace/trace_events.c
ac343da7bc9048 Masami Hiramatsu 2020-09-10 2417
1473e4417c79f1 Steven Rostedt 2009-02-24 2418 static int
7f1d2f8210195c Steven Rostedt (Red Hat 2015-05-05 2419) event_create_dir(struct dentry *parent, struct trace_event_file *file)
1473e4417c79f1 Steven Rostedt 2009-02-24 2420 {
2425bcb9240f8c Steven Rostedt (Red Hat 2015-05-05 2421) struct trace_event_call *call = file->event_call;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2422 struct trace_array *tr = file->tr;
2fe2002efb23a7 Ajay Kaher 2023-05-02 2423 struct eventfs_file *ef_subsystem = NULL;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 @2424 struct dentry *d_events;
de7b2973903c6c Mathieu Desnoyers 2014-04-08 2425 const char *name;
fd99498989f3b3 Steven Rostedt 2009-02-28 2426 int ret;
1473e4417c79f1 Steven Rostedt 2009-02-24 2427
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2428 /*
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2429 * If the trace point header did not define TRACE_SYSTEM
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2430 * then the system would be called "TRACE_SYSTEM".
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2431 */
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2432 if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
2fe2002efb23a7 Ajay Kaher 2023-05-02 2433 ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2434 if (!ef_subsystem)
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2435 return -ENOMEM;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2436 } else
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2438
687fcc4aee4567 Steven Rostedt (Red Hat 2015-05-13 2439) name = trace_event_name(call);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2440 file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2441 if (IS_ERR(file->ef)) {
8434dc9340cd2e Steven Rostedt (Red Hat 2015-01-20 2442) pr_warn("Could not create tracefs '%s' directory\n", name);
1473e4417c79f1 Steven Rostedt 2009-02-24 2443 return -1;
1473e4417c79f1 Steven Rostedt 2009-02-24 2444 }
1473e4417c79f1 Steven Rostedt 2009-02-24 2445
9b63776fa3ca96 Steven Rostedt 2012-05-10 2446 if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
2fe2002efb23a7 Ajay Kaher 2023-05-02 2447 eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file,
620a30e97febc8 Oleg Nesterov 2013-07-31 2448 &ftrace_enable_fops);
1473e4417c79f1 Steven Rostedt 2009-02-24 2449
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
2023-05-02 13:40 ` kernel test robot
@ 2023-05-02 18:07 ` kernel test robot
2023-05-09 12:29 ` Ajay Kaher
1 sibling, 1 reply; 10+ messages in thread
From: kernel test robot @ 2023-05-02 18:07 UTC (permalink / raw)
To: Ajay Kaher, rostedt, mhiramat, shuah
Cc: llvm, oe-kbuild-all, linux-kernel, linux-trace-kernel,
linux-kselftest, chinglinyu, namit, srivatsab, srivatsa,
amakhalov, vsirnapalli, tkundu, er.ajay.kaher, Ajay Kaher
Hi Ajay,
kernel test robot noticed the following build warnings:
[auto build test WARNING on shuah-kselftest/next]
[also build test WARNING on shuah-kselftest/fixes linus/master v6.3 next-20230428]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ajay-Kaher/eventfs-introducing-struct-tracefs_inode/20230502-192949
base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
patch link: https://lore.kernel.org/r/1683026600-13485-9-git-send-email-akaher%40vmware.com
patch subject: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
config: i386-randconfig-a011-20230501 (https://download.01.org/0day-ci/archive/20230503/202305030116.Gu6yyvKj-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/2fe2002efb23a715f5eb7a58891ff85f4e37b084
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ajay-Kaher/eventfs-introducing-struct-tracefs_inode/20230502-192949
git checkout 2fe2002efb23a715f5eb7a58891ff85f4e37b084
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash kernel/trace/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305030116.Gu6yyvKj-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/trace/trace_events.c:2424:17: warning: variable 'd_events' set but not used [-Wunused-but-set-variable]
struct dentry *d_events;
^
1 warning generated.
vim +/d_events +2424 kernel/trace/trace_events.c
ac343da7bc9048 Masami Hiramatsu 2020-09-10 2417
1473e4417c79f1 Steven Rostedt 2009-02-24 2418 static int
7f1d2f8210195c Steven Rostedt (Red Hat 2015-05-05 2419) event_create_dir(struct dentry *parent, struct trace_event_file *file)
1473e4417c79f1 Steven Rostedt 2009-02-24 2420 {
2425bcb9240f8c Steven Rostedt (Red Hat 2015-05-05 2421) struct trace_event_call *call = file->event_call;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2422 struct trace_array *tr = file->tr;
2fe2002efb23a7 Ajay Kaher 2023-05-02 2423 struct eventfs_file *ef_subsystem = NULL;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 @2424 struct dentry *d_events;
de7b2973903c6c Mathieu Desnoyers 2014-04-08 2425 const char *name;
fd99498989f3b3 Steven Rostedt 2009-02-28 2426 int ret;
1473e4417c79f1 Steven Rostedt 2009-02-24 2427
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2428 /*
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2429 * If the trace point header did not define TRACE_SYSTEM
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2430 * then the system would be called "TRACE_SYSTEM".
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2431 */
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2432 if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
2fe2002efb23a7 Ajay Kaher 2023-05-02 2433 ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2434 if (!ef_subsystem)
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2435 return -ENOMEM;
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2436 } else
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
6ecc2d1ca39177 Steven Rostedt 2009-02-27 2438
687fcc4aee4567 Steven Rostedt (Red Hat 2015-05-13 2439) name = trace_event_name(call);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2440 file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem);
2fe2002efb23a7 Ajay Kaher 2023-05-02 2441 if (IS_ERR(file->ef)) {
8434dc9340cd2e Steven Rostedt (Red Hat 2015-01-20 2442) pr_warn("Could not create tracefs '%s' directory\n", name);
1473e4417c79f1 Steven Rostedt 2009-02-24 2443 return -1;
1473e4417c79f1 Steven Rostedt 2009-02-24 2444 }
1473e4417c79f1 Steven Rostedt 2009-02-24 2445
9b63776fa3ca96 Steven Rostedt 2012-05-10 2446 if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
2fe2002efb23a7 Ajay Kaher 2023-05-02 2447 eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file,
620a30e97febc8 Oleg Nesterov 2013-07-31 2448 &ftrace_enable_fops);
1473e4417c79f1 Steven Rostedt 2009-02-24 2449
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-02 18:07 ` kernel test robot
@ 2023-05-09 12:29 ` Ajay Kaher
2023-05-09 16:45 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Ajay Kaher @ 2023-05-09 12:29 UTC (permalink / raw)
To: kernel test robot, rostedt@goodmis.org, mhiramat@kernel.org,
shuah@kernel.org
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, Srivatsa Bhat, srivatsa@csail.mit.edu,
Alexey Makhalov, Vasavi Sirnapalli, Tapas Kundu,
er.ajay.kaher@gmail.com
> On 02/05/23, 11:42 PM, "kernel test robot" <lkp@intel.com> wrote:
> >> kernel/trace/trace_events.c:2424:17: warning: variable 'd_events' set but not used [-Wunused-but-set-variable]
> struct dentry *d_events;
> ^
> 1 warning generated.
>
Steve, with-in event_create_dir(), do we have any scenario when file->event_call->class->system
doesn't have TRACE_SYSTEM? And need to execute following:
ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
looking for your input if we could remove d_events from event_create_dir().
- Ajay
> vim +/d_events +2424 kernel/trace/trace_events.c
>
> ac343da7bc9048 Masami Hiramatsu 2020-09-10 2417
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2418 static int
> 7f1d2f8210195c Steven Rostedt (Red Hat 2015-05-05 2419) event_create_dir(struct dentry *parent, struct trace_event_file *file)
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2420 {
> 2425bcb9240f8c Steven Rostedt (Red Hat 2015-05-05 2421) struct trace_event_call *call = file->event_call;
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2422 struct trace_array *tr = file->tr;
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2423 struct eventfs_file *ef_subsystem = NULL;
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 @2424 struct dentry *d_events;
> de7b2973903c6c Mathieu Desnoyers 2014-04-08 2425 const char *name;
> fd99498989f3b3 Steven Rostedt 2009-02-28 2426 int ret;
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2427
> 6ecc2d1ca39177 Steven Rostedt 2009-02-27 2428 /*
> 6ecc2d1ca39177 Steven Rostedt 2009-02-27 2429 * If the trace point header did not define TRACE_SYSTEM
> 6ecc2d1ca39177 Steven Rostedt 2009-02-27 2430 * then the system would be called "TRACE_SYSTEM".
> 6ecc2d1ca39177 Steven Rostedt 2009-02-27 2431 */
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2432 if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2433 ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2434 if (!ef_subsystem)
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2435 return -ENOMEM;
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2436 } else
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
> 6ecc2d1ca39177 Steven Rostedt 2009-02-27 2438
> 687fcc4aee4567 Steven Rostedt (Red Hat 2015-05-13 2439) name = trace_event_name(call);
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2440 file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem);
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2441 if (IS_ERR(file->ef)) {
> 8434dc9340cd2e Steven Rostedt (Red Hat 2015-01-20 2442) pr_warn("Could not create tracefs '%s' directory\n", name);
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2443 return -1;
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2444 }
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2445
> 9b63776fa3ca96 Steven Rostedt 2012-05-10 2446 if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
> 2fe2002efb23a7 Ajay Kaher 2023-05-02 2447 eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file,
> 620a30e97febc8 Oleg Nesterov 2013-07-31 2448 &ftrace_enable_fops);
> 1473e4417c79f1 Steven Rostedt 2009-02-24 2449
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-09 12:29 ` Ajay Kaher
@ 2023-05-09 16:45 ` Steven Rostedt
2023-05-10 11:11 ` Ajay Kaher
0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2023-05-09 16:45 UTC (permalink / raw)
To: Ajay Kaher
Cc: kernel test robot, mhiramat@kernel.org, shuah@kernel.org,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, Srivatsa Bhat, srivatsa@csail.mit.edu,
Alexey Makhalov, Vasavi Sirnapalli, Tapas Kundu,
er.ajay.kaher@gmail.com
On Tue, 9 May 2023 12:29:23 +0000
Ajay Kaher <akaher@vmware.com> wrote:
> > On 02/05/23, 11:42 PM, "kernel test robot" <lkp@intel.com> wrote:
> > >> kernel/trace/trace_events.c:2424:17: warning: variable 'd_events' set but not used [-Wunused-but-set-variable]
> > struct dentry *d_events;
> > ^
> > 1 warning generated.
> >
>
> Steve, with-in event_create_dir(), do we have any scenario when file->event_call->class->system
> doesn't have TRACE_SYSTEM? And need to execute following:
>
> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
>
> looking for your input if we could remove d_events from event_create_dir().
>
I have hit this in the beginning, but I don't think it's an issue
anymore. Perhaps just have it be:
if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0))
return -ENODEV;
ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
Hmm, how about just add this patch before your patch set:
-- Steve
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH] tracing: Require all trace events to have a TRACE_SYSTEM
The creation of the trace event directory requires that a TRACE_SYSTEM is
defined that the trace event directory is added within the system it was
defined in.
The code handled the case where a TRACE_SYSTEM was not added, and would
then add the event at the events directory. But nothing should be doing
this. This code also prevents the implementation of creating dynamic
dentrys for the eventfs system.
As this path has never been hit on correct code, remove it. If it does get
hit, issues a WARN_ON_ONCE() and return ENODEV.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
(lightly tested)
kernel/trace/trace_events.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 654ffa40457a..16bc5ba45507 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2424,14 +2424,15 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
/*
* If the trace point header did not define TRACE_SYSTEM
- * then the system would be called "TRACE_SYSTEM".
+ * then the system would be called "TRACE_SYSTEM". This should
+ * never happen.
*/
- if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
- d_events = event_subsystem_dir(tr, call->class->system, file, parent);
- if (!d_events)
- return -ENOMEM;
- } else
- d_events = parent;
+ if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0))
+ return -ENODEV;
+
+ d_events = event_subsystem_dir(tr, call->class->system, file, parent);
+ if (!d_events)
+ return -ENOMEM;
name = trace_event_name(call);
file->dir = tracefs_create_dir(name, d_events);
--
2.39.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-09 16:45 ` Steven Rostedt
@ 2023-05-10 11:11 ` Ajay Kaher
2023-05-12 22:59 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Ajay Kaher @ 2023-05-10 11:11 UTC (permalink / raw)
To: Steven Rostedt
Cc: kernel test robot, mhiramat@kernel.org, shuah@kernel.org,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, Srivatsa Bhat, srivatsa@csail.mit.edu,
Alexey Makhalov, Vasavi Sirnapalli, Tapas Kundu,
er.ajay.kaher@gmail.com
> On 09-May-2023, at 10:15 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> !! External Email
>
> On Tue, 9 May 2023 12:29:23 +0000
> Ajay Kaher <akaher@vmware.com> wrote:
>
>> > On 02/05/23, 11:42 PM, "kernel test robot" <lkp@intel.com> wrote:
>>>>> kernel/trace/trace_events.c:2424:17: warning: variable 'd_events' set but not used [-Wunused-but-set-variable]
>>> struct dentry *d_events;
>>> ^
>>> 1 warning generated.
>>>
>>
>> Steve, with-in event_create_dir(), do we have any scenario when file->event_call->class->system
>> doesn't have TRACE_SYSTEM? And need to execute following:
>>
>> ae63b31e4d0e2e Steven Rostedt 2012-05-03 2437 d_events = parent;
>>
>> looking for your input if we could remove d_events from event_create_dir().
>>
>
> I have hit this in the beginning, but I don't think it's an issue
> anymore. Perhaps just have it be:
>
> if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0))
> return -ENODEV;
>
> ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent);
>
> Hmm, how about just add this patch before your patch set:
>
Sounds good. Thanks Steve :)
Once you will merge below patch, I will rebase this patch in v3.
- Ajay
>
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> Subject: [PATCH] tracing: Require all trace events to have a TRACE_SYSTEM
>
> The creation of the trace event directory requires that a TRACE_SYSTEM is
> defined that the trace event directory is added within the system it was
> defined in.
>
> The code handled the case where a TRACE_SYSTEM was not added, and would
> then add the event at the events directory. But nothing should be doing
> this. This code also prevents the implementation of creating dynamic
> dentrys for the eventfs system.
>
> As this path has never been hit on correct code, remove it. If it does get
> hit, issues a WARN_ON_ONCE() and return ENODEV.
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>
> (lightly tested)
>
> kernel/trace/trace_events.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 654ffa40457a..16bc5ba45507 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -2424,14 +2424,15 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file)
>
> /*
> * If the trace point header did not define TRACE_SYSTEM
> - * then the system would be called "TRACE_SYSTEM".
> + * then the system would be called "TRACE_SYSTEM". This should
> + * never happen.
> */
> - if (strcmp(call->class->system, TRACE_SYSTEM) != 0) {
> - d_events = event_subsystem_dir(tr, call->class->system, file, parent);
> - if (!d_events)
> - return -ENOMEM;
> - } else
> - d_events = parent;
> + if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0))
> + return -ENODEV;
> +
> + d_events = event_subsystem_dir(tr, call->class->system, file, parent);
> + if (!d_events)
> + return -ENOMEM;
>
> name = trace_event_name(call);
> file->dir = tracefs_create_dir(name, d_events);
> --
> 2.39.2
>
>
> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-10 11:11 ` Ajay Kaher
@ 2023-05-12 22:59 ` Steven Rostedt
2023-05-15 11:35 ` Ajay Kaher
0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2023-05-12 22:59 UTC (permalink / raw)
To: Ajay Kaher
Cc: kernel test robot, mhiramat@kernel.org, shuah@kernel.org,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, Srivatsa Bhat, srivatsa@csail.mit.edu,
Alexey Makhalov, Vasavi Sirnapalli, Tapas Kundu,
er.ajay.kaher@gmail.com
On Wed, 10 May 2023 11:11:15 +0000
Ajay Kaher <akaher@vmware.com> wrote:
> Sounds good. Thanks Steve :)
> Once you will merge below patch, I will rebase this patch in v3.
Feel free to just add it at the start of your queue. You just need to
keep the "From" line and it will be added as my patch.
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-12 22:59 ` Steven Rostedt
@ 2023-05-15 11:35 ` Ajay Kaher
0 siblings, 0 replies; 10+ messages in thread
From: Ajay Kaher @ 2023-05-15 11:35 UTC (permalink / raw)
To: Steven Rostedt
Cc: kernel test robot, mhiramat@kernel.org, shuah@kernel.org,
llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, srivatsa@csail.mit.edu, Alexey Makhalov,
Vasavi Sirnapalli, Tapas Kundu, er.ajay.kaher@gmail.com
> On 13-May-2023, at 4:29 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> !! External Email
>
> On Wed, 10 May 2023 11:11:15 +0000
> Ajay Kaher <akaher@vmware.com> wrote:
>
>> Sounds good. Thanks Steve :)
>> Once you will merge below patch, I will rebase this patch in v3.
>
> Feel free to just add it at the start of your queue. You just need to
> keep the "From" line and it will be added as my patch.
Ok, I will include in v3.
-Ajay
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
[not found] <202305051619.9a469a9a-yujie.liu@intel.com>
@ 2023-05-17 12:40 ` Ajay Kaher
2023-05-17 14:14 ` Steven Rostedt
0 siblings, 1 reply; 10+ messages in thread
From: Ajay Kaher @ 2023-05-17 12:40 UTC (permalink / raw)
To: yujie.liu
Cc: akaher, amakhalov, chinglinyu, er.ajay.kaher, linux-kernel,
linux-kselftest, linux-trace-kernel, lkp, mhiramat, namit, oe-lkp,
rostedt, shuah, srivatsa, srivatsab, tkundu, vsirnapalli
> kernel test robot noticed "WARNING:at_fs/namei.c:#lookup_one_len" on:
>
> commit: 2fe2002efb23a715f5eb7a58891ff85f4e37b084 ("[PATCH v2 8/9] eventfs: moving tracing/events to eventfs")
> url: https://github.com/intel-lab-lkp/linux/commits/Ajay-Kaher/eventfs-introducing-struct-tracefs_inode/20230502-192949
> base: https://git.kernel.org/cgit/linux/kernel/git/shuah/linux-kselftest.git next
> patch link: https://lore.kernel.org/all/1683026600-13485-9-git-send-email-akaher@vmware.com/
> patch subject: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
.
.
.
> 49.752082][ T5878] eventfs_start_creating (fs/tracefs/inode.c:519)
> [ 49.757416][ T5878] eventfs_create_dir (fs/tracefs/event_inode.c:187 (discriminator 3))
> [ 49.762488][ T5878] eventfs_root_lookup (fs/tracefs/event_inode.c:291)
> [ 49.767637][ T5878] __lookup_slow (fs/namei.c:1686)
> [ 49.772268][ T5878] walk_component (include/linux/fs.h:773 fs/namei.c:1704 fs/namei.c:1994)
> [ 49.777016][ T5878] link_path_walk+0x24e/0x3b0
> [ 49.783462][ T5878] ? path_init (fs/namei.c:2387)
> [ 49.788021][ T5878] path_openat (fs/namei.c:3711)
> [ 49.792463][ T5878] do_filp_open (fs/namei.c:3742)
> [ 49.797021][ T5878] ? __check_object_size (mm/memremap.c:107 mm/memremap.c:144)
> [ 49.803055][ T5878] do_sys_openat2 (fs/open.c:1348)
> [ 49.807740][ T5878] __x64_sys_openat (fs/open.c:1375)
> [ 49.812512][ T5878] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
> [ 49.817068][ T5878] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
> [ 49.823092][ T5878] RIP: 0033:0x7fcddb3b84e7
Steve, locally I have reproduced this issue using:
lkp run job-cpu-100%-uprobe-60s.yaml
And also fixed, I will include this fix as well in v3.
Thanks to lkp, kernel test robot <yujie.liu@intel.com>.
-Ajay
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-17 12:40 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
@ 2023-05-17 14:14 ` Steven Rostedt
0 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2023-05-17 14:14 UTC (permalink / raw)
To: Ajay Kaher
Cc: yujie.liu, amakhalov, chinglinyu, er.ajay.kaher, linux-kernel,
linux-kselftest, linux-trace-kernel, lkp, mhiramat, namit, oe-lkp,
shuah, srivatsa, srivatsab, tkundu, vsirnapalli
On Wed, 17 May 2023 18:10:07 +0530
Ajay Kaher <akaher@vmware.com> wrote:
> Steve, locally I have reproduced this issue using:
> lkp run job-cpu-100%-uprobe-60s.yaml
>
> And also fixed, I will include this fix as well in v3.
Great. Thanks Ajay!
-- Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-05-17 14:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <202305051619.9a469a9a-yujie.liu@intel.com>
2023-05-17 12:40 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
2023-05-17 14:14 ` Steven Rostedt
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
2023-05-02 13:40 ` kernel test robot
2023-05-02 18:07 ` kernel test robot
2023-05-09 12:29 ` Ajay Kaher
2023-05-09 16:45 ` Steven Rostedt
2023-05-10 11:11 ` Ajay Kaher
2023-05-12 22:59 ` Steven Rostedt
2023-05-15 11:35 ` Ajay Kaher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox