diff mbox series

[DRAFT,3/4] : hwlat: port struct file_operations thread_mode_fops to struct kernfs_ops

Message ID 20240131-tracefs-kernfs-v1-3-f20e2e9a8d61@kernel.org (mailing list archive)
State New, archived
Headers show
Series : Port tracefs to kernfs | expand

Commit Message

Christian Brauner Jan. 31, 2024, 1:36 p.m. UTC
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 kernel/trace/trace_hwlat.c | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

Comments

kernel test robot Feb. 1, 2024, 3:30 a.m. UTC | #1
Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on 41bccc98fb7931d63d03f326a746ac4d429c1dd3]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Brauner/tracefs-port-to-kernfs/20240131-214120
base:   41bccc98fb7931d63d03f326a746ac4d429c1dd3
patch link:    https://lore.kernel.org/r/20240131-tracefs-kernfs-v1-3-f20e2e9a8d61%40kernel.org
patch subject: [PATCH DRAFT 3/4] : hwlat: port struct file_operations thread_mode_fops to struct kernfs_ops
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20240201/202402011108.V2Y9QaTk-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240201/202402011108.V2Y9QaTk-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402011108.V2Y9QaTk-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/trace/trace_hwlat.c: In function 'hwlat_mode_write':
   kernel/trace/trace_hwlat.c:672:14: error: 'buf' redeclared as different kind of symbol
     672 |         char buf[64];
         |              ^~~
   kernel/trace/trace_hwlat.c:667:68: note: previous definition of 'buf' with type 'char *'
     667 | static ssize_t hwlat_mode_write(struct kernfs_open_file *of, char *buf,
         |                                                              ~~~~~~^~~
   kernel/trace/trace_hwlat.c:672:14: warning: unused variable 'buf' [-Wunused-variable]
     672 |         char buf[64];
         |              ^~~
   kernel/trace/trace_hwlat.c: At top level:
   kernel/trace/trace_hwlat.c:736:10: error: 'const struct kernfs_ops' has no member named 'start'
     736 |         .start                  = s_mode_start,
         |          ^~~~~
   kernel/trace/trace_hwlat.c:736:9: warning: the address of 's_mode_start' will always evaluate as 'true' [-Waddress]
     736 |         .start                  = s_mode_start,
         |         ^
   kernel/trace/trace_hwlat.c:737:10: error: 'const struct kernfs_ops' has no member named 'next'
     737 |         .next                   = s_mode_next,
         |          ^~~~
>> kernel/trace/trace_hwlat.c:737:35: error: initialization of 'ssize_t (*)(struct kernfs_open_file *, char *, size_t,  loff_t)' {aka 'long int (*)(struct kernfs_open_file *, char *, long unsigned int,  long long int)'} from incompatible pointer type 'void * (*)(struct seq_file *, void *, loff_t *)' {aka 'void * (*)(struct seq_file *, void *, long long int *)'} [-Werror=incompatible-pointer-types]
     737 |         .next                   = s_mode_next,
         |                                   ^~~~~~~~~~~
   kernel/trace/trace_hwlat.c:737:35: note: (near initialization for 'thread_mode_fops.write')
   kernel/trace/trace_hwlat.c:738:10: error: 'const struct kernfs_ops' has no member named 'show'
     738 |         .show                   = s_mode_show,
         |          ^~~~
   kernel/trace/trace_hwlat.c:738:35: error: initialization of '__poll_t (*)(struct kernfs_open_file *, struct poll_table_struct *)' {aka 'unsigned int (*)(struct kernfs_open_file *, struct poll_table_struct *)'} from incompatible pointer type 'int (*)(struct seq_file *, void *)' [-Werror=incompatible-pointer-types]
     738 |         .show                   = s_mode_show,
         |                                   ^~~~~~~~~~~
   kernel/trace/trace_hwlat.c:738:35: note: (near initialization for 'thread_mode_fops.poll')
   kernel/trace/trace_hwlat.c:739:10: error: 'const struct kernfs_ops' has no member named 'stop'
     739 |         .stop                   = s_mode_stop,
         |          ^~~~
   kernel/trace/trace_hwlat.c:739:35: error: initialization of 'int (*)(struct kernfs_open_file *, struct vm_area_struct *)' from incompatible pointer type 'void (*)(struct seq_file *, void *)' [-Werror=incompatible-pointer-types]
     739 |         .stop                   = s_mode_stop,
         |                                   ^~~~~~~~~~~
   kernel/trace/trace_hwlat.c:739:35: note: (near initialization for 'thread_mode_fops.mmap')
   kernel/trace/trace_hwlat.c:740:35: warning: initialized field overwritten [-Woverride-init]
     740 |         .write                  = hwlat_mode_write,
         |                                   ^~~~~~~~~~~~~~~~
   kernel/trace/trace_hwlat.c:740:35: note: (near initialization for 'thread_mode_fops.write')
   kernel/trace/trace_hwlat.c: In function 'init_tracefs':
   kernel/trace/trace_hwlat.c:766:51: error: passing argument 5 of 'tracefs_create_file' from incompatible pointer type [-Werror=incompatible-pointer-types]
     766 |                                                   &trace_min_max_fops);
         |                                                   ^~~~~~~~~~~~~~~~~~~
         |                                                   |
         |                                                   const struct file_operations *
   In file included from kernel/trace/trace_hwlat.c:41:
   include/linux/tracefs.h:94:66: note: expected 'const struct kernfs_ops *' but argument is of type 'const struct file_operations *'
      94 |                                         const struct kernfs_ops *ops);
         |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
   kernel/trace/trace_hwlat.c:773:50: error: passing argument 5 of 'tracefs_create_file' from incompatible pointer type [-Werror=incompatible-pointer-types]
     773 |                                                  &trace_min_max_fops);
         |                                                  ^~~~~~~~~~~~~~~~~~~
         |                                                  |
         |                                                  const struct file_operations *
   include/linux/tracefs.h:94:66: note: expected 'const struct kernfs_ops *' but argument is of type 'const struct file_operations *'
      94 |                                         const struct kernfs_ops *ops);
         |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
   kernel/trace/trace_hwlat.c:778:47: error: passing argument 3 of 'trace_create_file' from incompatible pointer type [-Werror=incompatible-pointer-types]
     778 |                                               top_dir,
         |                                               ^~~~~~~
         |                                               |
         |                                               struct kernfs_node *
   In file included from kernel/trace/trace_hwlat.c:46:
   kernel/trace/trace.h:629:49: note: expected 'struct dentry *' but argument is of type 'struct kernfs_node *'
     629 |                                  struct dentry *parent,
         |                                  ~~~~~~~~~~~~~~~^~~~~~
   kernel/trace/trace_hwlat.c:780:47: error: passing argument 5 of 'trace_create_file' from incompatible pointer type [-Werror=incompatible-pointer-types]
     780 |                                               &thread_mode_fops);
         |                                               ^~~~~~~~~~~~~~~~~
         |                                               |
         |                                               const struct kernfs_ops *
   kernel/trace/trace.h:631:64: note: expected 'const struct file_operations *' but argument is of type 'const struct kernfs_ops *'
     631 |                                  const struct file_operations *fops);
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
   kernel/trace/trace_hwlat.c:777:27: error: assignment to 'struct kernfs_node *' from incompatible pointer type 'struct dentry *' [-Werror=incompatible-pointer-types]
     777 |         hwlat_thread_mode = trace_create_file("mode", TRACE_MODE_WRITE,
         |                           ^
   cc1: some warnings being treated as errors


vim +737 kernel/trace/trace_hwlat.c

   733	
   734	static const struct kernfs_ops thread_mode_fops = {
   735		.atomic_write_len	= PAGE_SIZE,
   736		.start			= s_mode_start,
 > 737		.next			= s_mode_next,
   738		.show			= s_mode_show,
   739		.stop			= s_mode_stop,
   740		.write			= hwlat_mode_write,
   741	};
   742	/**
   743	 * init_tracefs - A function to initialize the tracefs interface files
   744	 *
   745	 * This function creates entries in tracefs for "hwlat_detector".
   746	 * It creates the hwlat_detector directory in the tracing directory,
   747	 * and within that directory is the count, width and window files to
   748	 * change and view those values.
   749	 */
   750	static int init_tracefs(void)
   751	{
   752		int ret;
   753		struct kernfs_node *top_dir;
   754	
   755		ret = tracing_init_dentry();
   756		if (ret)
   757			return -ENOMEM;
   758	
   759		top_dir = tracefs_create_dir("hwlat_detector", NULL);
   760		if (!top_dir)
   761			return -ENOMEM;
   762	
   763		hwlat_sample_window = tracefs_create_file("window", TRACE_MODE_WRITE,
   764							  top_dir,
   765							  &hwlat_window,
   766							  &trace_min_max_fops);
   767		if (!hwlat_sample_window)
   768			goto err;
   769	
   770		hwlat_sample_width = tracefs_create_file("width", TRACE_MODE_WRITE,
   771							 top_dir,
   772							 &hwlat_width,
   773							 &trace_min_max_fops);
   774		if (!hwlat_sample_width)
   775			goto err;
   776	
   777		hwlat_thread_mode = trace_create_file("mode", TRACE_MODE_WRITE,
   778						      top_dir,
   779						      NULL,
   780						      &thread_mode_fops);
   781		if (!hwlat_thread_mode)
   782			goto err;
   783	
   784		return 0;
   785	
   786	 err:
   787		tracefs_remove(top_dir);
   788		return -ENOMEM;
   789	}
   790
diff mbox series

Patch

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 11b9f98b8d75..97f118575816 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -647,25 +647,12 @@  static void s_mode_stop(struct seq_file *s, void *v)
 	mutex_unlock(&hwlat_data.lock);
 }
 
-static const struct seq_operations thread_mode_seq_ops = {
-	.start		= s_mode_start,
-	.next		= s_mode_next,
-	.show		= s_mode_show,
-	.stop		= s_mode_stop
-};
-
-static int hwlat_mode_open(struct inode *inode, struct file *file)
-{
-	return seq_open(file, &thread_mode_seq_ops);
-};
-
 static void hwlat_tracer_start(struct trace_array *tr);
 static void hwlat_tracer_stop(struct trace_array *tr);
 
 /**
  * hwlat_mode_write - Write function for "mode" entry
  * @filp: The active open file structure
- * @ubuf: The user buffer that contains the value to write
  * @cnt: The maximum number of bytes to write to "file"
  * @ppos: The current position in @file
  *
@@ -677,8 +664,8 @@  static void hwlat_tracer_stop(struct trace_array *tr);
  * among the allowed CPUs in a round-robin fashion. The "per-cpu" mode
  * creates one hwlatd thread per allowed CPU.
  */
-static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
-				 size_t cnt, loff_t *ppos)
+static ssize_t hwlat_mode_write(struct kernfs_open_file *of, char *buf,
+				size_t cnt, loff_t ppos)
 {
 	struct trace_array *tr = hwlat_trace;
 	const char *mode;
@@ -688,9 +675,6 @@  static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, cnt))
-		return -EFAULT;
-
 	buf[cnt] = 0;
 
 	mode = strstrip(buf);
@@ -720,10 +704,6 @@  static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
 		hwlat_tracer_start(tr);
 	mutex_unlock(&trace_types_lock);
 
-	*ppos += cnt;
-
-
-
 	return ret;
 }
 
@@ -751,12 +731,13 @@  static struct trace_min_max_param hwlat_window = {
 	.min		= &hwlat_data.sample_width,
 };
 
-static const struct file_operations thread_mode_fops = {
-	.open		= hwlat_mode_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= seq_release,
-	.write		= hwlat_mode_write
+static const struct kernfs_ops thread_mode_fops = {
+	.atomic_write_len	= PAGE_SIZE,
+	.start			= s_mode_start,
+	.next			= s_mode_next,
+	.show			= s_mode_show,
+	.stop			= s_mode_stop,
+	.write			= hwlat_mode_write,
 };
 /**
  * init_tracefs - A function to initialize the tracefs interface files