Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp45057imm; Tue, 24 Jul 2018 13:42:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcz2j0wLtoc0XeKHYQ0Abi8re6E7Tzv4NsFOF4CUsqen07sYqusOOwF9DdbfKdEr2LmVsYq X-Received: by 2002:a63:7558:: with SMTP id f24-v6mr18133433pgn.314.1532464949194; Tue, 24 Jul 2018 13:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532464949; cv=none; d=google.com; s=arc-20160816; b=MFeT69PugH19/qV4mHVqQTSlN1tEhDOXRH2qo3t5lb5U+5zPxf9RqniBclUu5abq2P JZneMqYz/1WuVwa9sBaYVgP06DrcsuamyB/c5BKRvaGVJ2+9xdm8W5q+YFBHu8yZjLZ/ cFAkaByiHYrakcK8BPcENFUpGIq6ehIcGiDBE7gu9NY7ZChew+y3AYN5mL0EjlFSusXM L33V3s8waV4sjepILoT+uPIW6lYfUrvaNfvPi9Zr5zKC5+p+YtL7Cj0VxvDvoNJQ0QF/ Otzyfh9hidjU8zxXsoe/91hQlA1xqUC9aCFHo2hG9x9mESD2xNfkW0nwc4kaIB55ER3F 7A0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gC8PdAkRN6IwYEcNQXKcfO7AosVOoTr/H2gjhpnQNi8=; b=Y3lq8StHEmItniEW/k1QjpbaDlXBGJkt6H5oTmGXE7xCBKgktmlcfJWqThdKFglNSJ 3trHEFmtguJNuo7kl9gTl6wHYudZGDbtya56486cff1jpEj2oTlWH4YN6k9BfC7GiXbU PxOUEEYkyLQZVheAL0UnXWJYMbIFrjrSzhVnFgckOP9REYXB6Fz4UUf1DTm5b52kmxqH fmOYBnB+hSUgyVgQllFF5m5Hd0AStR+/UrYKp0AeJj8+xa6pw1RoYzZr1n1KDwAUjK1Y iCLxGizHAnjizp8lxXWydZbmKH8IBxGm0mhR/l/rHgfeFnwRgzxpp0ri9/9uHXQIpRQo XJsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4-v6si12397669pgg.537.2018.07.24.13.42.14; Tue, 24 Jul 2018 13:42:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388879AbeGXVtK (ORCPT + 99 others); Tue, 24 Jul 2018 17:49:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:61798 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388819AbeGXVtJ (ORCPT ); Tue, 24 Jul 2018 17:49:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2018 13:40:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,399,1526367600"; d="scan'208";a="74172844" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga004.fm.intel.com with ESMTP; 24 Jul 2018 13:40:30 -0700 From: Reinette Chatre 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 Subject: [RFC PATCH 4/7] x86/intel_rdt: Support restore of all pseudo-locked regions Date: Tue, 24 Jul 2018 13:40:15 -0700 Message-Id: <97783445912151c8fde002865bcc3ab5bb0576be.1532463771.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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