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
This commit is contained in:
parent
f3cbeacaa0
commit
4af4a88e0c
@ -22,6 +22,8 @@
|
|||||||
#define RMID_VAL_ERROR BIT_ULL(63)
|
#define RMID_VAL_ERROR BIT_ULL(63)
|
||||||
#define RMID_VAL_UNAVAIL BIT_ULL(62)
|
#define RMID_VAL_UNAVAIL BIT_ULL(62)
|
||||||
|
|
||||||
|
DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct mon_evt - Entry in the event list of a resource
|
* struct mon_evt - Entry in the event list of a resource
|
||||||
* @evtid: event id
|
* @evtid: event id
|
||||||
@ -59,6 +61,8 @@ extern bool rdt_alloc_capable;
|
|||||||
extern bool rdt_mon_capable;
|
extern bool rdt_mon_capable;
|
||||||
extern unsigned int rdt_mon_features;
|
extern unsigned int rdt_mon_features;
|
||||||
|
|
||||||
|
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
|
||||||
|
|
||||||
enum rdt_group_type {
|
enum rdt_group_type {
|
||||||
RDTCTRL_GROUP = 0,
|
RDTCTRL_GROUP = 0,
|
||||||
RDTMON_GROUP,
|
RDTMON_GROUP,
|
||||||
|
@ -343,6 +343,7 @@ void mon_event_count(void *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dom_data_init(struct rdt_resource *r)
|
static int dom_data_init(struct rdt_resource *r)
|
||||||
{
|
{
|
||||||
struct rmid_entry *entry = NULL;
|
struct rmid_entry *entry = NULL;
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include <asm/intel_rdt_sched.h>
|
#include <asm/intel_rdt_sched.h>
|
||||||
#include "intel_rdt.h"
|
#include "intel_rdt.h"
|
||||||
|
|
||||||
|
DEFINE_STATIC_KEY_FALSE(rdt_enable_key);
|
||||||
|
DEFINE_STATIC_KEY_FALSE(rdt_mon_enable_key);
|
||||||
DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
|
DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
|
||||||
static struct kernfs_root *rdt_root;
|
static struct kernfs_root *rdt_root;
|
||||||
struct rdtgroup rdtgroup_default;
|
struct rdtgroup rdtgroup_default;
|
||||||
@ -43,6 +45,12 @@ LIST_HEAD(rdt_all_groups);
|
|||||||
/* Kernel fs node for "info" directory under root */
|
/* Kernel fs node for "info" directory under root */
|
||||||
static struct kernfs_node *kn_info;
|
static struct kernfs_node *kn_info;
|
||||||
|
|
||||||
|
/* Kernel fs node for "mon_groups" directory under root */
|
||||||
|
static struct kernfs_node *kn_mongrp;
|
||||||
|
|
||||||
|
/* Kernel fs node for "mon_data" directory under root */
|
||||||
|
static struct kernfs_node *kn_mondata;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trivial allocator for CLOSIDs. Since h/w only supports a small number,
|
* Trivial allocator for CLOSIDs. Since h/w only supports a small number,
|
||||||
* we can keep a bitmap of free CLOSIDs in a single integer.
|
* we can keep a bitmap of free CLOSIDs in a single integer.
|
||||||
@ -1044,6 +1052,10 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mkdir_mondata_all(struct kernfs_node *parent_kn,
|
||||||
|
struct rdtgroup *prgrp,
|
||||||
|
struct kernfs_node **mon_data_kn);
|
||||||
|
|
||||||
static struct dentry *rdt_mount(struct file_system_type *fs_type,
|
static struct dentry *rdt_mount(struct file_system_type *fs_type,
|
||||||
int flags, const char *unused_dev_name,
|
int flags, const char *unused_dev_name,
|
||||||
void *data)
|
void *data)
|
||||||
@ -1055,7 +1067,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
|
|||||||
/*
|
/*
|
||||||
* resctrl file system can only be mounted once.
|
* resctrl file system can only be mounted once.
|
||||||
*/
|
*/
|
||||||
if (static_branch_unlikely(&rdt_alloc_enable_key)) {
|
if (static_branch_unlikely(&rdt_enable_key)) {
|
||||||
dentry = ERR_PTR(-EBUSY);
|
dentry = ERR_PTR(-EBUSY);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1074,15 +1086,47 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type,
|
|||||||
goto out_cdp;
|
goto out_cdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rdt_mon_capable) {
|
||||||
|
ret = mongroup_create_dir(rdtgroup_default.kn,
|
||||||
|
NULL, "mon_groups",
|
||||||
|
&kn_mongrp);
|
||||||
|
if (ret) {
|
||||||
|
dentry = ERR_PTR(ret);
|
||||||
|
goto out_info;
|
||||||
|
}
|
||||||
|
kernfs_get(kn_mongrp);
|
||||||
|
|
||||||
|
ret = mkdir_mondata_all(rdtgroup_default.kn,
|
||||||
|
&rdtgroup_default, &kn_mondata);
|
||||||
|
if (ret) {
|
||||||
|
dentry = ERR_PTR(ret);
|
||||||
|
goto out_mongrp;
|
||||||
|
}
|
||||||
|
kernfs_get(kn_mondata);
|
||||||
|
rdtgroup_default.mon.mon_data_kn = kn_mondata;
|
||||||
|
}
|
||||||
|
|
||||||
dentry = kernfs_mount(fs_type, flags, rdt_root,
|
dentry = kernfs_mount(fs_type, flags, rdt_root,
|
||||||
RDTGROUP_SUPER_MAGIC, NULL);
|
RDTGROUP_SUPER_MAGIC, NULL);
|
||||||
if (IS_ERR(dentry))
|
if (IS_ERR(dentry))
|
||||||
goto out_destroy;
|
goto out_mondata;
|
||||||
|
|
||||||
static_branch_enable(&rdt_alloc_enable_key);
|
if (rdt_alloc_capable)
|
||||||
|
static_branch_enable(&rdt_alloc_enable_key);
|
||||||
|
if (rdt_mon_capable)
|
||||||
|
static_branch_enable(&rdt_mon_enable_key);
|
||||||
|
|
||||||
|
if (rdt_alloc_capable || rdt_mon_capable)
|
||||||
|
static_branch_enable(&rdt_enable_key);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
out_destroy:
|
out_mondata:
|
||||||
|
if (rdt_mon_capable)
|
||||||
|
kernfs_remove(kn_mondata);
|
||||||
|
out_mongrp:
|
||||||
|
if (rdt_mon_capable)
|
||||||
|
kernfs_remove(kn_mongrp);
|
||||||
|
out_info:
|
||||||
kernfs_remove(kn_info);
|
kernfs_remove(kn_info);
|
||||||
out_cdp:
|
out_cdp:
|
||||||
cdp_disable();
|
cdp_disable();
|
||||||
@ -1204,6 +1248,9 @@ static void rmdir_all_sub(void)
|
|||||||
rdt_move_group_tasks(NULL, &rdtgroup_default, NULL);
|
rdt_move_group_tasks(NULL, &rdtgroup_default, NULL);
|
||||||
|
|
||||||
list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) {
|
list_for_each_entry_safe(rdtgrp, tmp, &rdt_all_groups, rdtgroup_list) {
|
||||||
|
/* Free any child rmids */
|
||||||
|
free_all_child_rdtgrp(rdtgrp);
|
||||||
|
|
||||||
/* Remove each rdtgroup other than root */
|
/* Remove each rdtgroup other than root */
|
||||||
if (rdtgrp == &rdtgroup_default)
|
if (rdtgrp == &rdtgroup_default)
|
||||||
continue;
|
continue;
|
||||||
@ -1216,6 +1263,8 @@ static void rmdir_all_sub(void)
|
|||||||
cpumask_or(&rdtgroup_default.cpu_mask,
|
cpumask_or(&rdtgroup_default.cpu_mask,
|
||||||
&rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);
|
&rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask);
|
||||||
|
|
||||||
|
free_rmid(rdtgrp->mon.rmid);
|
||||||
|
|
||||||
kernfs_remove(rdtgrp->kn);
|
kernfs_remove(rdtgrp->kn);
|
||||||
list_del(&rdtgrp->rdtgroup_list);
|
list_del(&rdtgrp->rdtgroup_list);
|
||||||
kfree(rdtgrp);
|
kfree(rdtgrp);
|
||||||
@ -1226,6 +1275,8 @@ static void rmdir_all_sub(void)
|
|||||||
put_online_cpus();
|
put_online_cpus();
|
||||||
|
|
||||||
kernfs_remove(kn_info);
|
kernfs_remove(kn_info);
|
||||||
|
kernfs_remove(kn_mongrp);
|
||||||
|
kernfs_remove(kn_mondata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rdt_kill_sb(struct super_block *sb)
|
static void rdt_kill_sb(struct super_block *sb)
|
||||||
@ -1240,6 +1291,8 @@ static void rdt_kill_sb(struct super_block *sb)
|
|||||||
cdp_disable();
|
cdp_disable();
|
||||||
rmdir_all_sub();
|
rmdir_all_sub();
|
||||||
static_branch_disable(&rdt_alloc_enable_key);
|
static_branch_disable(&rdt_alloc_enable_key);
|
||||||
|
static_branch_disable(&rdt_mon_enable_key);
|
||||||
|
static_branch_disable(&rdt_enable_key);
|
||||||
kernfs_kill_sb(sb);
|
kernfs_kill_sb(sb);
|
||||||
mutex_unlock(&rdtgroup_mutex);
|
mutex_unlock(&rdtgroup_mutex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user