Re: [PATCH v5 17/20] x86/resctrl: Introduce the interface switch between monitor modes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Reinette,

On 7/12/2024 5:14 PM, Reinette Chatre wrote:
Hi Babu,

On 7/3/24 2:48 PM, Babu Moger wrote:
Introduce interface to switch between ABMC and legacy modes.

By default ABMC is enabled on boot if the feature is available.
Provide the interface to go back to legacy mode if required.

$ cat /sys/fs/resctrl/info/L3_MON/mbm_mode
[abmc]
legacy

To enable the legacy monitoring feature:
$ echo "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v4: Minor commit text changes. Keep the default to ABMC when supported.
     Fixed comments to reflect changed interface "mbm_mode".

v3: New patch to address the review comments from upstream.
---
  Documentation/arch/x86/resctrl.rst     | 10 +++++++
  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++-
  2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
index 11b7a5f26b40..4c41c5622627 100644
--- a/Documentation/arch/x86/resctrl.rst
+++ b/Documentation/arch/x86/resctrl.rst
@@ -291,6 +291,16 @@ with the following files:
      Without ABMC enabled, monitoring will work in "legacy" mode
      without assignment option.
+    * To enable ABMC feature:
+      ::
+
+        # echo  "abmc" > /sys/fs/resctrl/info/L3_MON/mbm_mode
+
+    * To enable the legacy monitoring feature:
+      ::
+
+        # echo  "legacy" > /sys/fs/resctrl/info/L3_MON/mbm_mode
+

Needs details on what user can expect to happen to counters/data when
switching between modes.

Sure. Will add the details.


  "num_mbm_cntrs":
      The number of monitoring counters available for assignment.
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 475a0c7b2a25..531233779f8d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -910,6 +910,40 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of,
      return 0;
  }
+static ssize_t rdtgroup_mbm_mode_write(struct kernfs_open_file *of,
+                       char *buf, size_t nbytes,
+                       loff_t off)
+{
+    struct rdt_resource *r = of->kn->parent->priv;
+    int ret = 0;
+
+    if (!r->mon.abmc_capable)
+        return -EINVAL;
+

Why should a user not be able to write "legacy" into this
file if "legacy" is the only mode supported?

Yes. Will fix it.


+    /* Valid input requires a trailing newline */
+    if (nbytes == 0 || buf[nbytes - 1] != '\n')
+        return -EINVAL;
+
+    buf[nbytes - 1] = '\0';
+
+    cpus_read_lock();
+    mutex_lock(&rdtgroup_mutex);
+
+    rdt_last_cmd_clear();
+
+    if (!strcmp(buf, "legacy"))
+        resctrl_arch_abmc_disable();
+    else if (!strcmp(buf, "abmc"))
+        ret = resctrl_arch_abmc_enable();
+    else
+        ret = -EINVAL;
+
+    mutex_unlock(&rdtgroup_mutex);
+    cpus_read_unlock();
+
+    return ret ?: nbytes;
+}
+
  #ifdef CONFIG_PROC_CPU_RESCTRL
  /*
@@ -2103,9 +2137,10 @@ static struct rftype res_common_files[] = {
      },
      {
          .name        = "mbm_mode",
-        .mode        = 0444,
+        .mode        = 0644,
          .kf_ops        = &rdtgroup_kf_single_ops,
          .seq_show    = rdtgroup_mbm_mode_show,
+        .write        = rdtgroup_mbm_mode_write,
      },
      {
          .name        = "cpus",

Reinette


--
- Babu Moger




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux