Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1364506rwb; Fri, 23 Sep 2022 11:33:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5paluPQEVyzrFQ1QSRr84LZgvkSWQ7FqThFuCVU7HJLawgjm+UFpSQecsQP4V6IoiK6tlT X-Received: by 2002:a63:9041:0:b0:438:8ed0:8470 with SMTP id a62-20020a639041000000b004388ed08470mr8494479pge.25.1663958034841; Fri, 23 Sep 2022 11:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663958034; cv=none; d=google.com; s=arc-20160816; b=s4hy8+hMQIwkurYFxPCS9glL7Gn5OkkWBr/cKCeTJ857xpDwrwQk+7lVz826/vs3BG CA3blr8KfUguFG9TADoX1bQ6yKC7QmTasM34XN2KwtDFTW2Uh4ZyarATYt0Iv6Ftj1S8 I7rI/j//GqtFjUxg/PS6JoqrwCavnnXIfwK9ax3R/ptay22qFe+54gcoJ5wpqvGqNFN0 w0R05aH7zqLjafw5UMcUBW17KAnbSBg16Ex544qZJB0WVNt3A79aFJtkGO7FTPD0FJGR Xt6gnJ4L5K5nEpLYzrMADkXdpiRQ30I1YMGzpSWDqHsqWEU4urDDI3JStGq6Qs3Oht6i 638w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=h5kvcIo0g99vR5yOZYWaTuCCzeDg6P86/sFcyfvHn2g=; b=NFUgJvPZg4ePcYB8A2Gv3PNjP3PsJFXtVRTHtvG/lNPMkK7merIGMdWPpWQ0Ia9Li5 Ujrsttf3JpUKzof4V9aWiTXR4JwYCE0azGxFzQh4ZSUetdlFSJ+b0ZQOBtSx0Gzo/0YN 1pgG8r5KuN9MvIe/3SU1X7wOgJrgX1E6BKCaNBFQOTzBLL8T7kpuwl4u47EpWh2YJiRk Iedjt7eeEDRIWR7sY/BrkJL7R5ydUqEnfAEJd3I9o/+nBF5EZ8pu800AUMSly2+Sf2b7 2YJLTYjafwSBNa444ea/1Yeu5AAdu3CPWkeZvRTWmxL9PgDOwLAgEBVoLHZMfVbJl7vI lljA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=r73Y456B; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lq5dvc8I; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a056a00174100b00555463cd9e6si5979178pfc.238.2022.09.23.11.33.41; Fri, 23 Sep 2022 11:33:54 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=r73Y456B; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lq5dvc8I; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbiIWSBt (ORCPT + 99 others); Fri, 23 Sep 2022 14:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231145AbiIWSBp (ORCPT ); Fri, 23 Sep 2022 14:01:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B3611E5CC; Fri, 23 Sep 2022 11:01:43 -0700 (PDT) Date: Fri, 23 Sep 2022 18:01:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1663956102; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h5kvcIo0g99vR5yOZYWaTuCCzeDg6P86/sFcyfvHn2g=; b=r73Y456BdCzPGga9U9RWiUcg4c9FR3fD4Wq5c1IGiUKrH6I2pSTsBvYONv5FyZbOlLJBzq tqOo4IH8vkHKozWj2KG5l7uzK5sLEq9Ek9DjmH1rdmiQANrakgERQGf23it18Ww6qf0QEn Tj14ebjlMScAkbhg+kMu16lTUl7cMBYcj85Q5ncbgWrw/TuktcMM+rKkfMuX+l7NPYAMr4 AeMJBpv3Eicvsv57XyGZxrIhaUqvwue5jGrR6RRvqK94rD01YmhTZ8srBqJKALqGHtVVY9 AviAzvFJMQnduI/4kiMvJje+gt8o8ZiunkBZp5tgS6kyrXUva4gzR9yTvdYYMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1663956102; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h5kvcIo0g99vR5yOZYWaTuCCzeDg6P86/sFcyfvHn2g=; b=lq5dvc8IZt8xcWo1rabpRaqIta0Njlm4MTuYJZa01UQ6+HYbUAjWkNyPDnn737YYStmNcf hLpMQCXBzk8aE7CA== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Add resctrl_rmid_realloc_limit to abstract x86's boot_cpu_data Cc: James Morse , Borislav Petkov , Jamie Iles , Shaopeng Tan , Reinette Chatre , Xin Hao , Cristian Marussi , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220902154829.30399-21-james.morse@arm.com> References: <20220902154829.30399-21-james.morse@arm.com> MIME-Version: 1.0 Message-ID: <166395610108.401.14386026108602409429.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 The following commit has been merged into the x86/cache branch of tip: Commit-ID: d80975e264c8f01518890f3d91ab5bada8fa7f5e Gitweb: https://git.kernel.org/tip/d80975e264c8f01518890f3d91ab5bada8fa7f5e Author: James Morse AuthorDate: Fri, 02 Sep 2022 15:48:28 Committer: Borislav Petkov CommitterDate: Fri, 23 Sep 2022 14:24:16 +02:00 x86/resctrl: Add resctrl_rmid_realloc_limit to abstract x86's boot_cpu_data 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. Signed-off-by: James Morse Signed-off-by: Borislav Petkov Reviewed-by: Jamie Iles Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Tested-by: Xin Hao Tested-by: Shaopeng Tan Tested-by: Cristian Marussi Link: https://lore.kernel.org/r/20220902154829.30399-21-james.morse@arm.com --- 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 e91afe9..8d15568 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 849bdec..e5a48f0 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 9995d04..cb857f7 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 */