Received: by 10.223.185.116 with SMTP id b49csp27834wrg; Tue, 13 Feb 2018 15:55:03 -0800 (PST) X-Google-Smtp-Source: AH8x226v9d2BHq86p2IIOMj4cmvO9Yuh6RB2miKn4L+OUzO5frlfcDOXynG1/TwgeSvtlAY0uPJx X-Received: by 10.98.201.129 with SMTP id l1mr2880325pfk.76.1518566103744; Tue, 13 Feb 2018 15:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518566103; cv=none; d=google.com; s=arc-20160816; b=g4OHi7kIOF48LLWJauJMzbYkFiRzrRyNZ/fQppPIj9JuUW8FaYbnGXOBDnog5klP3o dojxRV6sdEi4XEV9k6Qm9BdzJ1REP0B5OtmKL+KzWKP7RW4CSOLaCNlfGRvZNNBcCOZc VOF0Qu4JIczl6YsgbdmVS6e+GWwFxeUrDj86dnnUiuiUx9/9JJsWpgHFPAJTqBJt1C+b BaPU8C6PsL6t0LOZCq+Ma71oGRYoADD38rebAoyDrYJ34vCJgIF1llSl5EYWAxKMN/R0 5IMLbHt8f4Sq5Fj9h+WRvOSj+AAIK4f/KQgW/ZDncxtxULxo+liXHBvLkhDbNFdcqNUQ alnA== 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=BVqfWfe6JmZzsj2o5b4Hp8rH3q/rlYBRVkEVpD0RI8Q=; b=b55YkKXEpwTA78yASWaNoCYSm5wZLOgN4YKBJ/LQaPUVJTV/P3Byj6aXa+DRUPv8nB 3q9DG5lZhxln5GEkJxLLAt7MUa4+T9CMVWTwiB25dz++U081ynVgFqLjB5+4Jk2RKtBB cZp+jcMdWnrIjl4fAF2/OcqQndMLl744x6wcZC6jj0pfNgEDk91uPsUEKWgsUvFUAai0 ZVeU7Am7+Ke70SxEWf4E7NVnfNZnDK21GZ4dbqwb4UB0fvwyT5w9LdbPRR4tfBl6Fihd sWZQbNA/QGpfo/mf7BxkyTCJZnsGJIzMQMTV+TfJu755d6w/a41soto2rMsaDwyNuf00 dwxA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si546071plj.651.2018.02.13.15.54.49; Tue, 13 Feb 2018 15:55:03 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966257AbeBMXxs (ORCPT + 99 others); Tue, 13 Feb 2018 18:53:48 -0500 Received: from mga17.intel.com ([192.55.52.151]:53392 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966139AbeBMXtd (ORCPT ); Tue, 13 Feb 2018 18:49:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 15:49:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,509,1511856000"; d="scan'208";a="29822311" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga004.fm.intel.com with ESMTP; 13 Feb 2018 15:49:33 -0800 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com Cc: gavin.hindman@intel.com, vikas.shivappa@linux.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 V2 05/22] x86/intel_rdt: Print more accurate pseudo-locking availability Date: Tue, 13 Feb 2018 07:46:49 -0800 Message-Id: <9057ea509f1e7b5b10d695c176622214753cb41a.1518443616.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.13.6 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 A region of cache is considered available for pseudo-locking when: * Cache area is in use by default COS. * Cache area is NOT in use by any other (other than default) COS. * Cache area is not shared with any other entity. Specifically, the cache area does not appear in "Bitmask of Shareable Resource with Other executing entities" found in EBX during CAT enumeration. * Cache area is not currently pseudo-locked. At this time the first three tests are possible and we update the "avail" file associated with pseudo-locking to print a more accurate reflection of pseudo-locking availability. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 62 ++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index ad8b97747024..a787a103c432 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -26,9 +26,69 @@ static struct kernfs_node *pseudo_lock_kn; +/** + * pseudo_lock_avail_get - return bitmask of cache available for locking + * @r: resource to which this cache instance belongs + * @d: domain representing the cache instance + * + * Availability for pseudo-locking is determined as follows: + * * Cache area is in use by default COS. + * * Cache area is NOT in use by any other (other than default) COS. + * * Cache area is not shared with any other entity. Specifically, the + * cache area does not appear in "Bitmask of Shareable Resource with Other + * executing entities" found in EBX during CAT enumeration. + * + * Below is also required to determine availability and will be + * added in later: + * * Cache area is not currently pseudo-locked. + * + * LOCKING: + * rdtgroup_mutex is expected to be held when called + * + * RETURNS: + * Bitmask representing region of cache that can be locked, zero if nothing + * available. + */ +static u32 pseudo_lock_avail_get(struct rdt_resource *r, struct rdt_domain *d) +{ + u32 avail; + int i; + + lockdep_assert_held(&rdtgroup_mutex); + + avail = d->ctrl_val[0]; + for (i = 1; i < r->num_closid; i++) { + if (closid_allocated(i)) + avail &= ~d->ctrl_val[i]; + } + avail &= ~r->cache.shareable_bits; + + return avail; +} + static int pseudo_lock_avail_show(struct seq_file *sf, void *v) { - seq_puts(sf, "0\n"); + struct rdt_resource *r; + struct rdt_domain *d; + bool sep; + + mutex_lock(&rdtgroup_mutex); + + for_each_alloc_enabled_rdt_resource(r) { + sep = false; + seq_printf(sf, "%s:", r->name); + list_for_each_entry(d, &r->domains, list) { + if (sep) + seq_puts(sf, ";"); + seq_printf(sf, "%d=%x", d->id, + pseudo_lock_avail_get(r, d)); + sep = true; + } + seq_puts(sf, "\n"); + } + + mutex_unlock(&rdtgroup_mutex); + return 0; } -- 2.13.6