linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 4/7] x86/intel_rdt: Support restore of all pseudo-locked regions
Date: Tue, 24 Jul 2018 13:40:15 -0700	[thread overview]
Message-ID: <97783445912151c8fde002865bcc3ab5bb0576be.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>

An instruction like wbinvd would evict all data from pseudo-locked
regions within the cache hierarchy on which the instruction was run.

Add support for offloading the restoration of all pseudo-locked
regions since it is not possible to know which pseudo-locked regions
specifically are in need of restoration. The restoration could be
triggered from anywhere at which time the work to do so is scheduled
on the system wide workqueue. Since this is a severe event that could
be handled automatically (not triggered by user space) a warning is
printed to user when the restoration runs.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 42 +++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
index 246cff17ce66..d395e6982467 100644
--- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
+++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
@@ -52,6 +52,12 @@ static unsigned int pseudo_lock_major;
 static unsigned long pseudo_lock_minor_avail = GENMASK(MINORBITS, 0);
 static struct class *pseudo_lock_class;
 
+/*
+ * Support the offloading of pseudo-locked region restoration.
+ */
+static void pseudo_lock_restore_work_fn(struct work_struct *work);
+static DECLARE_WORK(pseudo_lock_restore_work, pseudo_lock_restore_work_fn);
+
 /**
  * get_prefetch_disable_bits - prefetch disable bits of supported platforms
  *
@@ -1510,6 +1516,42 @@ void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp)
 	pseudo_lock_free(rdtgrp);
 }
 
+/**
+ * pseudo_lock_restore_work_fn - Restore all pseudo-locked regions
+ * @work: the work
+ *
+ * Instructions like wbinvd would cause pseudo-locked data to be evicted.
+ * Cases like this may be detected but it may not be obvious which
+ * pseudo-locked regions are affected. To handle severe cases like this
+ * pseudo_lock_restore_work_fn() will restore all pseudo-locked regions
+ * on the system.
+ * Since this may occur automatically a WARN will be triggered to notify
+ * the user of this event.
+ */
+static void pseudo_lock_restore_work_fn(struct work_struct *work)
+{
+	struct rdtgroup *rdtgrp;
+
+	cpus_read_lock();
+	mutex_lock(&rdtgroup_mutex);
+	list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) {
+		if (WARN_ON_ONCE(rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED)) {
+			pr_err("Automatic restore of Pseudo-Locked region %s\n",
+			       rdtgrp->kn->name);
+			_pseudo_lock_restore(rdtgrp);
+		}
+	}
+	mutex_unlock(&rdtgroup_mutex);
+	cpus_read_unlock();
+}
+
+void intel_rdtgroup_pseudo_lock_restore_all(void)
+{
+	if (static_branch_unlikely(&rdt_enable_key))
+		schedule_work(&pseudo_lock_restore_work);
+}
+EXPORT_SYMBOL(intel_rdtgroup_pseudo_lock_restore_all);
+
 static int pseudo_lock_dev_open(struct inode *inode, struct file *filp)
 {
 	struct rdtgroup *rdtgrp;
-- 
2.17.0


  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 ` [RFC PATCH 3/7] x86/intel_rdt: Enable user to trigger pseudo-locked region restore Reinette Chatre
2018-07-24 20:40 ` Reinette Chatre [this message]
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=97783445912151c8fde002865bcc3ab5bb0576be.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).