x86/intel_rdt: Ensure RDT cleanup on exit
authorReinette Chatre <reinette.chatre@intel.com>
Fri, 22 Jun 2018 22:42:24 +0000 (15:42 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 23 Jun 2018 11:03:50 +0000 (13:03 +0200)
The RDT system's initialization does not have the corresponding exit
handling to ensure everything initialized on load is cleaned up also.

Introduce the cleanup routines that complement all initialization. This
includes the removal of a duplicate rdtgroup_init() declaration.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: vikas.shivappa@linux.intel.com
Cc: gavin.hindman@intel.com
Cc: jithu.joseph@intel.com
Cc: dave.hansen@intel.com
Cc: hpa@zytor.com
Link: https://lkml.kernel.org/r/a9e3a2bbd731d13915d2d7bf05d4f675b4fa109b.1529706536.git.reinette.chatre@intel.com
arch/x86/kernel/cpu/intel_rdt.c
arch/x86/kernel/cpu/intel_rdt.h
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

index ec4754f81cbdcdf4971cafe73698500360da3934..abb71ac704433cea9f2eca68b8f3ed60566c22da 100644 (file)
@@ -859,6 +859,8 @@ static __init bool get_rdt_resources(void)
        return (rdt_mon_capable || rdt_alloc_capable);
 }
 
+static enum cpuhp_state rdt_online;
+
 static int __init intel_rdt_late_init(void)
 {
        struct rdt_resource *r;
@@ -880,6 +882,7 @@ static int __init intel_rdt_late_init(void)
                cpuhp_remove_state(state);
                return ret;
        }
+       rdt_online = state;
 
        for_each_alloc_capable_rdt_resource(r)
                pr_info("Intel RDT %s allocation detected\n", r->name);
@@ -891,3 +894,11 @@ static int __init intel_rdt_late_init(void)
 }
 
 late_initcall(intel_rdt_late_init);
+
+static void __exit intel_rdt_exit(void)
+{
+       cpuhp_remove_state(rdt_online);
+       rdtgroup_exit();
+}
+
+__exitcall(intel_rdt_exit);
index f245aaae514e76329d666506b8df8c6290440cfe..2b3f7619be48801604706808bf2e7b1e76a0ccd6 100644 (file)
@@ -209,6 +209,7 @@ extern struct list_head rdt_all_groups;
 extern int max_name_width, max_data_width;
 
 int __init rdtgroup_init(void);
+void __exit rdtgroup_exit(void);
 
 /**
  * struct rftype - describe each file in the resctrl file system
@@ -431,8 +432,6 @@ extern struct rdt_resource rdt_resources_all[];
 extern struct rdtgroup rdtgroup_default;
 DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
 
-int __init rdtgroup_init(void);
-
 enum {
        RDT_RESOURCE_L3,
        RDT_RESOURCE_L3DATA,
index f301919ae9b263f6c4dcebd1a3eda044babd91d8..9600662493747d08dccdcead2a88519fd07d4af8 100644 (file)
@@ -2828,3 +2828,10 @@ cleanup_root:
 
        return ret;
 }
+
+void __exit rdtgroup_exit(void)
+{
+       unregister_filesystem(&rdt_fs_type);
+       sysfs_remove_mount_point(fs_kobj, "resctrl");
+       kernfs_destroy_root(rdt_root);
+}