Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2313009rwr; Fri, 21 Apr 2023 07:18:38 -0700 (PDT) X-Google-Smtp-Source: AKy350bqd2ns1nG4MRv4upKfJGzCbVyl8YfTdGgvOhVW+zBTNF9Dabk6AfYzQP1Qzz873j3wEooh X-Received: by 2002:a05:6a00:1c95:b0:5e4:f141:568b with SMTP id y21-20020a056a001c9500b005e4f141568bmr5916383pfw.3.1682086718175; Fri, 21 Apr 2023 07:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682086718; cv=none; d=google.com; s=arc-20160816; b=J6pd4V8aepz2KV/s7g3XKMkfKwk/4dhcfGw7RkHnqd64MUlQgXgW93WKwnbt3rZHHB KKo6RWbMwYATHDgF5tGomPMnCuqQYVHxP0o35x4sn50Y9o2nmhz1gYCEh/PUYKOok4ix KmHv9c6Fe4HBuv2CMmCDe0kWbTA5qWHDGpUg7ymIzrkefF9nySBLZUcL5f5eSzaiJikY yEECCLjqgiQrKGk9Nkwb7P8CD8TraoLTGP0YrKJAy+HauAQMXEaSDFMW8PXwrIrMn44l OCXchAiM7VFPTN0yX/0hZWyr8lHPiqdJYaPOzgOVVvE9m8W8/qsmGOlUQeDacfEEkoDJ acmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=K9ehmzwOW4Qc9gQvpwM/ZZofEU4OqXe1UUgzo44mFis=; b=M7uyNL9VP+bWfEJDDNYkIB7cXupKANySVnigd46bQ2jJMayoyrDIGesfyF6mcAk7jE vhJfFLRepBZ1LPvm6KrOkHkwbgFbg3DYlZ/DcKd1r6bAvFg3sea1/ZUCl+HC4rgBTvq3 h9AobpIrUfnCxYcV3x8elV+aGT66X1a5V2e3Ou8IvPz/2/QinFwSCTQfv8mzI1bXwqk1 x0+4UMuOYL6/AYsc1mUcEcNE8XWTGn79G6UX+y4V70vvbkSaQhkm87i2tmFkM3er+hMW s8/pmenxJrKDS4iX2VB0SGavhsbeytFz1YDd5llh+jAKIQmZC7Ple1mMYe9d3MzTDUba qkMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="jQ/EfbEl"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020aa79502000000b0063d3c7837f8si4321771pfp.221.2023.04.21.07.18.25; Fri, 21 Apr 2023 07:18:38 -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=@google.com header.s=20221208 header.b="jQ/EfbEl"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjDUOR7 (ORCPT + 99 others); Fri, 21 Apr 2023 10:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232389AbjDUORt (ORCPT ); Fri, 21 Apr 2023 10:17:49 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8654493DE for ; Fri, 21 Apr 2023 07:17:47 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54f87c0a000so27619907b3.3 for ; Fri, 21 Apr 2023 07:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682086666; x=1684678666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=K9ehmzwOW4Qc9gQvpwM/ZZofEU4OqXe1UUgzo44mFis=; b=jQ/EfbElWOoD7Q5RcZ9PEMa2xeB33n91soMxfAboXtG9IdbuenydvfqGJRJs173o0i vupY0UegJS39vUDZPWg//Oym1AxFL0seSvyqJuJ2iCaBeWL8/gw7JMqp4PQ7JqaqcVXN iNIK16Y8y4rXoL54RmLqFH1ccS7vUP4c6UAmjsYbFOzVDuRQ9s7pTGXMPN+J00WMZlh/ dkBxnZoW2ygD8DRNK6Rn+6P0ltnrb6sIgfoNbyE0Ov4dTaBIn6WtKU0bQDqeRL8gbvhA /vwQxur+PunJsSaBWZDh+8oiYEaDyLaOgE7fzoSNYbg7eGhEH2OnC/ShEbI1U1+eZhx8 QppA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682086666; x=1684678666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K9ehmzwOW4Qc9gQvpwM/ZZofEU4OqXe1UUgzo44mFis=; b=WJfYWDaXt/0BzL6RJS/DtX7Cdq7lJjeXuMOJaYxUfNpEyQDdPuNNa8fE8QqUbafqW7 jAvhqrCYjo9nlWzIF3+PjThZFUz9Y+I90wyJ4W7+s9H2e2A4JfWPRCEpfuc1yt908MgZ plCetMcUhG1KU1QLbe+7yVmDNcX14lg6ha5gQFjZM+2tsjMFNK7DG1+J4FCy0Z2vnYvM j3DUSYjBXHovYNl1IMjlD3iaFx58B989hgU/U9UfbGRThDRQ1m9M9J0TIhEZ8cfovksj 9a6lZH5f07xfpdwZY2GWoklGU1SxtYLt0cg0s1YKMNN17omcMK++bUe3UAot384MsAdN VSFg== X-Gm-Message-State: AAQBX9eSwlOCasS39irAykfitlmpTflJjhODQUY5APN44iu4HddXmWpi CR+u76FZ9f/auf3Ow6u45BOboSFhNJe+uVf7Pg== X-Received: from peternewman0.zrh.corp.google.com ([2a00:79e0:9d:6:c801:daa2:428c:d3fc]) (user=peternewman job=sendgmr) by 2002:a81:b725:0:b0:555:f33e:e346 with SMTP id v37-20020a81b725000000b00555f33ee346mr1484199ywh.6.1682086666823; Fri, 21 Apr 2023 07:17:46 -0700 (PDT) Date: Fri, 21 Apr 2023 16:17:15 +0200 In-Reply-To: <20230421141723.2405942-1-peternewman@google.com> Mime-Version: 1.0 References: <20230421141723.2405942-1-peternewman@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421141723.2405942-2-peternewman@google.com> Subject: [PATCH v1 1/9] selftests/resctrl: Verify all RMIDs count together From: Peter Newman To: Fenghua Yu , Reinette Chatre Cc: Babu Moger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Stephane Eranian , James Morse , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Peter Newman Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 AMD CPUs in particular implement fewer monitors than RMIDs, so add a test case to see if a large number of monitoring groups can be measured together. Signed-off-by: Peter Newman --- tools/testing/selftests/resctrl/test_rmids.sh | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 tools/testing/selftests/resctrl/test_rmids.sh diff --git a/tools/testing/selftests/resctrl/test_rmids.sh b/tools/testing/selftests/resctrl/test_rmids.sh new file mode 100755 index 000000000000..475e69c0217e --- /dev/null +++ b/tools/testing/selftests/resctrl/test_rmids.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +cd /sys/fs/resctrl + +grep -q mbm_total_bytes info/L3_MON/mon_features || { + echo "MBM required" + exit 4 +} + +which perf > /dev/null || { + echo "perf tool required" + exit 4 +} + +num_rmids=$(cat info/L3_MON/num_rmids) + +count=0 + +result=0 + +# use as many RMIDs as possible, up to the number of RMIDs +for i in `seq $num_rmids`; do + mkdir mon_groups/_test_m$((count+1)) 2> /dev/null || break + if [[ -d mon_groups/_test_m$((count+1))/mon_data ]]; then + count=$((count+1)) + else + break; + fi +done + +echo "Created $count monitoring groups." + +if [[ $count -eq 0 ]]; then + echo "need monitoring groups to continue." + exit 4 +fi + +declare -a bytes_array + +unavailable=0 +unavailable0=0 + +for i in `seq $count`; do + bytes_array[$i]=$(cat mon_groups/_test_m${i}/mon_data/mon_L3_00/mbm_total_bytes) + + if [[ "${bytes_array[$i]}" = "Unavailable" ]]; then + unavailable0=$((unavailable0 + 1)) + fi +done + +for i in `seq $count`; do + echo $$ > mon_groups/_test_m${i}/tasks + taskset 0x1 perf bench mem memcpy -s 100MB -f default > /dev/null +done +echo $$ > tasks + +# zero non-integer values +declare -i bytes bytes0 + +success_count=0 + +for i in `seq $count`; do + raw_bytes=$(cat mon_groups/_test_m${i}/mon_data/mon_L3_00/mbm_total_bytes) + raw_bytes0=${bytes_array[$i]} + + # coerce the value to an integer for math + bytes=$raw_bytes + bytes0=$raw_bytes0 + + echo -n "g${i}: mbm_total_bytes: $raw_bytes0 -> $raw_bytes" + + if [[ "$raw_bytes" = "Unavailable" ]]; then + unavailable=$((unavailable + 1)) + fi + + if [[ $bytes -gt $bytes0 ]]; then + success_count=$((success_count+1)) + echo "" + else + echo " (FAIL)" + result=1 + fi +done + +first=$((count-unavailable0)) +second=$((count-unavailable)) +echo "$count groups, $first returned counts in first pass, $second in second" +echo "successfully measured bandwidth from ${success_count}/${count} groups" + +rmdir mon_groups/_test_m* + +exit $result -- 2.40.0.634.g4ca3ef3211-goog