crypto: iaa - Add global_stats file and remove individual stat files
authorTom Zanussi <tom.zanussi@linux.intel.com>
Mon, 4 Mar 2024 21:20:10 +0000 (15:20 -0600)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 2 Apr 2024 02:49:38 +0000 (10:49 +0800)
Currently, the wq_stats output also includes the global stats, while
the individual global stats are also available as separate debugfs
files.  Since these are all read-only, there's really no reason to
have them as separate files, especially since we already display them
as global stats in the wq_stats.  It makes more sense to just add a
separate global_stats file to display those, and remove them from the
wq_stats, as well as removing the individual stats files.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Documentation/driver-api/crypto/iaa/iaa-crypto.rst
drivers/crypto/intel/iaa/iaa_crypto_stats.c

index de587cf9cbed458a000747bf013c99b613d71628..7b28aef39ba00d6074554b66d8b0c917ddb3e1b0 100644 (file)
@@ -321,33 +321,30 @@ driver will generate statistics which can be accessed in debugfs at::
 
   # ls -al /sys/kernel/debug/iaa-crypto/
   total 0
-  drwxr-xr-x  2 root root 0 Mar  3 09:35 .
-  drwx------ 47 root root 0 Mar  3 09:35 ..
-  -rw-r--r--  1 root root 0 Mar  3 09:35 max_acomp_delay_ns
-  -rw-r--r--  1 root root 0 Mar  3 09:35 max_adecomp_delay_ns
-  -rw-r--r--  1 root root 0 Mar  3 09:35 max_comp_delay_ns
-  -rw-r--r--  1 root root 0 Mar  3 09:35 max_decomp_delay_ns
-  -rw-r--r--  1 root root 0 Mar  3 09:35 stats_reset
-  -rw-r--r--  1 root root 0 Mar  3 09:35 total_comp_bytes_out
-  -rw-r--r--  1 root root 0 Mar  3 09:35 total_comp_calls
-  -rw-r--r--  1 root root 0 Mar  3 09:35 total_decomp_bytes_in
-  -rw-r--r--  1 root root 0 Mar  3 09:35 total_decomp_calls
-  -rw-r--r--  1 root root 0 Mar  3 09:35 wq_stats
-
-Most of the above statisticss are self-explanatory.  The wq_stats file
-shows per-wq stats, a set for each iaa device and wq in addition to
-some global stats::
+  drwxr-xr-x  2 root root 0 Mar  3 07:55 .
+  drwx------ 53 root root 0 Mar  3 07:55 ..
+  -rw-r--r--  1 root root 0 Mar  3 07:55 global_stats
+  -rw-r--r--  1 root root 0 Mar  3 07:55 stats_reset
+  -rw-r--r--  1 root root 0 Mar  3 07:55 wq_stats
 
-  # cat wq_stats
+The global_stats file shows a set of global statistics collected since
+the driver has been loaded or reset::
+
+  # cat global_stats
   global stats:
-    total_comp_calls: 100
-    total_decomp_calls: 100
-    total_comp_bytes_out: 22800
-    total_decomp_bytes_in: 22800
+    total_comp_calls: 4300
+    total_decomp_calls: 4164
+    total_sw_decomp_calls: 0
+    total_comp_bytes_out: 5993989
+    total_decomp_bytes_in: 5993989
     total_completion_einval_errors: 0
     total_completion_timeout_errors: 0
-    total_completion_comp_buf_overflow_errors: 0
+    total_completion_comp_buf_overflow_errors: 136
+
+The wq_stats file shows per-wq stats, a set for each iaa device and wq
+in addition to some global stats::
 
+  # cat wq_stats
   iaa device:
     id: 1
     n_wqs: 1
@@ -379,21 +376,36 @@ some global stats::
   iaa device:
     id: 5
     n_wqs: 1
-    comp_calls: 100
-    comp_bytes: 22800
-    decomp_calls: 100
-    decomp_bytes: 22800
+    comp_calls: 1360
+    comp_bytes: 1999776
+    decomp_calls: 0
+    decomp_bytes: 0
     wqs:
       name: iaa_crypto
-      comp_calls: 100
-      comp_bytes: 22800
-      decomp_calls: 100
-      decomp_bytes: 22800
+      comp_calls: 1360
+      comp_bytes: 1999776
+      decomp_calls: 0
+      decomp_bytes: 0
+
+  iaa device:
+    id: 7
+    n_wqs: 1
+    comp_calls: 2940
+    comp_bytes: 3994213
+    decomp_calls: 4164
+    decomp_bytes: 5993989
+    wqs:
+      name: iaa_crypto
+      comp_calls: 2940
+      comp_bytes: 3994213
+      decomp_calls: 4164
+      decomp_bytes: 5993989
+    ...
 
-Writing to 'stats_reset' resets all the stats, including the
+Writing to 'stats_reset' resets all the stats, including the
 per-device and per-wq stats::
 
-  # echo 0 > stats_reset
+  # echo 1 > stats_reset
   # cat wq_stats
     global stats:
     total_comp_calls: 0
index 7820062a91e5076f10a53d2affc840311f8f61eb..0f225bdf2279046097384316d19276addae3b196 100644 (file)
@@ -159,7 +159,7 @@ static void device_stats_show(struct seq_file *m, struct iaa_device *iaa_device)
                wq_show(m, iaa_wq);
 }
 
-static void global_stats_show(struct seq_file *m)
+static int global_stats_show(struct seq_file *m, void *v)
 {
        seq_puts(m, "global stats:\n");
        seq_printf(m, "  total_comp_calls: %llu\n", total_comp_calls);
@@ -173,6 +173,8 @@ static void global_stats_show(struct seq_file *m)
                   total_completion_timeout_errors);
        seq_printf(m, "  total_completion_comp_buf_overflow_errors: %llu\n\n",
                   total_completion_comp_buf_overflow_errors);
+
+       return 0;
 }
 
 static int wq_stats_show(struct seq_file *m, void *v)
@@ -181,8 +183,6 @@ static int wq_stats_show(struct seq_file *m, void *v)
 
        mutex_lock(&iaa_devices_lock);
 
-       global_stats_show(m);
-
        list_for_each_entry(iaa_device, &iaa_devices, list)
                device_stats_show(m, iaa_device);
 
@@ -219,6 +219,18 @@ static const struct file_operations wq_stats_fops = {
        .release = single_release,
 };
 
+static int global_stats_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, global_stats_show, file);
+}
+
+static const struct file_operations global_stats_fops = {
+       .open = global_stats_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
 DEFINE_DEBUGFS_ATTRIBUTE(wq_stats_reset_fops, NULL, iaa_crypto_stats_reset, "%llu\n");
 
 int __init iaa_crypto_debugfs_init(void)
@@ -228,16 +240,8 @@ int __init iaa_crypto_debugfs_init(void)
 
        iaa_crypto_debugfs_root = debugfs_create_dir("iaa_crypto", NULL);
 
-       debugfs_create_u64("total_comp_calls", 0644,
-                          iaa_crypto_debugfs_root, &total_comp_calls);
-       debugfs_create_u64("total_decomp_calls", 0644,
-                          iaa_crypto_debugfs_root, &total_decomp_calls);
-       debugfs_create_u64("total_sw_decomp_calls", 0644,
-                          iaa_crypto_debugfs_root, &total_sw_decomp_calls);
-       debugfs_create_u64("total_comp_bytes_out", 0644,
-                          iaa_crypto_debugfs_root, &total_comp_bytes_out);
-       debugfs_create_u64("total_decomp_bytes_in", 0644,
-                          iaa_crypto_debugfs_root, &total_decomp_bytes_in);
+       debugfs_create_file("global_stats", 0644, iaa_crypto_debugfs_root, NULL,
+                           &global_stats_fops);
        debugfs_create_file("wq_stats", 0644, iaa_crypto_debugfs_root, NULL,
                            &wq_stats_fops);
        debugfs_create_file("stats_reset", 0644, iaa_crypto_debugfs_root, NULL,