[18/26] cgroup/misc: Expose root_misc
Commit Message
The SGX driver will need to get access to the root misc_cg object
to do iterative walks and also determine if a charge will be
towards the root cgroup or not.
Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
---
include/linux/misc_cgroup.h | 5 +++++
kernel/cgroup/misc.c | 9 +++++++++
2 files changed, 14 insertions(+)
Comments
On Fri, Nov 11, 2022 at 10:35:23AM -0800, Kristen Carlson Accardi wrote:
> diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h
> index 8f1b7b6cb81d..b79c78378f17 100644
> --- a/include/linux/misc_cgroup.h
> +++ b/include/linux/misc_cgroup.h
> @@ -59,6 +59,7 @@ struct misc_cg {
> struct misc_res res[MISC_CG_RES_TYPES];
> };
>
> +struct misc_cg *root_misc(void);
This is too generic a name to expose globally. Can we do sth like
cgrp_misc_root()?
Thanks.
@@ -59,6 +59,7 @@ struct misc_cg {
struct misc_res res[MISC_CG_RES_TYPES];
};
+struct misc_cg *root_misc(void);
unsigned long misc_cg_res_total_usage(enum misc_res_type type);
int misc_cg_set_capacity(enum misc_res_type type, unsigned long capacity);
int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg,
@@ -106,6 +107,10 @@ static inline void put_misc_cg(struct misc_cg *cg)
}
#else /* !CONFIG_CGROUP_MISC */
+static inline struct misc_cg *root_misc(void)
+{
+ return NULL;
+}
static inline unsigned long misc_cg_res_total_usage(enum misc_res_type type)
{
@@ -45,6 +45,15 @@ static unsigned long misc_res_capacity[MISC_CG_RES_TYPES];
*/
static BLOCKING_NOTIFIER_HEAD(misc_cg_notify_list);
+/**
+ * root_misc() - Return the root misc cgroup.
+ */
+struct misc_cg *root_misc(void)
+{
+ return &root_cg;
+}
+EXPORT_SYMBOL_GPL(root_misc);
+
/**
* parent_misc() - Get the parent of the passed misc cgroup.
* @cgroup: cgroup whose parent needs to be fetched.