Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2691567imm; Fri, 24 Aug 2018 03:48:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbjAihYkQBj7SjnpEaHiQY4Z2GSPutbMCjcqTJgBhaLcBql65ce98xtBwWI/DZ3Hs8ukmNm X-Received: by 2002:a62:b604:: with SMTP id j4-v6mr1364929pff.199.1535107698329; Fri, 24 Aug 2018 03:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535107698; cv=none; d=google.com; s=arc-20160816; b=BlzOUQ8J3VBe5tI+vcw3vvBWaJbhCts12dA1/mF6ODkOijP5+O10nnLHaOY+DkXCEk sKzknApp0djLKeOMiCAvPvTwZiNNo0YzGgAUBhyB3Fh6H6bxbh7qpgc69rRXULyoLlXm JOrlcHdhkjdmLZA/pdKFW8373YtWSNVp0/wzzEZehd+s+dLpGNIEPIrPq+9IcO2OTTyZ RxBU4gJbiRsfwQC9ToampWlqdW5/49W/Z6M+MGU4Mw0S2ToxrDDvaTh0bUmUjYoe+/hx r2lmmvfK8Lu/T92wq1RfYedxSUIZB0UW4Pwahfg/a7Qj5Ywg7TO3wo6KHgCMjPM89h9D DXxw== 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=k+29Sa3lDcualioOH7Agah2OYoBgOHio4aelYp5RDYc=; b=LLmfjBiEuy4MZ5VZmKabxIYuiht9lXEs91zw9pX4JY4j/nhjajG5QFb6DnnmTaP7Ts 3dHsbugDODTDeSWCxgZd8ksKsdBE7TWtNmT1jYIc4elRpWQIT82fpTQ9nr5CavXAAmTB /rxwvI+0ikfEFAmKrg6WaleerLmpwedE92aAN0SUdax1puSuqGVSMB6u/7vDSsiqcMVh 2creWOATc4IENR+fcBfO0ZE2M6XWaNGFFY3Mi90QbRADMLECTSyR9kSVR94RILITqTc3 9+U8Jfo6szETlDQ1E9JUsGupcsJ9SFrvjvD+yVyjZBAlYMBQAS4ZE6/sark8Svta799j e/ig== 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 n15-v6si6558084pgr.516.2018.08.24.03.48.03; Fri, 24 Aug 2018 03:48:18 -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 S1728115AbeHXOUu (ORCPT + 99 others); Fri, 24 Aug 2018 10:20:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55682 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727997AbeHXOUt (ORCPT ); Fri, 24 Aug 2018 10:20:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 11478168F; Fri, 24 Aug 2018 03:46:45 -0700 (PDT) Received: from melchizedek.Emea.Arm.com (melchizedek.emea.arm.com [10.4.12.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6951D3F5A0; Fri, 24 Aug 2018 03:46:43 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Thomas Gleixner , Fenghua Yu , Tony Luck , Ingo Molnar , H Peter Anvin , Reinette Chatre , Vikas Shivappa Subject: [RFC PATCH 20/20] x86/intel_rdt: Merge cdp enable/disable calls Date: Fri, 24 Aug 2018 11:45:19 +0100 Message-Id: <20180824104519.11203-21-james.morse@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180824104519.11203-1-james.morse@arm.com> References: <20180824104519.11203-1-james.morse@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the cdp_enable() and cdp_disable() calls are basically the same, merge them into cdp_set_enabled(true/false). All these functions are behind resctrl_arch_set_cdp_enabled(), so the can take the rdt_hw_resource directly. Signed-off-by: James Morse --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 49 ++++++------------------ 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 38cd463443e8..b9b7375ef8a9 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -1017,10 +1017,9 @@ static inline bool is_mba_linear(void) return rdt_resources_all[RDT_RESOURCE_MBA].resctrl.membw.delay_linear; } -static int set_cache_qos_cfg(int level, bool enable) +static int set_cache_qos_cfg(struct rdt_hw_resource *hw_res, bool enable) { void (*update)(void *arg); - struct rdt_resource *r_l; cpumask_var_t cpu_mask; struct rdt_domain *d; int cpu; @@ -1028,15 +1027,14 @@ static int set_cache_qos_cfg(int level, bool enable) if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL)) return -ENOMEM; - if (level == RDT_RESOURCE_L3) + if (hw_res == &rdt_resources_all[RDT_RESOURCE_L3]) update = l3_qos_cfg_update; - else if (level == RDT_RESOURCE_L2) + else if (hw_res == &rdt_resources_all[RDT_RESOURCE_L2]) update = l2_qos_cfg_update; else return -EINVAL; - r_l = &rdt_resources_all[level].resctrl; - list_for_each_entry(d, &r_l->domains, list) { + list_for_each_entry(d, &hw_res->resctrl.domains, list) { /* Pick one CPU from each domain instance to update MSR */ cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask); } @@ -1078,53 +1076,30 @@ static int set_mba_sc(bool mba_sc) return 0; } -static int cdp_enable(int level) +static int cdp_set_enabled(struct rdt_hw_resource *hw_res, bool enable) { - struct rdt_resource *r_l = &rdt_resources_all[level].resctrl; int ret; - if (!r_l->alloc_capable || !r_l->cdp_capable) + if (!hw_res->resctrl.cdp_capable) return -EINVAL; - ret = set_cache_qos_cfg(level, true); + ret = set_cache_qos_cfg(hw_res, enable); if (!ret) - r_l->cdp_enabled = true; + hw_res->resctrl.cdp_enabled = enable; return ret; } -static void cdp_disable(int level) -{ - struct rdt_resource *r = &rdt_resources_all[level].resctrl; - - if (r->cdp_enabled) { - set_cache_qos_cfg(level, false); - r->cdp_enabled = false; - } -} - int resctrl_arch_set_cdp_enabled(bool enable) { int ret = -EINVAL; struct rdt_hw_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3]; struct rdt_hw_resource *l2 = &rdt_resources_all[RDT_RESOURCE_L2]; - if (l3 && l3->resctrl.cdp_capable) { - if (!enable) { - cdp_disable(RDT_RESOURCE_L3); - ret = 0; - } else { - ret = cdp_enable(RDT_RESOURCE_L3); - } - } - if (l2 && l2->resctrl.cdp_capable) { - if (!enable) { - cdp_disable(RDT_RESOURCE_L2); - ret = 0; - } else { - ret = cdp_enable(RDT_RESOURCE_L2); - } - } + if (l3 && l3->resctrl.cdp_capable) + ret = cdp_set_enabled(l3, enable); + if (l2 && l2->resctrl.cdp_capable) + ret = cdp_set_enabled(l2, enable); return ret; } -- 2.18.0