From: Tony Luck <tony.luck@intel.com>
To: Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Shaopeng Tan <tan.shaopeng@fujitsu.com>,
Jamie Iles <quic_jiles@quicinc.com>,
James Morse <james.morse@arm.com>,
Babu Moger <babu.moger@amd.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Tony Luck <tony.luck@intel.com>
Subject: [RFC PATCH 5/7] x86/resctrl: Enhance driver registration to hook into schemata files
Date: Thu, 20 Apr 2023 15:06:34 -0700 [thread overview]
Message-ID: <20230420220636.53527-6-tony.luck@intel.com> (raw)
In-Reply-To: <20230420220636.53527-1-tony.luck@intel.com>
Add a new configuration type "DRIVER" for lines in the schemata files
with a show() and update() callback functions to the driver to maintain
these lines.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
include/linux/resctrl.h | 6 ++++++
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 17 ++++++++++++++---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 8668480cea51..691805214f41 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -23,11 +23,13 @@ int proc_resctrl_show(struct seq_file *m,
* @CDP_NONE: No prioritisation, both code and data are controlled or monitored.
* @CDP_CODE: Configuration applies to instruction fetches.
* @CDP_DATA: Configuration applies to reads and writes.
+ * @DRIVER: Resource managed by driver.
*/
enum resctrl_conf_type {
CDP_NONE,
CDP_CODE,
CDP_DATA,
+ DRIVER,
};
#define CDP_NUM_TYPES (CDP_DATA + 1)
@@ -201,6 +203,8 @@ struct resctrl_schema {
char name[8];
enum resctrl_conf_type conf_type;
struct rdt_resource *res;
+ void (*show)(struct seq_file *s, int closid);
+ int (*update)(char *s, int closid);
u32 num_closid;
};
@@ -218,6 +222,7 @@ struct resctrl_fileinfo {
* @infofiles: Array of files to create under infodir.
* @rmdir: Callback when a resctrl directory is removed.
* @ctrlfiles: Array of files to create in ctrlmon directories.
+ * @schema: Driver supplied to manage a line in schemata file.
*/
struct resctrl_driver {
struct list_head list;
@@ -226,6 +231,7 @@ struct resctrl_driver {
struct resctrl_fileinfo *infofiles;
int (*rmdir)(int oclos, int ormid, int nclos, int nrmid);
struct resctrl_fileinfo *ctrlfiles;
+ struct resctrl_schema schema;
};
int resctrl_register_driver(struct resctrl_driver *d);
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index b44c487727d4..7a59d6eab576 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -356,8 +356,12 @@ static int rdtgroup_parse_resource(char *resname, char *tok,
struct resctrl_schema *s;
list_for_each_entry(s, &resctrl_schema_all, list) {
- if (!strcmp(resname, s->name) && rdtgrp->closid < s->num_closid)
- return parse_line(tok, s, rdtgrp);
+ if (!strcmp(resname, s->name) && rdtgrp->closid < s->num_closid) {
+ if (s->conf_type == DRIVER)
+ return s->update(tok, rdtgrp->closid);
+ else
+ return parse_line(tok, s, rdtgrp);
+ }
}
rdt_last_cmd_printf("Unknown or unsupported resource name '%s'\n", resname);
return -EINVAL;
@@ -419,10 +423,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
r = s->res;
/*
+ * Resources controlled by a driver are updated by that driver.
* Writes to mba_sc resources update the software controller,
* not the control MSR.
*/
- if (is_mba_sc(r))
+ if (s->conf_type == DRIVER || is_mba_sc(r))
continue;
ret = resctrl_arch_update_domains(r, rdtgrp->closid);
@@ -464,6 +469,12 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo
u32 ctrl_val;
seq_printf(s, "%*s:", max_name_width, schema->name);
+
+ if (schema->conf_type == DRIVER) {
+ schema->show(s, closid);
+ return;
+ }
+
list_for_each_entry(dom, &r->domains, list) {
if (sep)
seq_puts(s, ";");
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index e2fdd5819336..cc2292a7435b 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2043,6 +2043,8 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)
/* loop over enabled controls, these are all alloc_capable */
list_for_each_entry(s, &resctrl_schema_all, list) {
+ if (s->conf_type == DRIVER)
+ continue;
r = s->res;
fflags = r->fflags | RF_CTRL_INFO;
ret = rdtgroup_mkdir_info_resdir(s, s->name, fflags);
@@ -2390,6 +2392,9 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
case CDP_NONE:
suffix = "";
break;
+ case DRIVER:
+ kfree(s);
+ return -EINVAL;
}
ret = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
@@ -2567,6 +2572,9 @@ int resctrl_register_driver(struct resctrl_driver *d)
mutex_lock(&rdtgroup_mutex);
list_add(&d->list, &drivers);
+ if (d->schema.name[0])
+ list_add(&d->schema.list, &resctrl_schema_all);
+
if (resctrl_is_mounted)
driver_up(d);
mutex_unlock(&rdtgroup_mutex);
@@ -2578,8 +2586,12 @@ EXPORT_SYMBOL_GPL(resctrl_register_driver);
void resctrl_unregister_driver(struct resctrl_driver *d)
{
mutex_lock(&rdtgroup_mutex);
+
list_del(&d->list);
+ if (d->schema.name[0])
+ list_del(&d->schema.list);
+
if (resctrl_is_mounted)
driver_down(d);
mutex_unlock(&rdtgroup_mutex);
@@ -2591,6 +2603,8 @@ static void schemata_list_destroy(void)
struct resctrl_schema *s, *tmp;
list_for_each_entry_safe(s, tmp, &resctrl_schema_all, list) {
+ if (s->conf_type == DRIVER)
+ continue;
list_del(&s->list);
kfree(s);
}
@@ -3285,6 +3299,8 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
rdt_staged_configs_clear();
list_for_each_entry(s, &resctrl_schema_all, list) {
+ if (s->conf_type == DRIVER)
+ continue;
r = s->res;
if (r->rid == RDT_RESOURCE_MBA ||
r->rid == RDT_RESOURCE_SMBA) {
--
2.39.2
next prev parent reply other threads:[~2023-04-20 22:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 22:06 [RFC PATCH 0/7] Add driver registration i/f to resctrl Tony Luck
2023-04-20 22:06 ` [RFC PATCH 1/7] x86/resctrl: Add register/unregister functions for driver to hook into resctrl Tony Luck
2023-05-05 23:17 ` Reinette Chatre
2023-04-20 22:06 ` [RFC PATCH 2/7] x86/resctrl: Add an interface to add/remove a new info/directory Tony Luck
2023-04-20 22:06 ` [RFC PATCH 3/7] x86/resctrl: Add driver callback when directories are removed Tony Luck
2023-05-05 23:19 ` Reinette Chatre
2023-04-20 22:06 ` [RFC PATCH 4/7] x86/resctrl: Add capability to driver registration to create control files Tony Luck
2023-05-05 23:20 ` Reinette Chatre
2023-04-20 22:06 ` Tony Luck [this message]
2023-05-05 23:20 ` [RFC PATCH 5/7] x86/resctrl: Enhance driver registration to hook into schemata files Reinette Chatre
2023-04-20 22:06 ` [RFC PATCH 6/7] x86/resctrl: Allow a device to override an existing schemata entry Tony Luck
2023-05-05 23:20 ` Reinette Chatre
2023-04-20 22:06 ` [RFC PATCH 7/7] x86/resctrl: Example resctrl driver Tony Luck
2023-05-05 23:17 ` [RFC PATCH 0/7] Add driver registration i/f to resctrl Reinette Chatre
2023-05-08 18:32 ` Luck, Tony
2023-05-09 21:34 ` Reinette Chatre
2023-05-09 23:35 ` Luck, Tony
2023-05-10 0:07 ` Reinette Chatre
2023-05-10 0:52 ` Luck, Tony
2023-05-11 20:35 ` Luck, Tony
2023-05-12 16:57 ` Reinette Chatre
2023-05-12 20:35 ` Luck, Tony
2023-05-12 21:08 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230420220636.53527-6-tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=quic_jiles@quicinc.com \
--cc=reinette.chatre@intel.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox