linux/kstat: allow multi-level module names

Module names are mapped directly to directory names in procfs, but
nothing is done to create the intermediate directories, or remove them.
This makes it impossible to sensibly present kstats about sub-objects.

This commit loops through '/'-separated names in the full module name,
creates a separate module for each, and hooks them up with a parent
pointer and child counter, and then unrolls this on the other side when
deleting a module.

Sponsored-by: Klara, Inc.
Sponsored-by: Syneto
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
Rob Norris
2024-04-29 15:26:56 +10:00
committed by Tony Hutter
parent 5b5a514955
commit d28d2e3007
2 changed files with 87 additions and 25 deletions
+6
View File
@@ -21,6 +21,10 @@
* You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (c) 2024-2025, Klara, Inc.
* Copyright (c) 2024-2025, Syneto
*/
#ifndef _SPL_KSTAT_H
#define _SPL_KSTAT_H
@@ -90,6 +94,8 @@ typedef struct kstat_module {
struct list_head ksm_module_list; /* module linkage */
struct list_head ksm_kstat_list; /* list of kstat entries */
struct proc_dir_entry *ksm_proc; /* proc entry */
struct kstat_module *ksm_parent; /* parent module in hierarchy */
uint_t ksm_nchildren; /* number of child modules */
} kstat_module_t;
typedef struct kstat_raw_ops {