Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1231553imm; Fri, 14 Sep 2018 13:37:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZkzkyA8W8JNLpniYTLR9Wc3Rhtdhe2hl9h0owgvmxNX9Sq6IUvhDR6BaotirAulkzHKvSP X-Received: by 2002:a63:5756:: with SMTP id h22-v6mr13498990pgm.423.1536957445191; Fri, 14 Sep 2018 13:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536957445; cv=none; d=google.com; s=arc-20160816; b=qv3Bps0NhOvwEVFi+dARn5sO1R509y1dvWGkbaYMgVg0x9kMbS1zu1uN2X9wjZv77z 5WeowSD7LlLDepvpv2bLOpVjJ93SQr8LkgAuWLml36PjloMTHtcFtT+7GAWgJ+Hcc2AK ciH7cHn+7FqTJcwg9+W+5PlFOx8D7Tc0KP6wvlvoBIaJJN+tIjPB0cVy2qgVIbQCzHFc tuT17inP9m0JcSV56eNGfJ5pvKcflTuQ1D8fphBgP0Kuf3kmcAp1aFU0dElZVfc++aTv fyGgw5T74KZkz/SIwOJ0+O1x/JnS+G3QZyRunRk3LtfoOzIPbF2uKvU5mJNrQjkUVTsI Wqxw== 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; bh=zWoIcLgnH4GIimFPwQQzXJ5quce25qgSTNExbHTwCEs=; b=0GglASL5Tv6Vf40PxnUDp0IXYTgd+LOkfa8cNTXgt+Sc2srv3Y10MuKG0x4VnR+wuQ qnPN5h5pHlVzc/RwaBHbNBdEV1FXhyELVfhpSnsXll8Hh8mJBdvzSojy3cJbroOMX2Hi JSk1H5OY6y13Z4eZEJV4jGcm7cG4sS3sm0PexXXh2gZxDbDTNfFy5ohJdz+cA3COunzG gnqWXM2axGalTh6A7wk69ris/tr89atWsg2IZY7ubOtt6Cno5FxtN/b48ch44TAIFC8/ v6vAXe2hmfOQWEPTycnaUNt7TDHbWzitZ7hdeqa8eVEpoMdki4Dqk4UOYK9CQ2lB2K9o C0xg== 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 d10-v6si7913758pla.436.2018.09.14.13.37.10; Fri, 14 Sep 2018 13:37:25 -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 S1728348AbeIOBvw (ORCPT + 99 others); Fri, 14 Sep 2018 21:51:52 -0400 Received: from mga05.intel.com ([192.55.52.43]:60388 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727716AbeIOBvw (ORCPT ); Fri, 14 Sep 2018 21:51:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Sep 2018 13:35:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,374,1531810800"; d="scan'208";a="263593809" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga006.fm.intel.com with ESMTP; 14 Sep 2018 13:35:44 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "H Peter Anvin" , "Tony Luck" Cc: "Chatre, Reinette" , "Xiaochen Shen" , "Chen Yu" , "linux-kernel" , "x86" , "Fenghua Yu" Subject: [PATCH 3/9] x86/intel_rdt: Global closid helper to support future fixes Date: Fri, 14 Sep 2018 13:32:03 -0700 Message-Id: <1536957129-70380-4-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1536957129-70380-1-git-send-email-fenghua.yu@intel.com> References: <1536957129-70380-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Reinette Chatre The number of CLOSIDs supported by a system is the minimum number of CLOSIDs supported by any of its resources. Care should be taken when iterating over the CLOSIDs of a resource since it may be that the number of CLOSIDs supported on the system is less than the number of CLOSIDs supported by the resource. Introduce a helper function that can be used to query the number of CLOSIDs that is supported by all resources, irrespective of how many CLOSIDs are supported by a particular resource. Signed-off-by: Reinette Chatre Signed-off-by: Fenghua Yu --- arch/x86/kernel/cpu/intel_rdt.h | 1 + arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 8c30772e37ed..b2bbba3c4c7e 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -536,6 +536,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp); void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp); struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r); int update_domains(struct rdt_resource *r, int closid); +int closids_supported(void); void closid_free(int closid); int alloc_rmid(void); void free_rmid(u32 rmid); diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 32e8bbdf2400..b372923eb209 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -97,6 +97,12 @@ void rdt_last_cmd_printf(const char *fmt, ...) * limited as the number of resources grows. */ static int closid_free_map; +static int closid_free_map_len; + +int closids_supported(void) +{ + return closid_free_map_len; +} static void closid_init(void) { @@ -111,6 +117,7 @@ static void closid_init(void) /* CLOSID 0 is always reserved for the default group */ closid_free_map &= ~1; + closid_free_map_len = rdt_min_closid; } static int closid_alloc(void) -- 2.19.0