From: Reinette Chatre <reinette.chatre@intel.com>
To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
vikas.shivappa@linux.intel.com
Cc: gavin.hindman@intel.com, jithu.joseph@intel.com,
dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, linux-kernel@vger.kernel.org,
Reinette Chatre <reinette.chatre@intel.com>
Subject: [RFC PATCH 3/7] x86/intel_rdt: Enable user to trigger pseudo-locked region restore
Date: Tue, 24 Jul 2018 13:40:14 -0700 [thread overview]
Message-ID: <1905054751d4388177b14de220b6adb708e04c3d.1532463771.git.reinette.chatre@intel.com> (raw)
In-Reply-To: <cover.1532463771.git.reinette.chatre@intel.com>
In-Reply-To: <cover.1532463771.git.reinette.chatre@intel.com>
Expose a new debugfs file that user can use to trigger the restoration
of a specific Cache Pseudo-Locked region at any time.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
Documentation/x86/intel_rdt_ui.txt | 18 ++++++---
arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 45 ++++++++++++++++++++-
2 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/Documentation/x86/intel_rdt_ui.txt b/Documentation/x86/intel_rdt_ui.txt
index f662d3c530e5..4b124a54eee3 100644
--- a/Documentation/x86/intel_rdt_ui.txt
+++ b/Documentation/x86/intel_rdt_ui.txt
@@ -507,6 +507,17 @@ Cache Pseudo-Locking Debugging Interface
The pseudo-locking debugging interface is enabled by default (if
CONFIG_DEBUG_FS is enabled) and can be found in /sys/kernel/debug/resctrl.
+The debugging interface supports the restoration and measurement of the cache
+pseudo-locked region. When a pseudo-locked region is created a new debugfs
+directory is created for it in debugfs as /sys/kernel/debug/resctrl/<newdir>.
+Two write-only files, pseudo_lock_measure and pseudo_lock_restore, are present
+in this directory.
+
+A Cache Pseudo-Locked region can be restored by writing one of 'Yy1' or 'on'
+to pseudo_lock_restore. This would be needed if it is found that the memory
+has been evicted from the cache and will result in the memory being
+pseudo-locked to the original cache region.
+
There is no explicit way for the kernel to test if a provided memory
location is present in the cache. The pseudo-locking debugging interface uses
the tracing infrastructure to provide two ways to measure cache residency of
@@ -525,11 +536,8 @@ the pseudo-locked region:
the system, if any other measurements are in progress the counters and
their corresponding event registers will be clobbered.
-When a pseudo-locked region is created a new debugfs directory is created for
-it in debugfs as /sys/kernel/debug/resctrl/<newdir>. A single
-write-only file, pseudo_lock_measure, is present in this directory. The
-measurement on the pseudo-locked region depends on the number, 1 or 2,
-written to this debugfs file. Since the measurements are recorded with the
+The measurement on the pseudo-locked region depends on the number, 1 or 2,
+written to pseudo_lock_measure. Since the measurements are recorded with the
tracing infrastructure the relevant tracepoints need to be enabled before the
measurement is triggered.
diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
index 693f99594e9f..246cff17ce66 100644
--- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
+++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
@@ -1290,7 +1290,7 @@ static int _pseudo_lock_restore(struct rdtgroup *rdtgrp)
return ret;
}
-static int __attribute__ ((unused)) pseudo_lock_restore(struct rdtgroup *rdtgrp)
+static int pseudo_lock_restore(struct rdtgroup *rdtgrp)
{
int ret;
@@ -1302,6 +1302,43 @@ static int __attribute__ ((unused)) pseudo_lock_restore(struct rdtgroup *rdtgrp)
return ret;
}
+static ssize_t pseudo_lock_restore_trigger(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct rdtgroup *rdtgrp = file->private_data;
+ size_t buf_size;
+ char buf[32];
+ int ret;
+ bool bv;
+
+ buf_size = min(count, (sizeof(buf) - 1));
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+
+ buf[buf_size] = '\0';
+ ret = strtobool(buf, &bv);
+ if (ret == 0 && bv) {
+ ret = debugfs_file_get(file->f_path.dentry);
+ if (ret)
+ return ret;
+ ret = pseudo_lock_restore(rdtgrp);
+ if (ret == 0)
+ ret = count;
+ debugfs_file_put(file->f_path.dentry);
+ } else {
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+static const struct file_operations pseudo_restore_fops = {
+ .write = pseudo_lock_restore_trigger,
+ .open = simple_open,
+ .llseek = default_llseek,
+};
+
/**
* rdtgroup_pseudo_lock_create - Create a pseudo-locked region
* @rdtgrp: resource group to which pseudo-lock region belongs
@@ -1385,10 +1422,14 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)
if (!IS_ERR_OR_NULL(debugfs_resctrl)) {
plr->debugfs_dir = debugfs_create_dir(rdtgrp->kn->name,
debugfs_resctrl);
- if (!IS_ERR_OR_NULL(plr->debugfs_dir))
+ if (!IS_ERR_OR_NULL(plr->debugfs_dir)) {
debugfs_create_file("pseudo_lock_measure", 0200,
plr->debugfs_dir, rdtgrp,
&pseudo_measure_fops);
+ debugfs_create_file("pseudo_lock_restore", 0200,
+ plr->debugfs_dir, rdtgrp,
+ &pseudo_restore_fops);
+ }
}
dev = device_create(pseudo_lock_class, NULL,
--
2.17.0
next prev parent reply other threads:[~2018-07-24 20:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 20:40 [RFC PATCH 0/7] x86/intel_rdt: Restoration of Cache Pseudo-Locked regions Reinette Chatre
2018-07-24 20:40 ` [RFC PATCH 1/7] x86/intel_rdt: Expose useful functions to all RDT code Reinette Chatre
2018-07-24 20:40 ` [RFC PATCH 2/7] x86/intel_rdt: Enable a pseudo-locked region to be restored Reinette Chatre
2018-07-24 20:40 ` Reinette Chatre [this message]
2018-07-24 20:40 ` [RFC PATCH 4/7] x86/intel_rdt: Support restore of all pseudo-locked regions Reinette Chatre
2018-07-24 20:40 ` [RFC PATCH 5/7] x86/intel_rdt: Trigger pseudo-lock restore after wbinvd call Reinette Chatre
2018-07-24 20:40 ` [RFC PATCH 6/7] mtd: replace direct wbinvd invoke with kernel api Reinette Chatre
2018-07-24 20:40 ` [RFC PATCH 7/7] video: fbdev: i810: " Reinette Chatre
2018-08-03 11:45 ` [RFC PATCH 0/7] x86/intel_rdt: Restoration of Cache Pseudo-Locked regions Thomas Gleixner
2018-08-03 14:23 ` Dave Hansen
2018-08-03 14:48 ` Peter Zijlstra
2018-08-03 15:40 ` Reinette Chatre
2018-08-03 15:51 ` Peter Zijlstra
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=1905054751d4388177b14de220b6adb708e04c3d.1532463771.git.reinette.chatre@intel.com \
--to=reinette.chatre@intel.com \
--cc=dave.hansen@intel.com \
--cc=fenghua.yu@intel.com \
--cc=gavin.hindman@intel.com \
--cc=hpa@zytor.com \
--cc=jithu.joseph@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vikas.shivappa@linux.intel.com \
--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;
as well as URLs for NNTP newsgroup(s).