lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Nov 2022 10:35:26 -0800
From:   Kristen Carlson Accardi <kristen@...ux.intel.com>
To:     jarkko@...nel.org, dave.hansen@...ux.kernel.org, tj@...nel.org,
        linux-kernel@...r.kernel.org, linux-sgx@...r.kernel.org,
        cgroups@...r.kernel.org, Zefan Li <lizefan.x@...edance.com>,
        Johannes Weiner <hannes@...xchg.org>
Cc:     zhiquan1.li@...el.com,
        Kristen Carlson Accardi <kristen@...ux.intel.com>
Subject: [PATCH 21/26] cgroup/misc: allow misc cgroup consumers to read the max value

The SGX driver will need to be able to read the max value per cgroup
to determine how far usage is from max. Add an api to return the
max value of the given cgroup.

Signed-off-by: Kristen Carlson Accardi <kristen@...ux.intel.com>
---
 include/linux/misc_cgroup.h |  6 ++++++
 kernel/cgroup/misc.c        | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h
index a9dd087132dc..c00deae4d2df 100644
--- a/include/linux/misc_cgroup.h
+++ b/include/linux/misc_cgroup.h
@@ -62,6 +62,7 @@ struct misc_cg {
 struct misc_cg *root_misc(void);
 struct misc_cg *parent_misc(struct misc_cg *cg);
 unsigned long misc_cg_read(enum misc_res_type type, struct misc_cg *cg);
+unsigned long misc_cg_max(enum misc_res_type type, struct misc_cg *cg);
 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,
@@ -124,6 +125,11 @@ static inline unsigned long misc_cg_read(enum misc_res_type type, struct misc_cg
 	return 0;
 }
 
+static inline unsigned long misc_cg_max(enum misc_res_type type, struct misc_cg *cg)
+{
+	return 0;
+}
+
 static inline unsigned long misc_cg_res_total_usage(enum misc_res_type type)
 {
 	return 0;
diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c
index e2c99fdc1d40..18d0bec7d609 100644
--- a/kernel/cgroup/misc.c
+++ b/kernel/cgroup/misc.c
@@ -232,6 +232,25 @@ unsigned long misc_cg_read(enum misc_res_type type, struct misc_cg *cg)
 }
 EXPORT_SYMBOL_GPL(misc_cg_read);
 
+/**
+ * misc_cg_max() - Return the max value of the misc cgroup res.
+ * @type: Type of the misc res.
+ * @cg: Misc cgroup whose max will be read
+ *
+ * Context: Any context.
+ * Return:
+ * 	The max value of the specified misc cgroup.
+ * 	If an invalid misc_res_type is given, zero will be returned.
+ */
+unsigned long misc_cg_max(enum misc_res_type type, struct misc_cg *cg)
+{
+	if (!(valid_type(type) && cg))
+		return 0;
+
+	return READ_ONCE(cg->res[type].max);
+}
+EXPORT_SYMBOL_GPL(misc_cg_max);
+
 /**
  * misc_cg_max_show() - Show the misc cgroup max limit.
  * @sf: Interface file
-- 
2.37.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ