From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934833AbdBQToQ (ORCPT ); Fri, 17 Feb 2017 14:44:16 -0500 Received: from mga06.intel.com ([134.134.136.31]:39825 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934415AbdBQToO (ORCPT ); Fri, 17 Feb 2017 14:44:14 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,173,1484035200"; d="scan'208";a="48500962" From: Vikas Shivappa To: vikas.shivappa@intel.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, ravi.v.shankar@intel.com, tony.luck@intel.com, fenghua.yu@intel.com, andi.kleen@intel.com, vikas.shivappa@linux.intel.com Subject: [PATCH 3/5] x86/intel_rdt: Fail early on a resource with incorrect domains Date: Fri, 17 Feb 2017 11:38:46 -0800 Message-Id: <1487360328-6768-4-git-send-email-vikas.shivappa@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487360328-6768-1-git-send-email-vikas.shivappa@linux.intel.com> References: <1487360328-6768-1-git-send-email-vikas.shivappa@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a schemata file is changed, user enters control values for all domains and all resources in the below format (Consider L3 and L2 resources): L3:=;=;... L2:=;=;... Return error as soon as we detect a resource not entering all domain values in schemata rather than waiting till we parse all resources because the entire change is atomic. Also this avoids looping all enabled resources again. Signed-off-by: Vikas Shivappa --- arch/x86/kernel/cpu/intel_rdt_schemata.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c index 64b43b1..527d042 100644 --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c @@ -94,6 +94,10 @@ static int parse_line(char *line, struct rdt_resource *r) return -EINVAL; } + /* Incorrect number of domains in the line */ + if (r->num_tmp_cbms != r->num_domains) + return -EINVAL; + /* Any garbage at the end of the line? */ if (line && line[0]) return -EINVAL; @@ -212,14 +216,6 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, } } - /* Did the parser find all the masks we need? */ - for_each_enabled_rdt_resource(r) { - if (r->num_tmp_cbms != r->num_domains) { - ret = -EINVAL; - goto out; - } - } - for_each_enabled_rdt_resource(r) { ret = update_domains(r, closid); if (ret) -- 1.9.1