diff options
author | Vikas Shivappa <vikas.shivappa@linux.intel.com> | 2017-07-25 17:14:41 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-08-01 16:41:27 -0400 |
commit | 4af4a88e0c9246990f95c88eeba781265f27c58e (patch) | |
tree | f9f85cf01d25aec85ce75035c2d08df4ab54ea51 | |
parent | f3cbeacaa06e2b8c2f3ce8531e9aa3fe1f2762cd (diff) |
x86/intel_rdt/cqm: Add mount,umount support
Add monitoring support during mount and unmount. Since root directory is
a "ctrl_mon" directory which can control and monitor resources create
the "mon_groups" directory which can hold monitor groups and a
"mon_data" directory which would hold all monitoring data like the rest
of resource groups.
The mount succeeds if either of monitoring or control/allocation is
enabled. If only monitoring is enabled user can still create monitor
groups under the "/sys/fs/resctrl/mon_groups/" and any mkdir under root
would fail. If only control/allocation is enabled all of the monitoring
related directories/files would not exist and resctrl would work in
legacy mode.
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: ravi.v.shankar@intel.com
Cc: tony.luck@intel.com
Cc: fenghua.yu@intel.com
Cc: peterz@infradead.org
Cc: eranian@google.com
Cc: vikas.shivappa@intel.com
Cc: ak@linux.intel.com
Cc: davidcc@google.com
Cc: reinette.chatre@intel.com
Link: http://lkml.kernel.org/r/1501017287-28083-23-git-send-email-vikas.shivappa@linux.intel.com
-rw-r--r-- | arch/x86/kernel/cpu/intel_rdt.h | 4 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_monitor.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 61 |
3 files changed, 62 insertions, 4 deletions
diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 7fcaa5f82bd0..92a5d3072d93 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h | |||
@@ -22,6 +22,8 @@ | |||
22 | #define RMID_VAL_ERROR BIT_ULL(63) | 22 | #define RMID_VAL_ERROR BIT_ULL(63) |
23 | #define RMID_VAL_UNAVAIL BIT_ULL(62) | 23 | #define RMID_VAL_UNAVAIL BIT_ULL(62) |
24 | 24 | ||
25 | DECLARE_STATIC_KEY_FALSE(rdt_enable_key); | ||
26 | |||
25 | /** | 27 | /** |
26 | * struct mon_evt - Entry in the event list of a resource | 28 | * struct mon_evt - Entry in the event list of a resource |
27 | * @evtid: event id | 29 | * @evtid: event id |
@@ -59,6 +61,8 @@ extern bool rdt_alloc_capable; | |||
59 | extern bool rdt_mon_capable; | 61 | extern bool rdt_mon_capable; |
60 | extern unsigned int rdt_mon_features; | 62 | extern unsigned int rdt_mon_features; |
61 | 63 | ||
64 | DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); | ||
65 | |||
62 | enum rdt_group_type { | 66 | enum rdt_group_type { |
63 | RDTCTRL_GROUP = 0, | 67 | RDTCTRL_GROUP = 0, |
64 | RDTMON_GROUP, | 68 | RDTMON_GROUP, |
diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c index f8f06f5b7fc3..6ae5cf58e50a 100644 --- a/arch/x86/kernel/cpu/intel_rdt_monitor.c +++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c | |||
@@ -343,6 +343,7 @@ void mon_event_count(void *info) | |||
343 | } | 343 | } |
344 | } | 344 | } |
345 | } | 345 | } |
346 | |||
346 | static int dom_data_init(struct rdt_resource *r) | 347 | static int dom_data_init(struct rdt_resource *r) |
347 | { | 348 | { |
348 | struct rmid_entry *entry = NULL; | 349 | struct rmid_entry *entry = NULL; |
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index e61908169dca..0a7be9b7a201 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <asm/intel_rdt_sched.h> | 35 | #include <asm/intel_rdt_sched.h> |
36 | #include "intel_rdt.h" | 36 | #include "intel_rdt.h" |
37 | 37 | ||
38 | DEFINE_STATIC_KEY_FALSE(rdt_enable_key); | ||
39 | DEFINE_STATIC_KEY_FALSE(rdt_mon_enable_key); | ||
38 | DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key); | 40 | DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key); |
39 | static struct kernfs_root *rdt_root; | 41 | static struct kernfs_root *rdt_root; |
40 | struct rdtgroup rdtgroup_default; | 42 | struct rdtgroup rdtgroup_default; |
@@ -43,6 +45,12 @@ LIST_HEAD(rdt_all_groups); | |||
43 | /* Kernel fs node for "info" directory under root */ | 45 | /* Kernel fs node for "info" directory under root */ |
44 | static struct kernfs_node *kn_info; | 46 | static struct kernfs_node *kn_info; |
45 | 47 | ||
48 | /* Kernel fs node for "mon_groups" directory under root */ | ||
49 | static struct kernfs_node *kn_mongrp; | ||
50 | |||
51 | /* Kernel fs node for "mon_data" directory under root */ | ||
52 | static struct kernfs_node *kn_mondata; | ||
53 | |||
46 | /* | 54 | /* |
47 | * Trivial allocator for CLOSIDs. Since h/w only supports a small number, | 55 | * Trivial allocator for CLOSIDs. Since h/w only supports a small number, |
48 | * we can keep a bitmap of free CLOSIDs in a single integer. | 56 | * we can keep a bitmap of free CLOSIDs in a single integer. |
@@ -1044,6 +1052,10 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn) | |||
1044 | } | 1052 | } |
1045 | } | 1053 | } |
1046 | 1054 | ||
1055 | static int mkdir_mondata_all(struct kernfs_node *parent_kn, | ||
1056 | struct rdtgroup *prgrp, | ||
1057 | struct kernfs_node **mon_data_kn); | ||
1058 | |||
1047 | static struct dentry *rdt_mount(struct file_system_type *fs_type, | 1059 | static struct dentry *rdt_mount(struct file_system_type *fs_type, |
1048 | int flags, const char *unused_dev_name, | 1060 | int flags, const char *unused_dev_name, |
1049 | void *data) | 1061 | void *data) |
@@ -1055,7 +1067,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type, | |||
1055 | /* | 1067 | /* |
1056 | * resctrl file system can only be mounted once. | 1068 | * resctrl file system can only be mounted once. |
1057 | */ | 1069 | */ |
1058 | if (static_branch_unlikely(&rdt_alloc_enable_key)) { | 1070 | if (static_branch_unlikely(&rdt_enable_key)) { |
1059 | dentry = ERR_PTR(-EBUSY); | 1071 | dentry = ERR_PTR(-EBUSY); |
1060 | goto out; | 1072 | goto out; |
1061 | } | 1073 | } |
@@ -1074,15 +1086,47 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type, | |||
1074 | goto out_cdp; | 1086 | goto out_cdp; |
1075 | } | 1087 | } |
1076 | 1088 | ||
1089 | if (rdt_mon_capable) { | ||
1090 | ret = mongroup_create_dir(rdtgroup_default.kn, | ||
1091 | NULL, "mon_groups", | ||
1092 | &kn_mongrp); | ||
1093 | if (ret) { | ||
1094 | dentry = ERR_PTR(ret); | ||
1095 | goto out_info; | ||
1096 | } | ||
1097 | kernfs_get(kn_mongrp); | ||
1098 | |||
1099 | ret = mkdir_mondata_all(rdtgroup_default.kn, | ||
1100 | &rdtgroup_default, &kn_mondata); | ||
1101 | if (ret) { | ||
1102 | dentry = ERR_PTR(ret); | ||
1103 | goto out_mongrp; | ||
1104 | } | ||
1105 | kernfs_get(kn_mondata); | ||
1106 | rdtgroup_default.mon.mon_data_kn = kn_mondata; | ||
1107 | } | ||
1108 | |||
1077 | dentry = kernfs_mount(fs_type, flags, rdt_root, | 1109 | dentry = kernfs_mount(fs_type, flags, rdt_root, |
1078 | RDTGROUP_SUPER_MAGIC, NULL); | 1110 | RDTGROUP_SUPER_MAGIC, NULL); |
1079 | if (IS_ERR(dentry)) | 1111 | if (IS_ERR(dentry)) |
1080 | goto out_destroy; | 1112 | goto out_mondata; |
1081 | 1113 | ||
1082 | static_branch_enable(&rdt_alloc_enable_key); | 1114 | if (rdt_alloc_capable) |
1115 | static_branch_enable(&rdt_alloc_enable_key); | ||
1116 | if (rdt_mon_capable) | ||
1117 | static_branch_enable(&rdt_mon_enable_key); | ||
1118 | |||
1119 | if (rdt_alloc_capable || rdt_mon_capable) | ||
1120 | static_branch_enable(&rdt_enable_key); | ||
1083 | goto out; | 1121 | goto out; |
1084 | 1122 | ||
1085 | out_destroy: | 1123 | out_mondata: |
1124 | if (rdt_mon_capable) | ||
1125 | kernfs_remove(kn_mondata); | ||
1126 | out_mongrp: | ||
1127 | if (rdt_mon_capable) | ||
1128 | kernfs_remove(kn_mongrp); | ||
1129 | out_info: | ||
1086 | kernfs_remove(kn_info); | 1130 | kernfs_remove(kn_info); |
1087 | out_cdp: | 1131 | out_cdp: |
1088 | cdp_disable(); | 1132 | cdp_disable(); |
@@ -1204,6 +1248,9 @@ static void rmdir_all_sub(void) | |||
1204 | rdt_move_group_tasks(NULL, &rdtgroup_default, NULL); | 1248 | rdt_move_group_tasks(NULL, &rdtgroup_default, NULL); |
1205 | 1249 | ||
1206 | list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) { | 1250 | list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) { |
1251 | /* Free any child rmids */ | ||
1252 | free_all_child_rdtgrp(rdtgrp); | ||
1253 | |||
1207 | /* Remove each rdtgroup other than root */ | 1254 | /* Remove each rdtgroup other than root */ |
1208 | if (rdtgrp == &rdtgroup_default) | 1255 | if (rdtgrp == &rdtgroup_default) |
1209 | continue; | 1256 | continue; |
@@ -1216,6 +1263,8 @@ static void rmdir_all_sub(void) | |||
1216 | cpumask_or(&rdtgroup_default.cpu_mask, | 1263 | cpumask_or(&rdtgroup_default.cpu_mask, |
1217 | &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); | 1264 | &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); |
1218 | 1265 | ||
1266 | free_rmid(rdtgrp->mon.rmid); | ||
1267 | |||
1219 | kernfs_remove(rdtgrp->kn); | 1268 | kernfs_remove(rdtgrp->kn); |
1220 | list_del(&rdtgrp->rdtgroup_list); | 1269 | list_del(&rdtgrp->rdtgroup_list); |
1221 | kfree(rdtgrp); | 1270 | kfree(rdtgrp); |
@@ -1226,6 +1275,8 @@ static void rmdir_all_sub(void) | |||
1226 | put_online_cpus(); | 1275 | put_online_cpus(); |
1227 | 1276 | ||
1228 | kernfs_remove(kn_info); | 1277 | kernfs_remove(kn_info); |
1278 | kernfs_remove(kn_mongrp); | ||
1279 | kernfs_remove(kn_mondata); | ||
1229 | } | 1280 | } |
1230 | 1281 | ||
1231 | static void rdt_kill_sb(struct super_block *sb) | 1282 | static void rdt_kill_sb(struct super_block *sb) |
@@ -1240,6 +1291,8 @@ static void rdt_kill_sb(struct super_block *sb) | |||
1240 | cdp_disable(); | 1291 | cdp_disable(); |
1241 | rmdir_all_sub(); | 1292 | rmdir_all_sub(); |
1242 | static_branch_disable(&rdt_alloc_enable_key); | 1293 | static_branch_disable(&rdt_alloc_enable_key); |
1294 | static_branch_disable(&rdt_mon_enable_key); | ||
1295 | static_branch_disable(&rdt_enable_key); | ||
1243 | kernfs_kill_sb(sb); | 1296 | kernfs_kill_sb(sb); |
1244 | mutex_unlock(&rdtgroup_mutex); | 1297 | mutex_unlock(&rdtgroup_mutex); |
1245 | } | 1298 | } |