* [PATCH v2 0/9] tracing: introducing eventfs
@ 2023-05-02 11:23 Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 1/9] eventfs: introducing struct tracefs_inode Ajay Kaher
` (8 more replies)
0 siblings, 9 replies; 23+ 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
Events Tracing infrastructure contains lot of files, directories
(internally in terms of inodes, dentries). And ends up by consuming
memory in MBs. We can have multiple events of Events Tracing, which
further requires more memory.
Instead of creating inodes/dentries, eventfs could keep meta-data and
skip the creation of inodes/dentries. As and when require, eventfs will
create the inodes/dentries only for required files/directories.
Also eventfs would delete the inodes/dentries once no more requires
but preserve the meta data.
Tracing events took ~9MB, with this approach it took ~4.5MB
for ~10K files/dir.
Diff from v1:
Patch 1: add header file
Patch 2: resolved kernel test robot issues
protecting eventfs lists using nested eventfs_rwsem
Patch 3: protecting eventfs lists using nested eventfs_rwsem
Patch 4: improve events cleanup code to fix crashes
Patch 5: resolved kernel test robot issues
removed d_instantiate_anon() calls
Patch 6: resolved kernel test robot issues
fix kprobe test in eventfs_root_lookup()
protecting eventfs lists using nested eventfs_rwsem
Patch 7: remove header file
Patch 8: pass eventfs_rwsem as argument to eventfs functions
called eventfs_remove_events_dir() instead of tracefs_remove()
from event_trace_del_tracer()
Patch 9: new patch to fix kprobe test case
fs/tracefs/Makefile | 1 +
fs/tracefs/event_inode.c | 761 ++++++++++++++++++
fs/tracefs/inode.c | 124 ++-
fs/tracefs/internal.h | 25 +
include/linux/trace_events.h | 1 +
include/linux/tracefs.h | 49 ++
kernel/trace/trace.h | 3 +-
kernel/trace/trace_events.c | 66 +-
.../ftrace/test.d/kprobe/kprobe_args_char.tc | 4 +-
.../test.d/kprobe/kprobe_args_string.tc | 4 +-
10 files changed, 992 insertions(+), 46 deletions(-)
create mode 100644 fs/tracefs/event_inode.c
create mode 100644 fs/tracefs/internal.h
--
2.39.0
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v2 1/9] eventfs: introducing struct tracefs_inode
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 2/9] eventfs: adding eventfs dir add functions Ajay Kaher
` (7 subsequent siblings)
8 siblings, 0 replies; 23+ 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
Introducing tracefs_inode structure, this will help eventfs
to keep track of inode, flags and pointer to private date.
Renaming, removing static property from some function name.
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 | 21 +++++++++++----------
fs/tracefs/internal.h | 25 +++++++++++++++++++++++++
2 files changed, 36 insertions(+), 10 deletions(-)
create mode 100644 fs/tracefs/internal.h
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 57ac8aa4a..7df1752e8 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -21,6 +21,7 @@
#include <linux/parser.h>
#include <linux/magic.h>
#include <linux/slab.h>
+#include "internal.h"
#define TRACEFS_DEFAULT_MODE 0700
@@ -127,7 +128,7 @@ static const struct inode_operations tracefs_dir_inode_operations = {
.rmdir = tracefs_syscall_rmdir,
};
-static struct inode *tracefs_get_inode(struct super_block *sb)
+struct inode *tracefs_get_inode(struct super_block *sb)
{
struct inode *inode = new_inode(sb);
if (inode) {
@@ -399,7 +400,7 @@ static struct file_system_type trace_fs_type = {
};
MODULE_ALIAS_FS("tracefs");
-static struct dentry *start_creating(const char *name, struct dentry *parent)
+struct dentry *tracefs_start_creating(const char *name, struct dentry *parent)
{
struct dentry *dentry;
int error;
@@ -437,7 +438,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
return dentry;
}
-static struct dentry *failed_creating(struct dentry *dentry)
+struct dentry *tracefs_failed_creating(struct dentry *dentry)
{
inode_unlock(d_inode(dentry->d_parent));
dput(dentry);
@@ -445,7 +446,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
return NULL;
}
-static struct dentry *end_creating(struct dentry *dentry)
+struct dentry *tracefs_end_creating(struct dentry *dentry)
{
inode_unlock(d_inode(dentry->d_parent));
return dentry;
@@ -490,14 +491,14 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
if (!(mode & S_IFMT))
mode |= S_IFREG;
BUG_ON(!S_ISREG(mode));
- dentry = start_creating(name, parent);
+ dentry = tracefs_start_creating(name, parent);
if (IS_ERR(dentry))
return NULL;
inode = tracefs_get_inode(dentry->d_sb);
if (unlikely(!inode))
- return failed_creating(dentry);
+ return tracefs_failed_creating(dentry);
inode->i_mode = mode;
inode->i_fop = fops ? fops : &tracefs_file_operations;
@@ -506,13 +507,13 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
inode->i_gid = d_inode(dentry->d_parent)->i_gid;
d_instantiate(dentry, inode);
fsnotify_create(d_inode(dentry->d_parent), dentry);
- return end_creating(dentry);
+ return tracefs_end_creating(dentry);
}
static struct dentry *__create_dir(const char *name, struct dentry *parent,
const struct inode_operations *ops)
{
- struct dentry *dentry = start_creating(name, parent);
+ struct dentry *dentry = tracefs_start_creating(name, parent);
struct inode *inode;
if (IS_ERR(dentry))
@@ -520,7 +521,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
inode = tracefs_get_inode(dentry->d_sb);
if (unlikely(!inode))
- return failed_creating(dentry);
+ return tracefs_failed_creating(dentry);
/* Do not set bits for OTH */
inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
@@ -534,7 +535,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
d_instantiate(dentry, inode);
inc_nlink(d_inode(dentry->d_parent));
fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
- return end_creating(dentry);
+ return tracefs_end_creating(dentry);
}
/**
diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h
new file mode 100644
index 000000000..6776b4693
--- /dev/null
+++ b/fs/tracefs/internal.h
@@ -0,0 +1,25 @@
+#ifndef _TRACEFS_INTERNAL_H
+#define _TRACEFS_INTERNAL_H
+
+enum {
+ TRACEFS_EVENT_INODE = BIT(1),
+};
+
+struct tracefs_inode {
+ unsigned long flags;
+ void *private;
+ struct inode vfs_inode;
+};
+
+static inline struct tracefs_inode *get_tracefs(const struct inode *inode)
+{
+ return container_of(inode, struct tracefs_inode, vfs_inode);
+}
+
+struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);
+struct dentry *tracefs_end_creating(struct dentry *dentry);
+struct dentry *tracefs_failed_creating(struct dentry *dentry);
+struct inode *tracefs_get_inode(struct super_block *sb);
+
+#endif /* _TRACEFS_INTERNAL_H */
+
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 2/9] eventfs: adding eventfs dir add functions
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 1/9] eventfs: introducing struct tracefs_inode Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-08 9:32 ` Zheng Yejian
2023-05-02 11:23 ` [PATCH v2 3/9] eventfs: adding eventfs file " Ajay Kaher
` (6 subsequent siblings)
8 siblings, 1 reply; 23+ 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
Adding eventfs_file structure which will hold properties of file or dir.
Adding following functions to add dir in eventfs:
eventfs_create_events_dir() will directly create events dir with-in
tracing folder.
eventfs_add_subsystem_dir() will adds the info of subsystem_dir to
eventfs and dynamically create subsystem_dir as and when requires.
eventfs_add_dir() will add the info of dir (which is with-in
subsystem_dir) to eventfs and dynamically create these dir as
and when requires.
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/Makefile | 1 +
fs/tracefs/event_inode.c | 252 +++++++++++++++++++++++++++++++++++++++
include/linux/tracefs.h | 29 +++++
kernel/trace/trace.h | 1 +
4 files changed, 283 insertions(+)
create mode 100644 fs/tracefs/event_inode.c
diff --git a/fs/tracefs/Makefile b/fs/tracefs/Makefile
index 7c35a282b..73c56da8e 100644
--- a/fs/tracefs/Makefile
+++ b/fs/tracefs/Makefile
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
tracefs-objs := inode.o
+tracefs-objs += event_inode.o
obj-$(CONFIG_TRACING) += tracefs.o
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
new file mode 100644
index 000000000..82caba7e9
--- /dev/null
+++ b/fs/tracefs/event_inode.c
@@ -0,0 +1,252 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * event_inode.c - part of tracefs, a pseudo file system for activating tracing
+ *
+ * Copyright (C) 2020-22 VMware Inc, author: Steven Rostedt (VMware) <rostedt@goodmis.org>
+ * Copyright (C) 2020-22 VMware Inc, author: Ajay Kaher <akaher@vmware.com>
+ *
+ * eventfs is used to show trace events with one set of dentries
+ *
+ * eventfs stores meta-data of files/dirs and skip to create object of
+ * inodes/dentries. As and when requires, eventfs will create the
+ * inodes/dentries for only required files/directories. Also eventfs
+ * would delete the inodes/dentries once no more requires but preserve
+ * the meta data.
+ */
+#include <linux/fsnotify.h>
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/security.h>
+#include <linux/tracefs.h>
+#include <linux/kref.h>
+#include <linux/delay.h>
+#include "internal.h"
+
+/**
+ * eventfs_dentry_to_rwsem - Return corresponding eventfs_rwsem
+ * @dentry: a pointer to dentry
+ *
+ * helper function to return crossponding eventfs_rwsem for given dentry
+ */
+static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry)
+{
+ if (S_ISDIR(dentry->d_inode->i_mode))
+ return (struct rw_semaphore *)dentry->d_inode->i_private;
+ else
+ return (struct rw_semaphore *)dentry->d_parent->d_inode->i_private;
+}
+
+/**
+ * eventfs_down_read - acquire read lock function
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * helper function to perform read lock, skip locking if caller task already
+ * own the lock. read lock requires for lookup(), release() and these also
+ * called with-in open(), remove() which already hold the read/write lock.
+ */
+static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem)
+{
+ down_read_nested(eventfs_rwsem, SINGLE_DEPTH_NESTING);
+}
+
+/**
+ * eventfs_up_read - release read lock function
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * helper function to release eventfs_rwsem lock if locked
+ */
+static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem)
+{
+ up_read(eventfs_rwsem);
+}
+
+/**
+ * eventfs_down_write - acquire write lock function
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * helper function to perform write lock on eventfs_rwsem
+ */
+static void eventfs_down_write(struct rw_semaphore *eventfs_rwsem)
+{
+ while (!down_write_trylock(eventfs_rwsem))
+ msleep(10);
+}
+
+/**
+ * eventfs_up_write - release write lock function
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * helper function to perform write lock on eventfs_rwsem
+ */
+static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem)
+{
+ up_write(eventfs_rwsem);
+}
+
+static const struct file_operations eventfs_file_operations = {
+};
+
+static const struct inode_operations eventfs_root_dir_inode_operations = {
+};
+
+/**
+ * eventfs_create_events_dir - create the trace event structure
+ * @name: a pointer to a string containing the name of the directory to
+ * create.
+ * @parent: a pointer to the parent dentry for this file. This should be a
+ * directory dentry if set. If this parameter is NULL, then the
+ * directory will be created in the root of the tracefs filesystem.
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * This function creates the top of the trace event directory.
+ */
+struct dentry *eventfs_create_events_dir(const char *name,
+ struct dentry *parent,
+ struct rw_semaphore *eventfs_rwsem)
+{
+ struct dentry *dentry = tracefs_start_creating(name, parent);
+ struct eventfs_inode *ei;
+ struct tracefs_inode *ti;
+ struct inode *inode;
+
+ if (IS_ERR(dentry))
+ return dentry;
+
+ ei = kzalloc(sizeof(*ei), GFP_KERNEL);
+ if (!ei)
+ return ERR_PTR(-ENOMEM);
+ inode = tracefs_get_inode(dentry->d_sb);
+ if (unlikely(!inode)) {
+ kfree(ei);
+ tracefs_failed_creating(dentry);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ init_rwsem(eventfs_rwsem);
+ INIT_LIST_HEAD(&ei->e_top_files);
+
+ ti = get_tracefs(inode);
+ ti->flags |= TRACEFS_EVENT_INODE;
+ ti->private = ei;
+
+ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
+ inode->i_op = &eventfs_root_dir_inode_operations;
+ inode->i_fop = &eventfs_file_operations;
+ inode->i_private = eventfs_rwsem;
+
+ /* directory inodes start off with i_nlink == 2 (for "." entry) */
+ inc_nlink(inode);
+ d_instantiate(dentry, inode);
+ inc_nlink(dentry->d_parent->d_inode);
+ fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
+ return tracefs_end_creating(dentry);
+}
+
+/**
+ * eventfs_add_subsystem_dir - add eventfs subsystem_dir to list to create later
+ * @name: a pointer to a string containing the name of the file to create.
+ * @parent: a pointer to the parent dentry for this dir.
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * This function adds eventfs subsystem dir to list.
+ * And all these dirs are created on the fly when they are looked up,
+ * and the dentry and inodes will be removed when they are done.
+ */
+struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
+ struct dentry *parent,
+ struct rw_semaphore *eventfs_rwsem)
+{
+ struct tracefs_inode *ti_parent;
+ struct eventfs_inode *ei_parent;
+ struct eventfs_file *ef;
+
+ if (!parent)
+ return ERR_PTR(-EINVAL);
+
+ ti_parent = get_tracefs(parent->d_inode);
+ ei_parent = ti_parent->private;
+
+ ef = kzalloc(sizeof(*ef), GFP_KERNEL);
+ if (!ef)
+ return ERR_PTR(-ENOMEM);
+
+ ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
+ if (!ef->ei) {
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ INIT_LIST_HEAD(&ef->ei->e_top_files);
+
+ ef->name = kstrdup(name, GFP_KERNEL);
+ if (!ef->name) {
+ kfree(ef->ei);
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
+ ef->iop = &eventfs_root_dir_inode_operations;
+ ef->fop = &eventfs_file_operations;
+ ef->dentry = NULL;
+ ef->created = false;
+ ef->d_parent = parent;
+ ef->data = eventfs_rwsem;
+
+ eventfs_down_write(eventfs_rwsem);
+ list_add_tail(&ef->list, &ei_parent->e_top_files);
+ eventfs_up_write(eventfs_rwsem);
+ return ef;
+}
+
+/**
+ * eventfs_add_dir - add eventfs dir to list to create later
+ * @name: a pointer to a string containing the name of the file to create.
+ * @ef_parent: a pointer to the parent eventfs_file for this dir.
+ * @eventfs_rwsem: a pointer to rw_semaphore
+ *
+ * This function adds eventfs dir to list.
+ * And all these dirs are created on the fly when they are looked up,
+ * and the dentry and inodes will be removed when they are done.
+ */
+struct eventfs_file *eventfs_add_dir(const char *name,
+ struct eventfs_file *ef_parent,
+ struct rw_semaphore *eventfs_rwsem)
+{
+ struct eventfs_file *ef;
+
+ if (!ef_parent)
+ return ERR_PTR(-EINVAL);
+
+ ef = kzalloc(sizeof(*ef), GFP_KERNEL);
+ if (!ef)
+ return ERR_PTR(-ENOMEM);
+
+ ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
+ if (!ef->ei) {
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ INIT_LIST_HEAD(&ef->ei->e_top_files);
+
+ ef->name = kstrdup(name, GFP_KERNEL);
+ if (!ef->name) {
+ kfree(ef->ei);
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
+ ef->iop = &eventfs_root_dir_inode_operations;
+ ef->fop = &eventfs_file_operations;
+ ef->created = false;
+ ef->dentry = NULL;
+ ef->d_parent = NULL;
+ ef->data = eventfs_rwsem;
+
+ eventfs_down_write(eventfs_rwsem);
+ list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
+ eventfs_up_write(eventfs_rwsem);
+ return ef;
+}
diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
index 999124459..aeca6761f 100644
--- a/include/linux/tracefs.h
+++ b/include/linux/tracefs.h
@@ -21,6 +21,35 @@ struct file_operations;
#ifdef CONFIG_TRACING
+struct eventfs_inode {
+ struct list_head e_top_files;
+};
+
+struct eventfs_file {
+ const char *name;
+ struct dentry *d_parent;
+ struct dentry *dentry;
+ struct list_head list;
+ struct eventfs_inode *ei;
+ const struct file_operations *fop;
+ const struct inode_operations *iop;
+ void *data;
+ umode_t mode;
+ bool created;
+};
+
+struct dentry *eventfs_create_events_dir(const char *name,
+ struct dentry *parent,
+ struct rw_semaphore *eventfs_rwsem);
+
+struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
+ struct dentry *parent,
+ struct rw_semaphore *eventfs_rwsem);
+
+struct eventfs_file *eventfs_add_dir(const char *name,
+ struct eventfs_file *ef_parent,
+ struct rw_semaphore *eventfs_rwsem);
+
struct dentry *tracefs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 616e1aa1c..3726725c8 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -359,6 +359,7 @@ struct trace_array {
struct dentry *options;
struct dentry *percpu_dir;
struct dentry *event_dir;
+ struct rw_semaphore eventfs_rwsem;
struct trace_options *topts;
struct list_head systems;
struct list_head events;
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 3/9] eventfs: adding eventfs file add functions
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 1/9] eventfs: introducing struct tracefs_inode Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 2/9] eventfs: adding eventfs dir add functions Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
` (5 subsequent siblings)
8 siblings, 0 replies; 23+ 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
Adding following function to eventfs to add files:
eventfs_add_top_file() will add the info of top file
to eventfs and dynamically create these files as and
when required.
eventfs_add_file() will add the info of nested files
to eventfs and dynamically create these dir as and
when required.
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/event_inode.c | 118 +++++++++++++++++++++++++++++++++++++++
include/linux/tracefs.h | 8 +++
2 files changed, 126 insertions(+)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 82caba7e9..93134ae40 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -250,3 +250,121 @@ struct eventfs_file *eventfs_add_dir(const char *name,
eventfs_up_write(eventfs_rwsem);
return ef;
}
+
+/**
+ * eventfs_add_top_file - add event top file to list to create later
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have.
+ * @parent: a pointer to the parent dentry for this file. This should be a
+ * directory dentry if set. If this parameter is NULL, then the
+ * file will be created in the root of the tracefs filesystem.
+ * @data: a pointer to something that the caller will want to get to later
+ * on. The inode.i_private pointer will point to this value on
+ * the open() call.
+ * @fop: a pointer to a struct file_operations that should be used for
+ * this file.
+ *
+ * This function adds top files of event dir to list.
+ * And all these files are created on the fly when they are looked up,
+ * and the dentry and inodes will be removed when they are done.
+ */
+int eventfs_add_top_file(const char *name, umode_t mode,
+ struct dentry *parent, void *data,
+ const struct file_operations *fop)
+{
+ struct tracefs_inode *ti;
+ struct eventfs_inode *ei;
+ struct eventfs_file *ef;
+ struct rw_semaphore *eventfs_rwsem;
+
+ if (!parent)
+ return -EINVAL;
+
+ if (!(mode & S_IFMT))
+ mode |= S_IFREG;
+
+ if (!parent->d_inode)
+ return -EINVAL;
+
+ ti = get_tracefs(parent->d_inode);
+ if (!(ti->flags & TRACEFS_EVENT_INODE))
+ return -EINVAL;
+
+ ei = ti->private;
+ ef = kzalloc(sizeof(*ef), GFP_KERNEL);
+ if (!ef)
+ return -ENOMEM;
+
+ ef->name = kstrdup(name, GFP_KERNEL);
+ if (!ef->name) {
+ kfree(ef);
+ return -ENOMEM;
+ }
+
+ ef->mode = mode;
+ ef->data = data;
+ ef->fop = fop;
+ ef->dentry = NULL;
+ ef->ei = NULL;
+ ef->created = false;
+ ef->d_parent = parent;
+
+ eventfs_rwsem = (struct rw_semaphore *) parent->d_inode->i_private;
+ eventfs_down_write(eventfs_rwsem);
+ list_add_tail(&ef->list, &ei->e_top_files);
+ eventfs_up_write(eventfs_rwsem);
+ return 0;
+}
+
+/**
+ * eventfs_add_file - add eventfs file to list to create later
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have.
+ * @ef_parent: a pointer to the parent eventfs_file for this file.
+ * @data: a pointer to something that the caller will want to get to later
+ * on. The inode.i_private pointer will point to this value on
+ * the open() call.
+ * @fop: a pointer to a struct file_operations that should be used for
+ * this file.
+ *
+ * This function adds top files of event dir to list.
+ * And all these files are created on the fly when they are looked up,
+ * and the dentry and inodes will be removed when they are done.
+ */
+int eventfs_add_file(const char *name, umode_t mode,
+ struct eventfs_file *ef_parent,
+ void *data,
+ const struct file_operations *fop)
+{
+ struct eventfs_file *ef;
+ struct rw_semaphore *eventfs_rwsem;
+
+ if (!ef_parent)
+ return -EINVAL;
+
+ if (!(mode & S_IFMT))
+ mode |= S_IFREG;
+
+ ef = kzalloc(sizeof(*ef), GFP_KERNEL);
+ if (!ef)
+ return -ENOMEM;
+
+ ef->name = kstrdup(name, GFP_KERNEL);
+ if (!ef->name) {
+ kfree(ef);
+ return -ENOMEM;
+ }
+
+ ef->mode = mode;
+ ef->data = data;
+ ef->fop = fop;
+ ef->dentry = NULL;
+ ef->ei = NULL;
+ ef->created = false;
+
+ eventfs_rwsem = (struct rw_semaphore *) ef_parent->data;
+ eventfs_down_write(eventfs_rwsem);
+ list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
+ eventfs_up_write(eventfs_rwsem);
+ return 0;
+}
diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
index aeca6761f..1e1780a61 100644
--- a/include/linux/tracefs.h
+++ b/include/linux/tracefs.h
@@ -50,6 +50,14 @@ struct eventfs_file *eventfs_add_dir(const char *name,
struct eventfs_file *ef_parent,
struct rw_semaphore *eventfs_rwsem);
+int eventfs_add_file(const char *name, umode_t mode,
+ struct eventfs_file *ef_parent, void *data,
+ const struct file_operations *fops);
+
+int eventfs_add_top_file(const char *name, umode_t mode,
+ struct dentry *parent, void *data,
+ const struct file_operations *fops);
+
struct dentry *tracefs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (2 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 3/9] eventfs: adding eventfs file " Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 14:21 ` kernel test robot
` (2 more replies)
2023-05-02 11:23 ` [PATCH v2 5/9] eventfs: adding functions to create eventfs files and directories Ajay Kaher
` (4 subsequent siblings)
8 siblings, 3 replies; 23+ 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
Adding eventfs_remove(), this function will recursively remove
dir or file info from eventfs.
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/event_inode.c | 78 ++++++++++++++++++++++++++++++++++++++++
include/linux/tracefs.h | 4 +++
2 files changed, 82 insertions(+)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 93134ae40..9ab675edf 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -368,3 +368,81 @@ int eventfs_add_file(const char *name, umode_t mode,
eventfs_up_write(eventfs_rwsem);
return 0;
}
+
+/**
+ * eventfs_remove_rec - remove eventfs dir or file from list
+ * @ef: a pointer to eventfs_file to be removed.
+ *
+ * This function recursively remove eventfs_file which
+ * contains info of file or dir.
+ */
+void eventfs_remove_rec(struct eventfs_file *ef)
+{
+ struct eventfs_file *ef_child, *n;
+
+ if (!ef)
+ return;
+
+ if (ef->ei) {
+ /* search for nested folders or files */
+ list_for_each_entry_safe(ef_child, n, &ef->ei->e_top_files, list) {
+ eventfs_remove_rec(ef_child);
+ }
+ kfree(ef->ei);
+ }
+
+ if (ef->created && ef->dentry) {
+ d_invalidate(ef->dentry);
+ dput(ef->dentry);
+ }
+ list_del(&ef->list);
+ kfree(ef->name);
+ kfree(ef);
+}
+
+/**
+ * eventfs_remove - remove eventfs dir or file from list
+ * @ef: a pointer to eventfs_file to be removed.
+ *
+ * This function acquire the eventfs_rwsem lock and call eventfs_remove_rec()
+ */
+void eventfs_remove(struct eventfs_file *ef)
+{
+ struct rw_semaphore *eventfs_rwsem;
+
+ if (!ef)
+ return;
+
+ if (ef->ei)
+ eventfs_rwsem = (struct rw_semaphore *) ef->data;
+ else
+ eventfs_rwsem = (struct rw_semaphore *) ef->d_parent->d_inode->i_private;
+
+ eventfs_down_write(eventfs_rwsem);
+ eventfs_remove_rec(ef);
+ eventfs_up_write(eventfs_rwsem);
+}
+
+/**
+ * eventfs_remove_events_dir - remove eventfs dir or file from list
+ * @dentry: a pointer to events's dentry to be removed.
+ *
+ * This function remove events main directory
+ */
+void eventfs_remove_events_dir(struct dentry *dentry)
+{
+ struct tracefs_inode *ti;
+ struct eventfs_inode *ei;
+
+ if (!dentry || !dentry->d_inode)
+ return;
+
+ ti = get_tracefs(dentry->d_inode);
+ if (!ti || !(ti->flags & TRACEFS_EVENT_INODE))
+ return;
+
+ ei = ti->private;
+ d_invalidate(dentry);
+ dput(dentry);
+ kfree(ei);
+}
diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
index 1e1780a61..ea10ccc87 100644
--- a/include/linux/tracefs.h
+++ b/include/linux/tracefs.h
@@ -58,6 +58,10 @@ int eventfs_add_top_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
+void eventfs_remove(struct eventfs_file *ef);
+
+void eventfs_remove_events_dir(struct dentry *dentry);
+
struct dentry *tracefs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 5/9] eventfs: adding functions to create eventfs files and directories
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (3 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 6/9] eventfs: adding eventfs lookup, read, open functions Ajay Kaher
` (3 subsequent siblings)
8 siblings, 0 replies; 23+ 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
Adding eventfs_create_file(), eventfs_create_dir()
to create file, dir at runtime as and when requires.
These function will be called either from lookup
of inode_operations or open of file_operations.
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/event_inode.c | 125 +++++++++++++++++++++++++++++++++++++++
fs/tracefs/inode.c | 47 +++++++++++++++
include/linux/tracefs.h | 6 ++
3 files changed, 178 insertions(+)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 9ab675edf..0ee27f7c8 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -83,6 +83,131 @@ static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem)
up_write(eventfs_rwsem);
}
+/**
+ * eventfs_create_file - create a file in the tracefs filesystem
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have.
+ * @parent: a pointer to the parent dentry for this file. This should be a
+ * directory dentry if set. If this parameter is NULL, then the
+ * file will be created in the root of the tracefs filesystem.
+ * @data: a pointer to something that the caller will want to get to later
+ * on. The inode.i_private pointer will point to this value on
+ * the open() call.
+ * @fop: a pointer to a struct file_operations that should be used for
+ * this file.
+ *
+ * This is the basic "create a file" function for tracefs. It allows for a
+ * wide range of flexibility in creating a file.
+ *
+ * This function will return a pointer to a dentry if it succeeds. This
+ * pointer must be passed to the tracefs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.) If an error occurs, %NULL will be returned.
+ *
+ * If tracefs is not enabled in the kernel, the value -%ENODEV will be
+ * returned.
+ */
+static struct dentry *eventfs_create_file(const char *name, umode_t mode,
+ struct dentry *parent, void *data,
+ const struct file_operations *fop)
+{
+ struct tracefs_inode *ti;
+ struct dentry *dentry;
+ struct inode *inode;
+
+ if (security_locked_down(LOCKDOWN_TRACEFS))
+ return NULL;
+
+ if (!(mode & S_IFMT))
+ mode |= S_IFREG;
+
+ if (WARN_ON_ONCE(!S_ISREG(mode)))
+ return NULL;
+
+ dentry = eventfs_start_creating(name, parent);
+
+ if (IS_ERR(dentry))
+ return dentry;
+
+ inode = tracefs_get_inode(dentry->d_sb);
+ if (unlikely(!inode))
+ return eventfs_failed_creating(dentry);
+
+ inode->i_mode = mode;
+ inode->i_fop = fop;
+ inode->i_private = data;
+
+ ti = get_tracefs(inode);
+ ti->flags |= TRACEFS_EVENT_INODE;
+ d_instantiate(dentry, inode);
+ fsnotify_create(dentry->d_parent->d_inode, dentry);
+ return eventfs_end_creating(dentry);
+}
+
+/**
+ * eventfs_create_dir - create a dir in the tracefs filesystem
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have.
+ * @parent: a pointer to the parent dentry for this file. This should be a
+ * directory dentry if set. If this parameter is NULL, then the
+ * file will be created in the root of the tracefs filesystem.
+ * @data: a pointer to something that the caller will want to get to later
+ * on. The inode.i_private pointer will point to this value on
+ * the open() call.
+ * @fop: a pointer to a struct file_operations that should be used for
+ * this dir.
+ * @iop: a pointer to a struct inode_operations that should be used for
+ * this dir.
+ *
+ * This is the basic "create a dir" function for eventfs. It allows for a
+ * wide range of flexibility in creating a dir.
+ *
+ * This function will return a pointer to a dentry if it succeeds. This
+ * pointer must be passed to the tracefs_remove() function when the file is
+ * to be removed (no automatic cleanup happens if your module is unloaded,
+ * you are responsible here.) If an error occurs, %NULL will be returned.
+ *
+ * If tracefs is not enabled in the kernel, the value -%ENODEV will be
+ * returned.
+ */
+static struct dentry *eventfs_create_dir(const char *name, umode_t mode,
+ struct dentry *parent, void *data,
+ const struct file_operations *fop,
+ const struct inode_operations *iop)
+{
+ struct tracefs_inode *ti;
+ struct dentry *dentry;
+ struct inode *inode;
+
+ if (security_locked_down(LOCKDOWN_TRACEFS))
+ return NULL;
+
+ WARN_ON(!S_ISDIR(mode));
+
+ dentry = eventfs_start_creating(name, parent);
+
+ if (IS_ERR(dentry))
+ return dentry;
+
+ inode = tracefs_get_inode(dentry->d_sb);
+ if (unlikely(!inode))
+ return eventfs_failed_creating(dentry);
+
+ inode->i_mode = mode;
+ inode->i_op = iop;
+ inode->i_fop = fop;
+ inode->i_private = data;
+
+ ti = get_tracefs(inode);
+ ti->flags |= TRACEFS_EVENT_INODE;
+
+ inc_nlink(inode);
+ d_instantiate(dentry, inode);
+ inc_nlink(dentry->d_parent->d_inode);
+ fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
+ return eventfs_end_creating(dentry);
+}
+
static const struct file_operations eventfs_file_operations = {
};
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 7df1752e8..66c4df734 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -452,6 +452,53 @@ struct dentry *tracefs_end_creating(struct dentry *dentry)
return dentry;
}
+struct dentry *eventfs_start_creating(const char *name, struct dentry *parent)
+{
+ struct dentry *dentry;
+ int error;
+
+ error = simple_pin_fs(&trace_fs_type, &tracefs_mount,
+ &tracefs_mount_count);
+ if (error)
+ return ERR_PTR(error);
+
+ /*
+ * If the parent is not specified, we create it in the root.
+ * We need the root dentry to do this, which is in the super
+ * block. A pointer to that is in the struct vfsmount that we
+ * have around.
+ */
+ if (!parent)
+ parent = tracefs_mount->mnt_root;
+
+ if (unlikely(IS_DEADDIR(parent->d_inode)))
+ dentry = ERR_PTR(-ENOENT);
+ else
+ dentry = lookup_one_len(name, parent, strlen(name));
+
+ if (!IS_ERR(dentry) && dentry->d_inode) {
+ dput(dentry);
+ dentry = ERR_PTR(-EEXIST);
+ }
+
+ if (IS_ERR(dentry))
+ simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+
+ return dentry;
+}
+
+struct dentry *eventfs_failed_creating(struct dentry *dentry)
+{
+ dput(dentry);
+ simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ return NULL;
+}
+
+struct dentry *eventfs_end_creating(struct dentry *dentry)
+{
+ return dentry;
+}
+
/**
* tracefs_create_file - create a file in the tracefs filesystem
* @name: a pointer to a string containing the name of the file to create.
diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
index ea10ccc87..57bfd1322 100644
--- a/include/linux/tracefs.h
+++ b/include/linux/tracefs.h
@@ -38,6 +38,12 @@ struct eventfs_file {
bool created;
};
+struct dentry *eventfs_start_creating(const char *name, struct dentry *parent);
+
+struct dentry *eventfs_failed_creating(struct dentry *dentry);
+
+struct dentry *eventfs_end_creating(struct dentry *dentry);
+
struct dentry *eventfs_create_events_dir(const char *name,
struct dentry *parent,
struct rw_semaphore *eventfs_rwsem);
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 6/9] eventfs: adding eventfs lookup, read, open functions
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (4 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 5/9] eventfs: adding functions to create eventfs files and directories Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 7/9] eventfs: creating tracefs_inode_cache Ajay Kaher
` (2 subsequent siblings)
8 siblings, 0 replies; 23+ 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
Adding following functions to eventfs:
eventfs_set_ef_status_free()
eventfs_post_create_dir()
eventfs_root_lookup()
eventfs_release()
dcache_dir_open_wrapper()
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/event_inode.c | 188 +++++++++++++++++++++++++++++++++++++++
include/linux/tracefs.h | 2 +
2 files changed, 190 insertions(+)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 0ee27f7c8..f047e45ed 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -208,10 +208,198 @@ static struct dentry *eventfs_create_dir(const char *name, umode_t mode,
return eventfs_end_creating(dentry);
}
+/**
+ * eventfs_set_ef_status_free - set the ef->status to free
+ * @dentry: dentry who's status to be freed
+ *
+ * eventfs_set_ef_status_free will be called if no more
+ * reference remains
+ */
+void eventfs_set_ef_status_free(struct dentry *dentry)
+{
+ struct tracefs_inode *ti_parent;
+ struct eventfs_file *ef;
+
+ ti_parent = get_tracefs(dentry->d_parent->d_inode);
+ if (!ti_parent || !(ti_parent->flags & TRACEFS_EVENT_INODE))
+ return;
+
+ ef = dentry->d_fsdata;
+ if (!ef)
+ return;
+ ef->created = false;
+ ef->dentry = NULL;
+}
+
+/**
+ * eventfs_post_create_dir - post create dir routine
+ * @ef: eventfs_file of recently created dir
+ *
+ * Files with-in eventfs dir should know dentry of parent dir
+ */
+static void eventfs_post_create_dir(struct eventfs_file *ef)
+{
+ struct eventfs_file *ef_child;
+ struct tracefs_inode *ti;
+
+ eventfs_down_read((struct rw_semaphore *) ef->data);
+ /* fill parent-child relation */
+ list_for_each_entry(ef_child, &ef->ei->e_top_files, list) {
+ ef_child->d_parent = ef->dentry;
+ }
+ eventfs_up_read((struct rw_semaphore *) ef->data);
+
+ ti = get_tracefs(ef->dentry->d_inode);
+ ti->private = ef->ei;
+}
+
+/**
+ * eventfs_root_lookup - lookup routine to create file/dir
+ * @dir: directory in which lookup to be done
+ * @dentry: file/dir dentry
+ * @flags:
+ *
+ * Used to create dynamic file/dir with-in @dir, search with-in ei
+ * list, if @dentry found go ahead and create the file/dir
+ */
+
+static struct dentry *eventfs_root_lookup(struct inode *dir,
+ struct dentry *dentry,
+ unsigned int flags)
+{
+ struct tracefs_inode *ti;
+ struct eventfs_inode *ei;
+ struct eventfs_file *ef;
+ struct dentry *ret = NULL;
+ struct rw_semaphore *eventfs_rwsem;
+
+ ti = get_tracefs(dir);
+ if (!(ti->flags & TRACEFS_EVENT_INODE))
+ return NULL;
+
+ ei = ti->private;
+ eventfs_rwsem = (struct rw_semaphore *) dir->i_private;
+ eventfs_down_read(eventfs_rwsem);
+ list_for_each_entry(ef, &ei->e_top_files, list) {
+ if (strcmp(ef->name, dentry->d_name.name))
+ continue;
+ ret = simple_lookup(dir, dentry, flags);
+ if (ef->created)
+ continue;
+ ef->created = true;
+ if (ef->ei)
+ ef->dentry = eventfs_create_dir(ef->name, ef->mode, ef->d_parent,
+ ef->data, ef->fop, ef->iop);
+ else
+ ef->dentry = eventfs_create_file(ef->name, ef->mode, ef->d_parent,
+ ef->data, ef->fop);
+
+ if (IS_ERR_OR_NULL(ef->dentry)) {
+ ef->created = false;
+ } else {
+ if (ef->ei)
+ eventfs_post_create_dir(ef);
+ ef->dentry->d_fsdata = ef;
+ dput(ef->dentry);
+ }
+ break;
+ }
+ eventfs_up_read(eventfs_rwsem);
+ return ret;
+}
+
+/**
+ * eventfs_release - called to release eventfs file/dir
+ * @inode: inode to be released
+ * @file: file to be released (not used)
+ */
+static int eventfs_release(struct inode *inode, struct file *file)
+{
+ struct tracefs_inode *ti;
+ struct eventfs_inode *ei;
+ struct eventfs_file *ef;
+ struct dentry *dentry = file_dentry(file);
+ struct rw_semaphore *eventfs_rwsem;
+
+ ti = get_tracefs(inode);
+ if (!(ti->flags & TRACEFS_EVENT_INODE))
+ return -EINVAL;
+
+ ei = ti->private;
+ eventfs_rwsem = eventfs_dentry_to_rwsem(dentry);
+ eventfs_down_read(eventfs_rwsem);
+ list_for_each_entry(ef, &ei->e_top_files, list) {
+ if (ef->created)
+ dput(ef->dentry);
+ }
+ eventfs_up_read(eventfs_rwsem);
+ return dcache_dir_close(inode, file);
+}
+
+/**
+ * dcache_dir_open_wrapper - eventfs open wrapper
+ * @inode: not used
+ * @file: dir to be opened (to create it's child)
+ *
+ * Used to dynamic create file/dir with-in @file, all the
+ * file/dir will be created. If already created then reference
+ * will be increased
+ */
+static int dcache_dir_open_wrapper(struct inode *inode, struct file *file)
+{
+ struct tracefs_inode *ti;
+ struct eventfs_inode *ei;
+ struct eventfs_file *ef;
+ struct inode *f_inode = file_inode(file);
+ struct dentry *dentry = file_dentry(file);
+ struct rw_semaphore *eventfs_rwsem;
+
+ ti = get_tracefs(f_inode);
+ if (!(ti->flags & TRACEFS_EVENT_INODE))
+ return -EINVAL;
+
+ ei = ti->private;
+ eventfs_rwsem = eventfs_dentry_to_rwsem(dentry);
+ eventfs_down_read(eventfs_rwsem);
+ list_for_each_entry(ef, &ei->e_top_files, list) {
+ if (ef->created) {
+ dget(ef->dentry);
+ continue;
+ }
+
+ ef->created = true;
+
+ inode_lock(dentry->d_inode);
+ if (ef->ei)
+ ef->dentry = eventfs_create_dir(ef->name, ef->mode, dentry,
+ ef->data, ef->fop, ef->iop);
+ else
+ ef->dentry = eventfs_create_file(ef->name, ef->mode, dentry,
+ ef->data, ef->fop);
+ inode_unlock(dentry->d_inode);
+
+ if (IS_ERR_OR_NULL(ef->dentry)) {
+ ef->created = false;
+ } else {
+ if (ef->ei)
+ eventfs_post_create_dir(ef);
+ ef->dentry->d_fsdata = ef;
+ }
+ }
+ eventfs_up_read(eventfs_rwsem);
+ return dcache_dir_open(inode, file);
+}
+
static const struct file_operations eventfs_file_operations = {
+ .open = dcache_dir_open_wrapper,
+ .read = generic_read_dir,
+ .iterate_shared = dcache_readdir,
+ .llseek = generic_file_llseek,
+ .release = eventfs_release,
};
static const struct inode_operations eventfs_root_dir_inode_operations = {
+ .lookup = eventfs_root_lookup,
};
/**
diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
index 57bfd1322..268450d60 100644
--- a/include/linux/tracefs.h
+++ b/include/linux/tracefs.h
@@ -68,6 +68,8 @@ void eventfs_remove(struct eventfs_file *ef);
void eventfs_remove_events_dir(struct dentry *dentry);
+void eventfs_set_ef_status_free(struct dentry *dentry);
+
struct dentry *tracefs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 7/9] eventfs: creating tracefs_inode_cache
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (5 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 6/9] eventfs: adding eventfs lookup, read, open functions Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 9/9] test: ftrace: fix kprobe test for eventfs Ajay Kaher
8 siblings, 0 replies; 23+ 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
Creating tracefs_inode_cache which is a cache of tracefs_inode.
Adding helping functions:
tracefs_alloc_inode()
tracefs_free_inode()
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 | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 66c4df734..76820d3e9 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -24,11 +24,30 @@
#include "internal.h"
#define TRACEFS_DEFAULT_MODE 0700
+static struct kmem_cache *tracefs_inode_cachep __ro_after_init;
static struct vfsmount *tracefs_mount;
static int tracefs_mount_count;
static bool tracefs_registered;
+static struct inode *tracefs_alloc_inode(struct super_block *sb)
+{
+ struct tracefs_inode *ti;
+
+ ti = kmem_cache_alloc(tracefs_inode_cachep, GFP_KERNEL);
+ if (!ti)
+ return NULL;
+
+ ti->flags = 0;
+
+ return &ti->vfs_inode;
+}
+
+static void tracefs_free_inode(struct inode *inode)
+{
+ kmem_cache_free(tracefs_inode_cachep, get_tracefs(inode));
+}
+
static ssize_t default_read_file(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
@@ -347,6 +366,9 @@ static int tracefs_show_options(struct seq_file *m, struct dentry *root)
}
static const struct super_operations tracefs_super_operations = {
+ .alloc_inode = tracefs_alloc_inode,
+ .free_inode = tracefs_free_inode,
+ .drop_inode = generic_delete_inode,
.statfs = simple_statfs,
.remount_fs = tracefs_remount,
.show_options = tracefs_show_options,
@@ -676,10 +698,26 @@ bool tracefs_initialized(void)
return tracefs_registered;
}
+static void init_once(void *foo)
+{
+ struct tracefs_inode *ti = (struct tracefs_inode *) foo;
+
+ inode_init_once(&ti->vfs_inode);
+}
+
static int __init tracefs_init(void)
{
int retval;
+ tracefs_inode_cachep = kmem_cache_create("tracefs_inode_cache",
+ sizeof(struct tracefs_inode),
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD|
+ SLAB_ACCOUNT),
+ init_once);
+ if (!tracefs_inode_cachep)
+ return -ENOMEM;
+
retval = sysfs_create_mount_point(kernel_kobj, "tracing");
if (retval)
return -EINVAL;
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v2 8/9] eventfs: moving tracing/events to eventfs
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (6 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 7/9] eventfs: creating tracefs_inode_cache 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
2023-05-02 11:23 ` [PATCH v2 9/9] test: ftrace: fix kprobe test for eventfs Ajay Kaher
8 siblings, 2 replies; 23+ 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] 23+ messages in thread
* [PATCH v2 9/9] test: ftrace: fix kprobe test for eventfs
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
` (7 preceding siblings ...)
2023-05-02 11:23 ` [PATCH v2 8/9] eventfs: moving tracing/events to eventfs Ajay Kaher
@ 2023-05-02 11:23 ` Ajay Kaher
8 siblings, 0 replies; 23+ 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
kprobe_args_char.tc, kprobe_args_string.tc has validation check
for tracefs_create_dir, for eventfs it should be eventfs_create_dir.
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>
---
.../selftests/ftrace/test.d/kprobe/kprobe_args_char.tc | 4 ++--
.../selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc
index 285b4770e..523cfb645 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc
@@ -34,14 +34,14 @@ mips*)
esac
: "Test get argument (1)"
-echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):char" > kprobe_events
+echo "p:testprobe eventfs_add_dir arg1=+0(${ARG1}):char" > kprobe_events
echo 1 > events/kprobes/testprobe/enable
echo "p:test $FUNCTION_FORK" >> kprobe_events
grep -qe "testprobe.* arg1='t'" trace
echo 0 > events/kprobes/testprobe/enable
: "Test get argument (2)"
-echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):char arg2=+0(${ARG1}):char[4]" > kprobe_events
+echo "p:testprobe eventfs_add_dir arg1=+0(${ARG1}):char arg2=+0(${ARG1}):char[4]" > kprobe_events
echo 1 > events/kprobes/testprobe/enable
echo "p:test $FUNCTION_FORK" >> kprobe_events
grep -qe "testprobe.* arg1='t' arg2={'t','e','s','t'}" trace
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
index a4f8e7c53..b9f8c3f8b 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
@@ -37,14 +37,14 @@ loongarch*)
esac
: "Test get argument (1)"
-echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events
+echo "p:testprobe eventfs_add_dir arg1=+0(${ARG1}):string" > kprobe_events
echo 1 > events/kprobes/testprobe/enable
echo "p:test $FUNCTION_FORK" >> kprobe_events
grep -qe "testprobe.* arg1=\"test\"" trace
echo 0 > events/kprobes/testprobe/enable
: "Test get argument (2)"
-echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events
+echo "p:testprobe eventfs_add_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events
echo 1 > events/kprobes/testprobe/enable
echo "p:test $FUNCTION_FORK" >> kprobe_events
grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace
--
2.39.0
^ permalink raw reply related [flat|nested] 23+ 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; 23+ 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] 23+ messages in thread
* Re: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
@ 2023-05-02 14:21 ` kernel test robot
2023-05-02 16:04 ` kernel test robot
2023-05-02 22:15 ` kernel test robot
2 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2023-05-02 14:21 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 rostedt-trace/for-next v6.3 next-20230428]
[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-5-git-send-email-akaher%40vmware.com
patch subject: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20230502/202305022234.nOgIYubz-lkp@intel.com/config)
compiler: arceb-elf-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/9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
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 9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
# 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=arc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash fs/tracefs/
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/202305022234.nOgIYubz-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/tracefs/event_inode.c:379:6: warning: no previous prototype for 'eventfs_remove_rec' [-Wmissing-prototypes]
379 | void eventfs_remove_rec(struct eventfs_file *ef)
| ^~~~~~~~~~~~~~~~~~
fs/tracefs/event_inode.c:58:13: warning: 'eventfs_up_read' defined but not used [-Wunused-function]
58 | static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem)
| ^~~~~~~~~~~~~~~
fs/tracefs/event_inode.c:47:13: warning: 'eventfs_down_read' defined but not used [-Wunused-function]
47 | static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem)
| ^~~~~~~~~~~~~~~~~
fs/tracefs/event_inode.c:31:29: warning: 'eventfs_dentry_to_rwsem' defined but not used [-Wunused-function]
31 | static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry)
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +/eventfs_remove_rec +379 fs/tracefs/event_inode.c
371
372 /**
373 * eventfs_remove_rec - remove eventfs dir or file from list
374 * @ef: a pointer to eventfs_file to be removed.
375 *
376 * This function recursively remove eventfs_file which
377 * contains info of file or dir.
378 */
> 379 void eventfs_remove_rec(struct eventfs_file *ef)
380 {
381 struct eventfs_file *ef_child, *n;
382
383 if (!ef)
384 return;
385
386 if (ef->ei) {
387 /* search for nested folders or files */
388 list_for_each_entry_safe(ef_child, n, &ef->ei->e_top_files, list) {
389 eventfs_remove_rec(ef_child);
390 }
391 kfree(ef->ei);
392 }
393
394 if (ef->created && ef->dentry) {
395 d_invalidate(ef->dentry);
396 dput(ef->dentry);
397 }
398 list_del(&ef->list);
399 kfree(ef->name);
400 kfree(ef);
401 }
402
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
2023-05-02 14:21 ` kernel test robot
@ 2023-05-02 16:04 ` kernel test robot
2023-05-02 22:15 ` kernel test robot
2 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2023-05-02 16:04 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-5-git-send-email-akaher%40vmware.com
patch subject: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
config: i386-randconfig-a011-20230501 (https://download.01.org/0day-ci/archive/20230502/202305022354.fzV9RKTT-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/9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
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 9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
# 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 fs/tracefs/ 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/202305022354.fzV9RKTT-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/tracefs/event_inode.c:379:6: warning: no previous prototype for function 'eventfs_remove_rec' [-Wmissing-prototypes]
void eventfs_remove_rec(struct eventfs_file *ef)
^
fs/tracefs/event_inode.c:379:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void eventfs_remove_rec(struct eventfs_file *ef)
^
static
fs/tracefs/event_inode.c:31:29: warning: unused function 'eventfs_dentry_to_rwsem' [-Wunused-function]
static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry)
^
fs/tracefs/event_inode.c:47:13: warning: unused function 'eventfs_down_read' [-Wunused-function]
static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem)
^
fs/tracefs/event_inode.c:58:13: warning: unused function 'eventfs_up_read' [-Wunused-function]
static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem)
^
4 warnings generated.
vim +/eventfs_remove_rec +379 fs/tracefs/event_inode.c
371
372 /**
373 * eventfs_remove_rec - remove eventfs dir or file from list
374 * @ef: a pointer to eventfs_file to be removed.
375 *
376 * This function recursively remove eventfs_file which
377 * contains info of file or dir.
378 */
> 379 void eventfs_remove_rec(struct eventfs_file *ef)
380 {
381 struct eventfs_file *ef_child, *n;
382
383 if (!ef)
384 return;
385
386 if (ef->ei) {
387 /* search for nested folders or files */
388 list_for_each_entry_safe(ef_child, n, &ef->ei->e_top_files, list) {
389 eventfs_remove_rec(ef_child);
390 }
391 kfree(ef->ei);
392 }
393
394 if (ef->created && ef->dentry) {
395 d_invalidate(ef->dentry);
396 dput(ef->dentry);
397 }
398 list_del(&ef->list);
399 kfree(ef->name);
400 kfree(ef);
401 }
402
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 23+ 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; 23+ 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] 23+ messages in thread
* Re: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
2023-05-02 14:21 ` kernel test robot
2023-05-02 16:04 ` kernel test robot
@ 2023-05-02 22:15 ` kernel test robot
2 siblings, 0 replies; 23+ messages in thread
From: kernel test robot @ 2023-05-02 22:15 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 rostedt-trace/for-next v6.3 next-20230428]
[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-5-git-send-email-akaher%40vmware.com
patch subject: [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function
config: i386-randconfig-s002 (https://download.01.org/0day-ci/archive/20230503/202305030611.Kas747Ev-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
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 9a36b39da0c3fbfe15a3c3a0ed71b52013bac292
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash fs/tracefs/
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/202305030611.Kas747Ev-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> fs/tracefs/event_inode.c:379:6: sparse: sparse: symbol 'eventfs_remove_rec' was not declared. Should it be static?
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 2/9] eventfs: adding eventfs dir add functions
2023-05-02 11:23 ` [PATCH v2 2/9] eventfs: adding eventfs dir add functions Ajay Kaher
@ 2023-05-08 9:32 ` Zheng Yejian
2023-05-10 11:25 ` Ajay Kaher
0 siblings, 1 reply; 23+ messages in thread
From: Zheng Yejian @ 2023-05-08 9:32 UTC (permalink / raw)
To: Ajay Kaher, rostedt, mhiramat, shuah
Cc: linux-kernel, linux-trace-kernel, linux-kselftest, chinglinyu,
namit, srivatsab, srivatsa, amakhalov, vsirnapalli, tkundu,
er.ajay.kaher
On 2023/5/2 19:23, Ajay Kaher wrote:
> Adding eventfs_file structure which will hold properties of file or dir.
>
> Adding following functions to add dir in eventfs:
>
> eventfs_create_events_dir() will directly create events dir with-in
> tracing folder.
>
> eventfs_add_subsystem_dir() will adds the info of subsystem_dir to
> eventfs and dynamically create subsystem_dir as and when requires.
>
> eventfs_add_dir() will add the info of dir (which is with-in
> subsystem_dir) to eventfs and dynamically create these dir as
> and when requires.
>
> 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/Makefile | 1 +
> fs/tracefs/event_inode.c | 252 +++++++++++++++++++++++++++++++++++++++
> include/linux/tracefs.h | 29 +++++
> kernel/trace/trace.h | 1 +
> 4 files changed, 283 insertions(+)
> create mode 100644 fs/tracefs/event_inode.c
>
> diff --git a/fs/tracefs/Makefile b/fs/tracefs/Makefile
> index 7c35a282b..73c56da8e 100644
> --- a/fs/tracefs/Makefile
> +++ b/fs/tracefs/Makefile
> @@ -1,5 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0-only
> tracefs-objs := inode.o
> +tracefs-objs += event_inode.o
>
> obj-$(CONFIG_TRACING) += tracefs.o
>
> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> new file mode 100644
> index 000000000..82caba7e9
> --- /dev/null
> +++ b/fs/tracefs/event_inode.c
> @@ -0,0 +1,252 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * event_inode.c - part of tracefs, a pseudo file system for activating tracing
> + *
> + * Copyright (C) 2020-22 VMware Inc, author: Steven Rostedt (VMware) <rostedt@goodmis.org>
> + * Copyright (C) 2020-22 VMware Inc, author: Ajay Kaher <akaher@vmware.com>
> + *
> + * eventfs is used to show trace events with one set of dentries
> + *
> + * eventfs stores meta-data of files/dirs and skip to create object of
> + * inodes/dentries. As and when requires, eventfs will create the
> + * inodes/dentries for only required files/directories. Also eventfs
> + * would delete the inodes/dentries once no more requires but preserve
> + * the meta data.
> + */
> +#include <linux/fsnotify.h>
> +#include <linux/fs.h>
> +#include <linux/namei.h>
> +#include <linux/security.h>
> +#include <linux/tracefs.h>
> +#include <linux/kref.h>
> +#include <linux/delay.h>
> +#include "internal.h"
> +
> +/**
> + * eventfs_dentry_to_rwsem - Return corresponding eventfs_rwsem
> + * @dentry: a pointer to dentry
> + *
> + * helper function to return crossponding eventfs_rwsem for given dentry
> + */
> +static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry)
> +{
> + if (S_ISDIR(dentry->d_inode->i_mode))
> + return (struct rw_semaphore *)dentry->d_inode->i_private;
> + else
> + return (struct rw_semaphore *)dentry->d_parent->d_inode->i_private;
> +}
> +
> +/**
> + * eventfs_down_read - acquire read lock function
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * helper function to perform read lock, skip locking if caller task already
> + * own the lock. read lock requires for lookup(), release() and these also
> + * called with-in open(), remove() which already hold the read/write lock.
> + */
> +static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem)
> +{
> + down_read_nested(eventfs_rwsem, SINGLE_DEPTH_NESTING);
> +}
> +
> +/**
> + * eventfs_up_read - release read lock function
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * helper function to release eventfs_rwsem lock if locked
> + */
> +static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem)
> +{
> + up_read(eventfs_rwsem);
> +}
> +
> +/**
> + * eventfs_down_write - acquire write lock function
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * helper function to perform write lock on eventfs_rwsem
> + */
> +static void eventfs_down_write(struct rw_semaphore *eventfs_rwsem)
> +{
> + while (!down_write_trylock(eventfs_rwsem))
> + msleep(10);
> +}
> +
> +/**
> + * eventfs_up_write - release write lock function
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * helper function to perform write lock on eventfs_rwsem
> + */
> +static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem)
> +{
> + up_write(eventfs_rwsem);
> +}
> +
> +static const struct file_operations eventfs_file_operations = {
> +};
> +
> +static const struct inode_operations eventfs_root_dir_inode_operations = {
> +};
> +
> +/**
> + * eventfs_create_events_dir - create the trace event structure
> + * @name: a pointer to a string containing the name of the directory to
> + * create.
> + * @parent: a pointer to the parent dentry for this file. This should be a
> + * directory dentry if set. If this parameter is NULL, then the
> + * directory will be created in the root of the tracefs filesystem.
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * This function creates the top of the trace event directory.
> + */
> +struct dentry *eventfs_create_events_dir(const char *name,
> + struct dentry *parent,
> + struct rw_semaphore *eventfs_rwsem)
> +{
> + struct dentry *dentry = tracefs_start_creating(name, parent);
> + struct eventfs_inode *ei;
> + struct tracefs_inode *ti;
> + struct inode *inode;
> +
> + if (IS_ERR(dentry))
> + return dentry;
> +
> + ei = kzalloc(sizeof(*ei), GFP_KERNEL);
> + if (!ei)
> + return ERR_PTR(-ENOMEM);
> + inode = tracefs_get_inode(dentry->d_sb);
> + if (unlikely(!inode)) {
> + kfree(ei);
> + tracefs_failed_creating(dentry);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + init_rwsem(eventfs_rwsem);
> + INIT_LIST_HEAD(&ei->e_top_files);
> +
> + ti = get_tracefs(inode);
> + ti->flags |= TRACEFS_EVENT_INODE;
> + ti->private = ei;
> +
> + inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
> + inode->i_op = &eventfs_root_dir_inode_operations;
> + inode->i_fop = &eventfs_file_operations;
> + inode->i_private = eventfs_rwsem;
> +
> + /* directory inodes start off with i_nlink == 2 (for "." entry) */
> + inc_nlink(inode);
> + d_instantiate(dentry, inode);
> + inc_nlink(dentry->d_parent->d_inode);
> + fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
> + return tracefs_end_creating(dentry);
> +}
> +
> +/**
> + * eventfs_add_subsystem_dir - add eventfs subsystem_dir to list to create later
> + * @name: a pointer to a string containing the name of the file to create.
> + * @parent: a pointer to the parent dentry for this dir.
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * This function adds eventfs subsystem dir to list.
> + * And all these dirs are created on the fly when they are looked up,
> + * and the dentry and inodes will be removed when they are done.
> + */
> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
> + struct dentry *parent,
> + struct rw_semaphore *eventfs_rwsem)
> +{
> + struct tracefs_inode *ti_parent;
> + struct eventfs_inode *ei_parent;
> + struct eventfs_file *ef;
> +
> + if (!parent)
> + return ERR_PTR(-EINVAL);
> +
> + ti_parent = get_tracefs(parent->d_inode);
> + ei_parent = ti_parent->private;
> +
> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
> + if (!ef)
> + return ERR_PTR(-ENOMEM);
> +
> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
> + if (!ef->ei) {
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + INIT_LIST_HEAD(&ef->ei->e_top_files);
> +
> + ef->name = kstrdup(name, GFP_KERNEL);
> + if (!ef->name) {
> + kfree(ef->ei);
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
> + ef->iop = &eventfs_root_dir_inode_operations;
> + ef->fop = &eventfs_file_operations;
> + ef->dentry = NULL;
> + ef->created = false;
> + ef->d_parent = parent;
> + ef->data = eventfs_rwsem;
> +
> + eventfs_down_write(eventfs_rwsem);
> + list_add_tail(&ef->list, &ei_parent->e_top_files);
> + eventfs_up_write(eventfs_rwsem);
> + return ef;
> +}
> +
> +/**
> + * eventfs_add_dir - add eventfs dir to list to create later
> + * @name: a pointer to a string containing the name of the file to create.
> + * @ef_parent: a pointer to the parent eventfs_file for this dir.
> + * @eventfs_rwsem: a pointer to rw_semaphore
> + *
> + * This function adds eventfs dir to list.
> + * And all these dirs are created on the fly when they are looked up,
> + * and the dentry and inodes will be removed when they are done.
> + */
> +struct eventfs_file *eventfs_add_dir(const char *name,
> + struct eventfs_file *ef_parent,
> + struct rw_semaphore *eventfs_rwsem)
> +{
> + struct eventfs_file *ef;
> +
> + if (!ef_parent)
> + return ERR_PTR(-EINVAL);
> +
> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
> + if (!ef)
> + return ERR_PTR(-ENOMEM);
> +
> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
> + if (!ef->ei) {
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + INIT_LIST_HEAD(&ef->ei->e_top_files);
> +
> + ef->name = kstrdup(name, GFP_KERNEL);
> + if (!ef->name) {
> + kfree(ef->ei);
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
> + ef->iop = &eventfs_root_dir_inode_operations;
> + ef->fop = &eventfs_file_operations;
> + ef->created = false;
> + ef->dentry = NULL;
> + ef->d_parent = NULL;
> + ef->data = eventfs_rwsem;
> +
> + eventfs_down_write(eventfs_rwsem);
> + list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
> + eventfs_up_write(eventfs_rwsem);
> + return ef;
> +}
Hi,
eventfs_add_subsystem_dir() and eventfs_add_dir() are almost the same,
how about extract a common help function to simplify them, like:
+static struct eventfs_file *__eventfs_add_dir(const char *name,
+ struct dentry *d_parent,
+ struct eventfs_inode
*ei_parent,
+ struct rw_semaphore
*eventfs_rwsem)
+{
+ struct eventfs_file *ef;
+
+ ef = kzalloc(sizeof(*ef), GFP_KERNEL);
+ if (!ef)
+ return ERR_PTR(-ENOMEM);
+
+ ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
+ if (!ef->ei) {
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ INIT_LIST_HEAD(&ef->ei->e_top_files);
+
+ ef->name = kstrdup(name, GFP_KERNEL);
+ if (!ef->name) {
+ kfree(ef->ei);
+ kfree(ef);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
+ ef->iop = &eventfs_root_dir_inode_operations;
+ ef->fop = &eventfs_file_operations;
+ ef->dentry = NULL;
+ ef->created = false;
+ ef->d_parent = d_parent;
+ ef->data = eventfs_rwsem;
+
+ eventfs_down_write(eventfs_rwsem);
+ list_add_tail(&ef->list, &ei_parent->e_top_files);
+ eventfs_up_write(eventfs_rwsem);
+ return ef;
+}
+
+struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
+ struct dentry *parent,
+ struct rw_semaphore
*eventfs_rwsem)
+{
+ struct tracefs_inode *ti_parent;
+ struct eventfs_inode *ei_parent;
+
+ if (!parent)
+ return ERR_PTR(-EINVAL);
+ ti_parent = get_tracefs(parent->d_inode);
+ ei_parent = ti_parent->private;
+ return __eventfs_add_dir(name, parent, ei_parent, eventfs_rwsem);
+}
+
+struct eventfs_file *eventfs_add_dir(const char *name,
+ struct eventfs_file *ef_parent,
+ struct rw_semaphore *eventfs_rwsem)
+{
+ if (!ef_parent)
+ return ERR_PTR(-EINVAL);
+ return __eventfs_add_dir(name, NULL, ef_parent->ei, eventfs_rwsem);
+}
--
Best regards,
Zheng Yejian
> diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
> index 999124459..aeca6761f 100644
> --- a/include/linux/tracefs.h
> +++ b/include/linux/tracefs.h
> @@ -21,6 +21,35 @@ struct file_operations;
>
> #ifdef CONFIG_TRACING
>
> +struct eventfs_inode {
> + struct list_head e_top_files;
> +};
> +
> +struct eventfs_file {
> + const char *name;
> + struct dentry *d_parent;
> + struct dentry *dentry;
> + struct list_head list;
> + struct eventfs_inode *ei;
> + const struct file_operations *fop;
> + const struct inode_operations *iop;
> + void *data;
> + umode_t mode;
> + bool created;
> +};
> +
> +struct dentry *eventfs_create_events_dir(const char *name,
> + struct dentry *parent,
> + struct rw_semaphore *eventfs_rwsem);
> +
> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
> + struct dentry *parent,
> + struct rw_semaphore *eventfs_rwsem);
> +
> +struct eventfs_file *eventfs_add_dir(const char *name,
> + struct eventfs_file *ef_parent,
> + struct rw_semaphore *eventfs_rwsem);
> +
> struct dentry *tracefs_create_file(const char *name, umode_t mode,
> struct dentry *parent, void *data,
> const struct file_operations *fops);
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 616e1aa1c..3726725c8 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -359,6 +359,7 @@ struct trace_array {
> struct dentry *options;
> struct dentry *percpu_dir;
> struct dentry *event_dir;
> + struct rw_semaphore eventfs_rwsem;
> struct trace_options *topts;
> struct list_head systems;
> struct list_head events;
^ permalink raw reply [flat|nested] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ messages in thread
* Re: [PATCH v2 2/9] eventfs: adding eventfs dir add functions
2023-05-08 9:32 ` Zheng Yejian
@ 2023-05-10 11:25 ` Ajay Kaher
2023-06-19 5:24 ` Ajay Kaher
0 siblings, 1 reply; 23+ messages in thread
From: Ajay Kaher @ 2023-05-10 11:25 UTC (permalink / raw)
To: Zheng Yejian
Cc: Steven Rostedt, mhiramat@kernel.org, shuah@kernel.org,
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 08-May-2023, at 3:02 PM, Zheng Yejian <zhengyejian1@huawei.com> wrote:
>
> On 2023/5/2 19:23, Ajay Kaher wrote:
>> Adding eventfs_file structure which will hold properties of file or dir.
>>
>> Adding following functions to add dir in eventfs:
>>
>> eventfs_create_events_dir() will directly create events dir with-in
>> tracing folder.
>>
>> eventfs_add_subsystem_dir() will adds the info of subsystem_dir to
>> eventfs and dynamically create subsystem_dir as and when requires.
>>
>> eventfs_add_dir() will add the info of dir (which is with-in
>> subsystem_dir) to eventfs and dynamically create these dir as
>> and when requires.
>>
>> 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/Makefile | 1 +
>> fs/tracefs/event_inode.c | 252 +++++++++++++++++++++++++++++++++++++++
>> include/linux/tracefs.h | 29 +++++
>> kernel/trace/trace.h | 1 +
>> 4 files changed, 283 insertions(+)
>> create mode 100644 fs/tracefs/event_inode.c
>>
>> diff --git a/fs/tracefs/Makefile b/fs/tracefs/Makefile
>> index 7c35a282b..73c56da8e 100644
>> --- a/fs/tracefs/Makefile
>> +++ b/fs/tracefs/Makefile
>> @@ -1,5 +1,6 @@
>> # SPDX-License-Identifier: GPL-2.0-only
>> tracefs-objs := inode.o
>> +tracefs-objs += event_inode.o
>>
>> obj-$(CONFIG_TRACING) += tracefs.o
>>
>> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
>> new file mode 100644
>> index 000000000..82caba7e9
>> --- /dev/null
>> +++ b/fs/tracefs/event_inode.c
>> @@ -0,0 +1,252 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * event_inode.c - part of tracefs, a pseudo file system for activating tracing
>> + *
>> + * Copyright (C) 2020-22 VMware Inc, author: Steven Rostedt (VMware) <rostedt@goodmis.org>
>> + * Copyright (C) 2020-22 VMware Inc, author: Ajay Kaher <akaher@vmware.com>
>> + *
>> + * eventfs is used to show trace events with one set of dentries
>> + *
>> + * eventfs stores meta-data of files/dirs and skip to create object of
>> + * inodes/dentries. As and when requires, eventfs will create the
>> + * inodes/dentries for only required files/directories. Also eventfs
>> + * would delete the inodes/dentries once no more requires but preserve
>> + * the meta data.
>> + */
>> +#include <linux/fsnotify.h>
>> +#include <linux/fs.h>
>> +#include <linux/namei.h>
>> +#include <linux/security.h>
>> +#include <linux/tracefs.h>
>> +#include <linux/kref.h>
>> +#include <linux/delay.h>
>> +#include "internal.h"
>> +
>> +/**
>> + * eventfs_dentry_to_rwsem - Return corresponding eventfs_rwsem
>> + * @dentry: a pointer to dentry
>> + *
>> + * helper function to return crossponding eventfs_rwsem for given dentry
>> + */
>> +static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry)
>> +{
>> + if (S_ISDIR(dentry->d_inode->i_mode))
>> + return (struct rw_semaphore *)dentry->d_inode->i_private;
>> + else
>> + return (struct rw_semaphore *)dentry->d_parent->d_inode->i_private;
>> +}
>> +
>> +/**
>> + * eventfs_down_read - acquire read lock function
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * helper function to perform read lock, skip locking if caller task already
>> + * own the lock. read lock requires for lookup(), release() and these also
>> + * called with-in open(), remove() which already hold the read/write lock.
>> + */
>> +static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem)
>> +{
>> + down_read_nested(eventfs_rwsem, SINGLE_DEPTH_NESTING);
>> +}
>> +
>> +/**
>> + * eventfs_up_read - release read lock function
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * helper function to release eventfs_rwsem lock if locked
>> + */
>> +static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem)
>> +{
>> + up_read(eventfs_rwsem);
>> +}
>> +
>> +/**
>> + * eventfs_down_write - acquire write lock function
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * helper function to perform write lock on eventfs_rwsem
>> + */
>> +static void eventfs_down_write(struct rw_semaphore *eventfs_rwsem)
>> +{
>> + while (!down_write_trylock(eventfs_rwsem))
>> + msleep(10);
>> +}
>> +
>> +/**
>> + * eventfs_up_write - release write lock function
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * helper function to perform write lock on eventfs_rwsem
>> + */
>> +static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem)
>> +{
>> + up_write(eventfs_rwsem);
>> +}
>> +
>> +static const struct file_operations eventfs_file_operations = {
>> +};
>> +
>> +static const struct inode_operations eventfs_root_dir_inode_operations = {
>> +};
>> +
>> +/**
>> + * eventfs_create_events_dir - create the trace event structure
>> + * @name: a pointer to a string containing the name of the directory to
>> + * create.
>> + * @parent: a pointer to the parent dentry for this file. This should be a
>> + * directory dentry if set. If this parameter is NULL, then the
>> + * directory will be created in the root of the tracefs filesystem.
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * This function creates the top of the trace event directory.
>> + */
>> +struct dentry *eventfs_create_events_dir(const char *name,
>> + struct dentry *parent,
>> + struct rw_semaphore *eventfs_rwsem)
>> +{
>> + struct dentry *dentry = tracefs_start_creating(name, parent);
>> + struct eventfs_inode *ei;
>> + struct tracefs_inode *ti;
>> + struct inode *inode;
>> +
>> + if (IS_ERR(dentry))
>> + return dentry;
>> +
>> + ei = kzalloc(sizeof(*ei), GFP_KERNEL);
>> + if (!ei)
>> + return ERR_PTR(-ENOMEM);
>> + inode = tracefs_get_inode(dentry->d_sb);
>> + if (unlikely(!inode)) {
>> + kfree(ei);
>> + tracefs_failed_creating(dentry);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + init_rwsem(eventfs_rwsem);
>> + INIT_LIST_HEAD(&ei->e_top_files);
>> +
>> + ti = get_tracefs(inode);
>> + ti->flags |= TRACEFS_EVENT_INODE;
>> + ti->private = ei;
>> +
>> + inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
>> + inode->i_op = &eventfs_root_dir_inode_operations;
>> + inode->i_fop = &eventfs_file_operations;
>> + inode->i_private = eventfs_rwsem;
>> +
>> + /* directory inodes start off with i_nlink == 2 (for "." entry) */
>> + inc_nlink(inode);
>> + d_instantiate(dentry, inode);
>> + inc_nlink(dentry->d_parent->d_inode);
>> + fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
>> + return tracefs_end_creating(dentry);
>> +}
>> +
>> +/**
>> + * eventfs_add_subsystem_dir - add eventfs subsystem_dir to list to create later
>> + * @name: a pointer to a string containing the name of the file to create.
>> + * @parent: a pointer to the parent dentry for this dir.
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * This function adds eventfs subsystem dir to list.
>> + * And all these dirs are created on the fly when they are looked up,
>> + * and the dentry and inodes will be removed when they are done.
>> + */
>> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
>> + struct dentry *parent,
>> + struct rw_semaphore *eventfs_rwsem)
>> +{
>> + struct tracefs_inode *ti_parent;
>> + struct eventfs_inode *ei_parent;
>> + struct eventfs_file *ef;
>> +
>> + if (!parent)
>> + return ERR_PTR(-EINVAL);
>> +
>> + ti_parent = get_tracefs(parent->d_inode);
>> + ei_parent = ti_parent->private;
>> +
>> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
>> + if (!ef)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
>> + if (!ef->ei) {
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + INIT_LIST_HEAD(&ef->ei->e_top_files);
>> +
>> + ef->name = kstrdup(name, GFP_KERNEL);
>> + if (!ef->name) {
>> + kfree(ef->ei);
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
>> + ef->iop = &eventfs_root_dir_inode_operations;
>> + ef->fop = &eventfs_file_operations;
>> + ef->dentry = NULL;
>> + ef->created = false;
>> + ef->d_parent = parent;
>> + ef->data = eventfs_rwsem;
>> +
>> + eventfs_down_write(eventfs_rwsem);
>> + list_add_tail(&ef->list, &ei_parent->e_top_files);
>> + eventfs_up_write(eventfs_rwsem);
>> + return ef;
>> +}
>> +
>> +/**
>> + * eventfs_add_dir - add eventfs dir to list to create later
>> + * @name: a pointer to a string containing the name of the file to create.
>> + * @ef_parent: a pointer to the parent eventfs_file for this dir.
>> + * @eventfs_rwsem: a pointer to rw_semaphore
>> + *
>> + * This function adds eventfs dir to list.
>> + * And all these dirs are created on the fly when they are looked up,
>> + * and the dentry and inodes will be removed when they are done.
>> + */
>> +struct eventfs_file *eventfs_add_dir(const char *name,
>> + struct eventfs_file *ef_parent,
>> + struct rw_semaphore *eventfs_rwsem)
>> +{
>> + struct eventfs_file *ef;
>> +
>> + if (!ef_parent)
>> + return ERR_PTR(-EINVAL);
>> +
>> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
>> + if (!ef)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
>> + if (!ef->ei) {
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + INIT_LIST_HEAD(&ef->ei->e_top_files);
>> +
>> + ef->name = kstrdup(name, GFP_KERNEL);
>> + if (!ef->name) {
>> + kfree(ef->ei);
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
>> + ef->iop = &eventfs_root_dir_inode_operations;
>> + ef->fop = &eventfs_file_operations;
>> + ef->created = false;
>> + ef->dentry = NULL;
>> + ef->d_parent = NULL;
>> + ef->data = eventfs_rwsem;
>> +
>> + eventfs_down_write(eventfs_rwsem);
>> + list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
>> + eventfs_up_write(eventfs_rwsem);
>> + return ef;
>> +}
>
> Hi,
> eventfs_add_subsystem_dir() and eventfs_add_dir() are almost the same,
> how about extract a common help function to simplify them, like:
>
> +static struct eventfs_file *__eventfs_add_dir(const char *name,
> + struct dentry *d_parent,
> + struct eventfs_inode
> *ei_parent,
> + struct rw_semaphore
> *eventfs_rwsem)
> +{
> + struct eventfs_file *ef;
> +
> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
> + if (!ef)
> + return ERR_PTR(-ENOMEM);
> +
> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
> + if (!ef->ei) {
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + INIT_LIST_HEAD(&ef->ei->e_top_files);
> +
> + ef->name = kstrdup(name, GFP_KERNEL);
> + if (!ef->name) {
> + kfree(ef->ei);
> + kfree(ef);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
> + ef->iop = &eventfs_root_dir_inode_operations;
> + ef->fop = &eventfs_file_operations;
> + ef->dentry = NULL;
> + ef->created = false;
> + ef->d_parent = d_parent;
> + ef->data = eventfs_rwsem;
> +
> + eventfs_down_write(eventfs_rwsem);
> + list_add_tail(&ef->list, &ei_parent->e_top_files);
> + eventfs_up_write(eventfs_rwsem);
> + return ef;
> +}
> +
> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
> + struct dentry *parent,
> + struct rw_semaphore
> *eventfs_rwsem)
> +{
> + struct tracefs_inode *ti_parent;
> + struct eventfs_inode *ei_parent;
> +
> + if (!parent)
> + return ERR_PTR(-EINVAL);
> + ti_parent = get_tracefs(parent->d_inode);
> + ei_parent = ti_parent->private;
> + return __eventfs_add_dir(name, parent, ei_parent, eventfs_rwsem);
> +}
> +
> +struct eventfs_file *eventfs_add_dir(const char *name,
> + struct eventfs_file *ef_parent,
> + struct rw_semaphore *eventfs_rwsem)
> +{
> + if (!ef_parent)
> + return ERR_PTR(-EINVAL);
> + return __eventfs_add_dir(name, NULL, ef_parent->ei, eventfs_rwsem);
> +}
Sounds good. Thanks for sharing code snippet. I will consider in v3.
- Ajay
>> diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h
>> index 999124459..aeca6761f 100644
>> --- a/include/linux/tracefs.h
>> +++ b/include/linux/tracefs.h
>> @@ -21,6 +21,35 @@ struct file_operations;
>>
>> #ifdef CONFIG_TRACING
>>
>> +struct eventfs_inode {
>> + struct list_head e_top_files;
>> +};
>> +
>> +struct eventfs_file {
>> + const char *name;
>> + struct dentry *d_parent;
>> + struct dentry *dentry;
>> + struct list_head list;
>> + struct eventfs_inode *ei;
>> + const struct file_operations *fop;
>> + const struct inode_operations *iop;
>> + void *data;
>> + umode_t mode;
>> + bool created;
>> +};
>> +
>> +struct dentry *eventfs_create_events_dir(const char *name,
>> + struct dentry *parent,
>> + struct rw_semaphore *eventfs_rwsem);
>> +
>> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
>> + struct dentry *parent,
>> + struct rw_semaphore *eventfs_rwsem);
>> +
>> +struct eventfs_file *eventfs_add_dir(const char *name,
>> + struct eventfs_file *ef_parent,
>> + struct rw_semaphore *eventfs_rwsem);
>> +
>> struct dentry *tracefs_create_file(const char *name, umode_t mode,
>> struct dentry *parent, void *data,
>> const struct file_operations *fops);
>> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
>> index 616e1aa1c..3726725c8 100644
>> --- a/kernel/trace/trace.h
>> +++ b/kernel/trace/trace.h
>> @@ -359,6 +359,7 @@ struct trace_array {
>> struct dentry *options;
>> struct dentry *percpu_dir;
>> struct dentry *event_dir;
>> + struct rw_semaphore eventfs_rwsem;
>> struct trace_options *topts;
>> struct list_head systems;
>> struct list_head events;
^ permalink raw reply [flat|nested] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ messages in thread
* Re: [PATCH v2 2/9] eventfs: adding eventfs dir add functions
2023-05-10 11:25 ` Ajay Kaher
@ 2023-06-19 5:24 ` Ajay Kaher
0 siblings, 0 replies; 23+ messages in thread
From: Ajay Kaher @ 2023-06-19 5:24 UTC (permalink / raw)
To: Zheng Yejian
Cc: Steven Rostedt, mhiramat@kernel.org, shuah@kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, chinglinyu@google.com,
Nadav Amit, srivatsab@vmware.com, srivatsa@csail.mit.edu,
Alexey Makhalov, Vasavi Sirnapalli, Tapas Kundu,
er.ajay.kaher@gmail.com
> On 10-May-2023, at 4:55 PM, Ajay Kaher <akaher@vmware.com> wrote:
>>
>> Hi,
>> eventfs_add_subsystem_dir() and eventfs_add_dir() are almost the same,
>> how about extract a common help function to simplify them, like:
>>
>> +static struct eventfs_file *__eventfs_add_dir(const char *name,
>> + struct dentry *d_parent,
>> + struct eventfs_inode
>> *ei_parent,
>> + struct rw_semaphore
>> *eventfs_rwsem)
>> +{
>> + struct eventfs_file *ef;
>> +
>> + ef = kzalloc(sizeof(*ef), GFP_KERNEL);
>> + if (!ef)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL);
>> + if (!ef->ei) {
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + INIT_LIST_HEAD(&ef->ei->e_top_files);
>> +
>> + ef->name = kstrdup(name, GFP_KERNEL);
>> + if (!ef->name) {
>> + kfree(ef->ei);
>> + kfree(ef);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + ef->mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
>> + ef->iop = &eventfs_root_dir_inode_operations;
>> + ef->fop = &eventfs_file_operations;
>> + ef->dentry = NULL;
>> + ef->created = false;
>> + ef->d_parent = d_parent;
>> + ef->data = eventfs_rwsem;
>> +
>> + eventfs_down_write(eventfs_rwsem);
>> + list_add_tail(&ef->list, &ei_parent->e_top_files);
>> + eventfs_up_write(eventfs_rwsem);
>> + return ef;
>> +}
>> +
>> +struct eventfs_file *eventfs_add_subsystem_dir(const char *name,
>> + struct dentry *parent,
>> + struct rw_semaphore
>> *eventfs_rwsem)
>> +{
>> + struct tracefs_inode *ti_parent;
>> + struct eventfs_inode *ei_parent;
>> +
>> + if (!parent)
>> + return ERR_PTR(-EINVAL);
>> + ti_parent = get_tracefs(parent->d_inode);
>> + ei_parent = ti_parent->private;
>> + return __eventfs_add_dir(name, parent, ei_parent, eventfs_rwsem);
>> +}
>> +
>> +struct eventfs_file *eventfs_add_dir(const char *name,
>> + struct eventfs_file *ef_parent,
>> + struct rw_semaphore *eventfs_rwsem)
>> +{
>> + if (!ef_parent)
>> + return ERR_PTR(-EINVAL);
>> + return __eventfs_add_dir(name, NULL, ef_parent->ei, eventfs_rwsem);
>> +}
>
> Sounds good. Thanks for sharing code snippet. I will consider in v3.
>
Hi Zheng, I have moved common code to eventfs_prepare_ef() in v3 3/10, 4/10:
https://lore.kernel.org/all/1685610013-33478-1-git-send-email-akaher@vmware.com/
-Ajay
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2023-06-19 5:24 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 11:23 [PATCH v2 0/9] tracing: introducing eventfs Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 1/9] eventfs: introducing struct tracefs_inode Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 2/9] eventfs: adding eventfs dir add functions Ajay Kaher
2023-05-08 9:32 ` Zheng Yejian
2023-05-10 11:25 ` Ajay Kaher
2023-06-19 5:24 ` Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 3/9] eventfs: adding eventfs file " Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 4/9] eventfs: adding eventfs file, directory remove function Ajay Kaher
2023-05-02 14:21 ` kernel test robot
2023-05-02 16:04 ` kernel test robot
2023-05-02 22:15 ` kernel test robot
2023-05-02 11:23 ` [PATCH v2 5/9] eventfs: adding functions to create eventfs files and directories Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 6/9] eventfs: adding eventfs lookup, read, open functions Ajay Kaher
2023-05-02 11:23 ` [PATCH v2 7/9] eventfs: creating tracefs_inode_cache 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
2023-05-02 11:23 ` [PATCH v2 9/9] test: ftrace: fix kprobe test for eventfs Ajay Kaher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox