Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5032880iog; Wed, 22 Jun 2022 10:31:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s4F5tui2m0KHEBz3GQ++NgCyR0yNIzauqF2BZpyMJY2yQih0I6IDb154SzYtOaV/I0bKT6 X-Received: by 2002:a17:907:6e8e:b0:722:e15d:b89e with SMTP id sh14-20020a1709076e8e00b00722e15db89emr4167826ejc.12.1655919091123; Wed, 22 Jun 2022 10:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655919091; cv=none; d=google.com; s=arc-20160816; b=kTI9rVMKWSqIw0FVvVThZIOfjPRn3lot0BknZ+NDYcWwpFKTnS/PTflZVJ8bGndrCo HQNjDXCkK4+aSJTixtYTMSGkH/7s8fGxhu7RMucy/UUiX+X04kg8M2KNgrK9CSuMCst+ oAKbxdsFTI6uvyOCy9LFtwb4Wwm633c6iIOu3saLeBHikiQhSfeAT6NY8oLwjG2Ri98k lruZ8hVW8zoul1NZ/7hk4XXlKv6NijnfibQ8B2e5a5+OduiCsegm+WyvkgcI+eTdV5CO Ik72Qhpgt+1TTwyStIVcs75R/8D3+gOECFCMU5njzBwC2JLlRBh+jtHpfvYiJHmM9I5x g6gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HNix5ym1kOXgsnjbHIEDh47WM1WM5Dk/nizfpsZVn/s=; b=eVPAtIoAIYmT1JiEgmsJPN5pWZy3C8COdWqcZkuAVfir7PNOJ9431FeuKuxqP3zIxs xwGP2P70nYIXS+/IzClp9Uh9Gsf5CuZRLWqI9Ep9LPIYX7d6mgm1Tg2EywC9yeem+KS4 JWttexrFSwJyLMGr2wF6Cln318GY/3dmRyO/W9DDUvqQom6E0l+uf4TSZnmFK/dBB59h Kii7/2u+354Tm0FDYGEqFSUMDYBsoerg7UsR8OgXQhFQUrU0BkuhIC5ZzWIbh0ScxTwq 6bcNdGi0bxrPmhk58hMYAP40NR9tKb1qfbxojo4eOqyL8tCTgGCPJJB29ufSoh8slg3X tt3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb40-20020a170907962800b00713dd68c65csi22695676ejc.818.2022.06.22.10.31.02; Wed, 22 Jun 2022 10:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376804AbiFVQty (ORCPT + 99 others); Wed, 22 Jun 2022 12:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376884AbiFVQs0 (ORCPT ); Wed, 22 Jun 2022 12:48:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B42C136 for ; Wed, 22 Jun 2022 09:47:51 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6ED8B152B; Wed, 22 Jun 2022 09:47:51 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E6AF93F792; Wed, 22 Jun 2022 09:47:48 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Cristian Marussi , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com Subject: [PATCH v5 20/21] x86/resctrl: Add resctrl_rmid_realloc_limit to abstract x86's boot_cpu_data Date: Wed, 22 Jun 2022 16:46:28 +0000 Message-Id: <20220622164629.20795-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220622164629.20795-1-james.morse@arm.com> References: <20220622164629.20795-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org resctrl_rmid_realloc_threshold can be set by user-space. The maximum value is specified by the architecture. Currently max_threshold_occ_write() reads the maximum value from boot_cpu_data.x86_cache_size, which is not portable to another architecture. Add resctrl_rmid_realloc_limit to describe the maximum size in bytes that user-space can set the threshold to. Reviewed-by: Jamie Iles Tested-by: Xin Hao Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Tested-by: Cristian Marussi Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/monitor.c | 9 +++++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- include/linux/resctrl.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index e91afe99b763..8d15568d7121 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -67,6 +67,11 @@ unsigned int rdt_mon_features; */ unsigned int resctrl_rmid_realloc_threshold; +/* + * This is the maximum value for the reallocation threshold, in bytes. + */ +unsigned int resctrl_rmid_realloc_limit; + #define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5)) /* @@ -747,10 +752,10 @@ int rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); - unsigned int cl_size = boot_cpu_data.x86_cache_size; unsigned int threshold; int ret; + resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size * 1024; hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale; r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1; hw_res->mbm_width = MBM_CNTR_WIDTH_BASE; @@ -767,7 +772,7 @@ int rdt_get_mon_l3_config(struct rdt_resource *r) * * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - threshold = cl_size * 1024 / r->num_rmid; + threshold = resctrl_rmid_realloc_limit / r->num_rmid; /* * Because num_rmid may not be a power of two, round the value diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index ae77ea5f323a..1b714523dc26 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1059,7 +1059,7 @@ static ssize_t max_threshold_occ_write(struct kernfs_open_file *of, if (ret) return ret; - if (bytes > (boot_cpu_data.x86_cache_size * 1024)) + if (bytes > resctrl_rmid_realloc_limit) return -EINVAL; resctrl_rmid_realloc_threshold = resctrl_arch_round_mon_val(bytes); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 9995d043650a..cb857f753322 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -251,5 +251,6 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, u32 rmid, enum resctrl_event_id eventid); extern unsigned int resctrl_rmid_realloc_threshold; +extern unsigned int resctrl_rmid_realloc_limit; #endif /* _RESCTRL_H */ -- 2.30.2