From patchwork Fri Apr 21 14:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Newman X-Patchwork-Id: 86350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1110157vqo; Fri, 21 Apr 2023 07:28:42 -0700 (PDT) X-Google-Smtp-Source: AKy350b+YSK8J7c390Zr2d9MDlFQAO5qG0kpupIyNCJJSKfuQW+d2ePHJPToGK69TKeCyxDjO3kI X-Received: by 2002:a17:90b:4a87:b0:23f:9448:89c2 with SMTP id lp7-20020a17090b4a8700b0023f944889c2mr5644657pjb.7.1682087322736; Fri, 21 Apr 2023 07:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682087322; cv=none; d=google.com; s=arc-20160816; b=GvZK6oS9da/F/3a7kP0Z3PKAqzOE0LAH1lmWh4CA/hKJ1ayHqzGAsqN3Y8f0vy4YHk 24t3rgj8JKPWLrsXO10W2CKZDXGnarjsyAmZdAIAKKWsSGC23qis0lfFIToCSSiW7wOk U5TXYlowVzdbifCrVwstdBKGVCl8//FYv8I5kzTplcv873R+9XpmDQ9qUwVfPXaAFL+m hCa5C85pwHy60yF4kdEYwhud8+FIE5Fzc1kSDKyGepI+JisZMtm4Gznw7MZ9FcXxEu5O FYQCsflrdHvNcN3jjY5U8gCg829wJ0pyF5+f+E7BRSgMOQjI59fEzZX2YzrIKNF1jQPP o/fQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o1-20020a17090aac0100b00240d56569eesi4591021pjq.166.2023.04.21.07.28.25; Fri, 21 Apr 2023 07:28:42 -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 S231923AbjDUOSA (ORCPT + 99 others); Fri, 21 Apr 2023 10:18:00 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763796396793021848?= X-GMAIL-MSGID: =?utf-8?q?1763796396793021848?= 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