Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp126452imm; Tue, 19 Jun 2018 17:29:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxhZ8fgxy9WIi5fLNdEzmE/27LYV8zrSEfM8n1JqR4pZ2zv+6lxtLpsCszAUoPaPWke55V X-Received: by 2002:a62:3d05:: with SMTP id k5-v6mr20241014pfa.122.1529454552013; Tue, 19 Jun 2018 17:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529454551; cv=none; d=google.com; s=arc-20160816; b=ndRYVj/acONi92CzjRYuUD7BGSp44xqCxdeclUmvORYuQRt2QpkXp5oDWmnN0tFnpH 8ah0gs/rrXXloP35Wcj+RJHyxEngjiInFwWfNABlwI6Lhy3Axyg/VRHBZ1VWOnOtncZI wlqcmRBt0Sz/10yQZDYZ7WLTxkSg/1rrSC5yPBGG+DtIcV4h+At/mHmmI82mSxgCaebx qvoZbwJFn6ngIsSnWDHTmtzjFVbtyPkTMYpOB5qR3QAGqrBX39qHcVgmU+uPbcaoXGoH AT9a466EL5lnjTP8EavW44zCFwCxW5RxeHmjeyVu6prJ2fFTZoaM4fw7Yo+NWVKNRB/2 BhUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=99KSLx8603NA4qS0JK3qXuKrErgE/hjoYUUiFcjQkKE=; b=sGjS5IF9pRBh2WSHp2wrP/Y/M2qYjET0fSLNg6EIo9jgJwx45dZBQP826VeNZrDWqz jNy+4PQBjB9ZQzmyCR2XatH38UA+7XfCgI60v7hcHoaCKCCXEiTJFF+sQF9pMV3SmHTm ybBzn4W9uFIq8ADomH1NRe1O2ELsfmhF50yfO34wcDIL4lR+RCc5fWJ+T1rydwNQ9kJa A5Gqzw+hYVkKdna1OCXMTV0GkpXqN/5YUV4fyUdTqz+Kzyq18e4ozO48Wc8GNK3LHsFv THdBATlIhZ9vaBBWjG4TW57RWrdXd532JHUbgDHWfp9hV/LoyXOhcoMf+GjJL0HJRRC/ Wl9g== 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 q19-v6si895584pls.139.2018.06.19.17.28.58; Tue, 19 Jun 2018 17:29:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753826AbeFTA1a (ORCPT + 99 others); Tue, 19 Jun 2018 20:27:30 -0400 Received: from terminus.zytor.com ([198.137.202.136]:44961 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752892AbeFTA10 (ORCPT ); Tue, 19 Jun 2018 20:27:26 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K0RLwB3299759 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 17:27:22 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K0RLiX3299756; Tue, 19 Jun 2018 17:27:21 -0700 Date: Tue, 19 Jun 2018 17:27:21 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: mingo@kernel.org, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de Reply-To: mingo@kernel.org, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <59b96030bd839dbc474bbac217f9879e45579e52.1527847599.git.reinette.chatre@intel.com> References: <59b96030bd839dbc474bbac217f9879e45579e52.1527847599.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Add utilities to test pseudo-locked region possibility Git-Commit-ID: f809a8d67ee44cedca6d9acf5b8f6252c108e195 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f809a8d67ee44cedca6d9acf5b8f6252c108e195 Gitweb: https://git.kernel.org/tip/f809a8d67ee44cedca6d9acf5b8f6252c108e195 Author: Reinette Chatre AuthorDate: Fri, 1 Jun 2018 06:09:20 -0700 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 00:56:37 +0200 x86/intel_rdt: Add utilities to test pseudo-locked region possibility A pseudo-locked region does not have a class of service associated with it and thus not tracked in the array of control values maintained as part of the domain. Even so, when the user provides a new bitmask for another resource group it needs to be checked for interference with existing pseudo-locked regions. Additionally only one pseudo-locked region can be created in any cache hierarchy. Introduce two utilities in support of above scenarios: (1) a utility that can be used to test if a given capacity bitmask overlaps with any pseudo-locked regions associated with a particular cache instance, (2) a utility that can be used to test if a pseudo-locked region exists within a particular cache hierarchy. Signed-off-by: Reinette Chatre Signed-off-by: Thomas Gleixner Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/59b96030bd839dbc474bbac217f9879e45579e52.1527847599.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt.h | 2 + arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 74 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 12b006178d3a..119645c83e27 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -503,6 +503,8 @@ enum rdtgrp_mode rdtgroup_mode_by_closid(int closid); int rdtgroup_tasks_assigned(struct rdtgroup *r); int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp); +bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm); +bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d); struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r); int update_domains(struct rdt_resource *r, int closid); void closid_free(int closid); diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index ce8243c87877..b145a7386b10 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -299,3 +299,77 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp) pseudo_lock_free(rdtgrp); return 0; } + +/** + * rdtgroup_cbm_overlaps_pseudo_locked - Test if CBM or portion is pseudo-locked + * @d: RDT domain + * @_cbm: CBM to test + * + * @d represents a cache instance and @_cbm a capacity bitmask that is + * considered for it. Determine if @_cbm overlaps with any existing + * pseudo-locked region on @d. + * + * Return: true if @_cbm overlaps with pseudo-locked region on @d, false + * otherwise. + */ +bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm) +{ + unsigned long *cbm = (unsigned long *)&_cbm; + unsigned long *cbm_b; + unsigned int cbm_len; + + if (d->plr) { + cbm_len = d->plr->r->cache.cbm_len; + cbm_b = (unsigned long *)&d->plr->cbm; + if (bitmap_intersects(cbm, cbm_b, cbm_len)) + return true; + } + + return false; +} + +/** + * rdtgroup_pseudo_locked_in_hierarchy - Pseudo-locked region in cache hierarchy + * @d: RDT domain under test + * + * The setup of a pseudo-locked region affects all cache instances within + * the hierarchy of the region. It is thus essential to know if any + * pseudo-locked regions exist within a cache hierarchy to prevent any + * attempts to create new pseudo-locked regions in the same hierarchy. + * + * Return: true if a pseudo-locked region exists in the hierarchy of @d or + * if it is not possible to test due to memory allocation issue, + * false otherwise. + */ +bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d) +{ + cpumask_var_t cpu_with_psl; + struct rdt_resource *r; + struct rdt_domain *d_i; + bool ret = false; + + if (!zalloc_cpumask_var(&cpu_with_psl, GFP_KERNEL)) + return true; + + /* + * First determine which cpus have pseudo-locked regions + * associated with them. + */ + for_each_alloc_enabled_rdt_resource(r) { + list_for_each_entry(d_i, &r->domains, list) { + if (d_i->plr) + cpumask_or(cpu_with_psl, cpu_with_psl, + &d_i->cpu_mask); + } + } + + /* + * Next test if new pseudo-locked region would intersect with + * existing region. + */ + if (cpumask_intersects(&d->cpu_mask, cpu_with_psl)) + ret = true; + + free_cpumask_var(cpu_with_psl); + return ret; +}