Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp94180imm; Thu, 7 Jun 2018 14:28:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKyIeWQOVTfLu+ttqFyxpacw67NvVa9T4zcbPN/jSbrTTir/nJ/ZoPpdzaAV6/qHYgwbGEn X-Received: by 2002:a17:902:2c01:: with SMTP id m1-v6mr3633245plb.347.1528406930326; Thu, 07 Jun 2018 14:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528406930; cv=none; d=google.com; s=arc-20160816; b=J7r8ab2ecrmXazbqx2iwahFwq9q5Ay6lNyrS2p/aQgQydO/lN2G68AKqsajWCST76r hFoP9ubw8+RvX1IFn1qtl/NSa4La+FR8qdqov4xYWImDIwlqw8WmtQaAbq5hbGBAKSAk vMFK6y9R4Uq7SCTOcWDljmXHCwKYmRHv+CfxoWV5asL/BTTEqACH4Vek1MLorlg/x5S2 Z3rLpvZe7zQokRS5EtOactfgdS1XH4NrEBHsBW0sTmGAgYU+A8/pnF+JG1nuEn0Dm7Mm y6KrJ2Nrl8AgCfitz9vMaau0PlYZYy+SbXk9M6V/k43vP7pFFBUcmM4NuClQylzdYQaf hWYA== 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:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DlhPDwqKxN4jXbu35/l+bIdM3EUvAeD+JOhFbIdGgak=; b=P2VkYmD3i5WZHvpfH6/D61GXhhODoWrFIVoUKa6rBNwTAJ8zT0NUIGxvLGME5mmFmD hgRKbdUCr5DCvSGVVKLFWzri3voVgxLDnf+rKiGHkP8YJqJmfUwwicIkcynu1G0ZMUP2 5Qr/7Cf74cxA8X49pSilx7MLU/hfRE3/DllU5eJ8GaGjLyf/UXbsIefDI+c8ZDCEsbKW PclsRWUBig0JLwD9kvqGTJ7hUpDdxopg7z84o6OIWsl1/lm3dRPO2shDIp6TesA4zTUU Ap/E0fHVMt9yzSuaXLSCOPfbaSIbXEAE7vZmLxjLiSgalKbd0Opg44EpDclMrIo8jkQW C0dQ== 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 128-v6si43952956pgb.176.2018.06.07.14.28.05; Thu, 07 Jun 2018 14:28:50 -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 S1752610AbeFGV0x (ORCPT + 99 others); Thu, 7 Jun 2018 17:26:53 -0400 Received: from mga03.intel.com ([134.134.136.65]:9189 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752561AbeFGV0w (ORCPT ); Thu, 7 Jun 2018 17:26:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 14:26:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,488,1520924400"; d="scan'208";a="47634958" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga008.jf.intel.com with ESMTP; 07 Jun 2018 14:26:51 -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: [PATCH V6 25/38] x86/intel_rdt: Enable entering of pseudo-locksetup mode Date: Thu, 7 Jun 2018 14:26:44 -0700 Message-Id: X-Mailer: git-send-email 2.13.6 In-Reply-To: <2d019e91959799576299ff6974e0716163aad052.1527593971.git.reinette.chatre@intel.com> References: <2d019e91959799576299ff6974e0716163aad052.1527593971.git.reinette.chatre@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The user can request entering pseudo-locksetup mode by writing "pseudo-locksetup" to the mode file. Act on this request as well as support switching from a pseudo-locksetup mode (before pseudo-locked mode was entered). It is not supported to modify the mode once pseudo-locked mode has been entered. The schemata reflects the new mode by adding "uninitialized" to all resources. The size resctrl file reports zero for all cache domains in support of the uninitialized nature. Since there are no users of this class of service its allocations can be ignored when searching for appropriate default allocations for new resource groups. For the same reason resource groups in pseudo-locksetup mode are not considered when testing if new resource groups may overlap. Signed-off-by: Reinette Chatre --- V6: A resource group in pseudo-locksetup mode does have a CLOSID associated with it but until its mode is changed to pseudo-locked there is no way in which this CLOSID can be active. When a new allocation is considered for a different resource group the new allocation should not be compared to the unusable allocation associated with the CLOSID assigned to the resource group in pseudo-locksetup mode. arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 16 +++++++---- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 41 +++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c index bc79396c5dad..1ed273220ffa 100644 --- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c @@ -156,7 +156,8 @@ int parse_cbm(void *_data, struct rdt_resource *r, struct rdt_domain *d) } if (rdtgroup_cbm_overlaps(r, d, cbm_val, rdtgrp->closid, false)) { - if (rdtgrp->mode == RDT_MODE_EXCLUSIVE) { + if (rdtgrp->mode == RDT_MODE_EXCLUSIVE || + rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { rdt_last_cmd_printf("overlaps with other group\n"); return -EINVAL; } @@ -356,10 +357,15 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, rdtgrp = rdtgroup_kn_lock_live(of->kn); if (rdtgrp) { - closid = rdtgrp->closid; - for_each_alloc_enabled_rdt_resource(r) { - if (closid < r->num_closid) - show_doms(s, r, closid); + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { + for_each_alloc_enabled_rdt_resource(r) + seq_printf(s, "%s:uninitialized\n", r->name); + } else { + closid = rdtgrp->closid; + for_each_alloc_enabled_rdt_resource(r) { + if (closid < r->num_closid) + show_doms(s, r, closid); + } } } else { ret = -ENOENT; diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 59b5bdbb6597..0277c4fe433c 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -974,9 +974,10 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, ctrl = d->ctrl_val; for (i = 0; i < r->num_closid; i++, ctrl++) { ctrl_b = (unsigned long *)ctrl; - if (closid_allocated(i) && i != closid) { + mode = rdtgroup_mode_by_closid(i); + if (closid_allocated(i) && i != closid && + mode != RDT_MODE_PSEUDO_LOCKSETUP) { if (bitmap_intersects(cbm, ctrl_b, r->cache.cbm_len)) { - mode = rdtgroup_mode_by_closid(i); if (exclusive) { if (mode == RDT_MODE_EXCLUSIVE) return true; @@ -1046,10 +1047,24 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of, mode = rdtgrp->mode; if ((!strcmp(buf, "shareable") && mode == RDT_MODE_SHAREABLE) || - (!strcmp(buf, "exclusive") && mode == RDT_MODE_EXCLUSIVE)) + (!strcmp(buf, "exclusive") && mode == RDT_MODE_EXCLUSIVE) || + (!strcmp(buf, "pseudo-locksetup") && + mode == RDT_MODE_PSEUDO_LOCKSETUP) || + (!strcmp(buf, "pseudo-locked") && mode == RDT_MODE_PSEUDO_LOCKED)) goto out; + if (mode == RDT_MODE_PSEUDO_LOCKED) { + rdt_last_cmd_printf("cannot change pseudo-locked group\n"); + ret = -EINVAL; + goto out; + } + if (!strcmp(buf, "shareable")) { + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { + ret = rdtgroup_locksetup_exit(rdtgrp); + if (ret) + goto out; + } rdtgrp->mode = RDT_MODE_SHAREABLE; } else if (!strcmp(buf, "exclusive")) { if (!rdtgroup_mode_test_exclusive(rdtgrp)) { @@ -1057,7 +1072,17 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of, ret = -EINVAL; goto out; } + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { + ret = rdtgroup_locksetup_exit(rdtgrp); + if (ret) + goto out; + } rdtgrp->mode = RDT_MODE_EXCLUSIVE; + } else if (!strcmp(buf, "pseudo-locksetup")) { + ret = rdtgroup_locksetup_enter(rdtgrp); + if (ret) + goto out; + rdtgrp->mode = RDT_MODE_PSEUDO_LOCKSETUP; } else { rdt_last_cmd_printf("unknown/unsupported mode\n"); ret = -EINVAL; @@ -1127,8 +1152,12 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, list_for_each_entry(d, &r->domains, list) { if (sep) seq_putc(s, ';'); - cbm = d->ctrl_val[rdtgrp->closid]; - size = rdtgroup_cbm_to_size(r, d, cbm); + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { + size = 0; + } else { + cbm = d->ctrl_val[rdtgrp->closid]; + size = rdtgroup_cbm_to_size(r, d, cbm); + } seq_printf(s, "%d=%u", d->id, size); sep = true; } @@ -2261,6 +2290,8 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) for (i = 0; i < r->num_closid; i++, ctrl++) { if (closid_allocated(i) && i != closid) { mode = rdtgroup_mode_by_closid(i); + if (mode == RDT_MODE_PSEUDO_LOCKSETUP) + break; used_b |= *ctrl; if (mode == RDT_MODE_SHAREABLE) d->new_ctrl |= *ctrl; -- 2.13.6