Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp13266lfv; Tue, 12 Apr 2022 15:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9nNOWvj/GbL0Lwwqx66tuhfwVyIPFCeGULFbPyYFd3R5SngMzR8FHw4ORRNiGr/J6lCjK X-Received: by 2002:a17:90b:380b:b0:1cb:7765:45c7 with SMTP id mq11-20020a17090b380b00b001cb776545c7mr7253794pjb.17.1649801787004; Tue, 12 Apr 2022 15:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649801787; cv=none; d=google.com; s=arc-20160816; b=kt9gcuH2HOCxG/3fSn9477PpIssxCUKr8iy0pQkO+4bwWg4g6NcK9DqW8OHdCV8iFG hnpLRbeYid2/NJ1LQkEvJQok2X1qhXG5+VILTr5tHJtPy3pjmrQbFwJ2GxI48vIwd7Hg 8BZxzQQCocxZa/uqEwYh0pfVhY+6+suHj3QkQKnu01x2XnF1hH8femw7XcYO6lwSXyE9 91axYt9mwLg/FqWGq86e916RGbjW52hkNIS05KRH4kvUVIiSOQ2Osgo+p/x7SufIV2WX QiEWz2CejX4IAmKZLcZoCGNqQgRFSCAYF8gekN96Za95K801dAOcDyURM6A19mhx+AXc fVgw== 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=OchMBZSkGvGyqjrptIBXcBJQQNl6N36MI0Sy1Io9fUg=; b=rRfKrkM2rJX5kLgbR/AcnPsbjy3l48yTBc3catJNXRJp48Nq/1qYPtjyKeYUHCl0yc vX8TZqpEk6kMGvGre2XPZjvw1smZOJLCuIdcCjbBNWSAcEZP8cpq2ET0zzJQ899/gaaa QQt9juNUg6PSyXHvGmmFaqRvglIZfSJGK9BezJk+pltYZsLPLoZXlBR0jU5R0UGBtfhL HVZGB8hVVMFoU9d5vMzjUD4ZQbHOh68PfUPSc/9K+vXqOkKQHWTQi/z1Sk0IdK/+qvAV souydmi686p1rgIT8ai6Jt6gnxHzv2IMDzLw4JdN0zU/xGqcDNGK68utDZhdjkr3c7o8 keZw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w62-20020a638241000000b0039d11248f09si3953997pgd.48.2022.04.12.15.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:16:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FE8B1689F6; Tue, 12 Apr 2022 13:58:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355088AbiDLNJ3 (ORCPT + 99 others); Tue, 12 Apr 2022 09:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356407AbiDLND2 (ORCPT ); Tue, 12 Apr 2022 09:03:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B61F8DFD3 for ; Tue, 12 Apr 2022 05:45:39 -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 6FAEA169C; Tue, 12 Apr 2022 05:45:39 -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 1F0923F70D; Tue, 12 Apr 2022 05:45:37 -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 v4 20/21] x86/resctrl: Add resctrl_rmid_realloc_limit to abstract x86's boot_cpu_data Date: Tue, 12 Apr 2022 12:44:18 +0000 Message-Id: <20220412124419.30689-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220412124419.30689-1-james.morse@arm.com> References: <20220412124419.30689-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 00f6e27e4e0d..bc5c31920a66 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -64,6 +64,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)) /* @@ -744,10 +749,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; @@ -764,7 +769,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 7c35561e5216..0e9f9a527e6a 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 = bytes; diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index fc4805901f1a..9c360999fb9b 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