From patchwork Tue Apr 18 11:44:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2780670vqo; Tue, 18 Apr 2023 04:49:10 -0700 (PDT) X-Google-Smtp-Source: AKy350YKA6MruGrZGLOphVrR3YRUzfPA6xLnafMOPtmgAwyW8mofnODXn8CaEgIOY4RLtJK87+b9 X-Received: by 2002:a17:90b:300c:b0:23d:3931:7b49 with SMTP id hg12-20020a17090b300c00b0023d39317b49mr1596970pjb.35.1681818550160; Tue, 18 Apr 2023 04:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818550; cv=none; d=google.com; s=arc-20160816; b=A0ZAu1n8yCC1P4Zx4uCBkNmNWZeC1kDk4xreloDd4/Z5XRY9oJcipeLtGAynaP4OZE F/giOcfTtCQdbgaHaIMRMIA2Hv+UmovuKYM8b86+Ip8NIk+HG/KBxB4Zog4YQwqZ2OlF IoygFLJZaDQIeIkfWAQtDnNKlGPQJzUhr4d0/c/u/VVAZd+06NyGBWlvbETUbjSpZ2UR HoT+o7ErXmxPniuiU4Bl9x1RR1V62P79LqtICCgiv4oDh1TpUN5tWwWngG1u+EU/emMu PWj3/Iof50VtGFB5bgFfB9vd2hcV0hZCvAWw9diulkYfccMMlIh+JATbPLmbED+cSy7E vp5g== 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 :dkim-signature; bh=hOOWL5cZAgybLvTfgqyqqJqs20FQ8Dmv7+oo0RcccEg=; b=LEpnP2xOAJxmdRe/WCJcuGueRaURsi9nhJYZRk8JpJ0he9Xjif+1JrjGCz8NhLZZt7 BCGCaPbewFwm0Sd4vtUINeHJQoGItnAYZBs0tB50Xrj4e1rOfQCBQIIkVvJ/7N+Fa6Gj NJZoPYFd+1i8x8bmeVSeSYBgjzOkGaGgWhK0Yo9PicHG80qiG1VUBkNbijGCNxEwMnpa /is08hwcvgoVYIgCZbab1UipdIViP/fKcN8IqM0tafi0JG+meU+VUKlgeH5mUuuEj/Uw fnkaT0ekrOS0rp30bn6W+zLDzTLtmo6c4/6NNAbA/XlFxDEF3ATf7H0ZlaTHLio9kFFh Thyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S79S7sEQ; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mj12-20020a17090b368c00b00246799bf0c2si13457168pjb.187.2023.04.18.04.48.57; Tue, 18 Apr 2023 04:49:10 -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=@intel.com header.s=Intel header.b=S79S7sEQ; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbjDRLpf (ORCPT + 99 others); Tue, 18 Apr 2023 07:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjDRLpb (ORCPT ); Tue, 18 Apr 2023 07:45:31 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9460855AC; Tue, 18 Apr 2023 04:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818330; x=1713354330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gKz1qH2cDM86ZzghpGTcpGq4JirHuIesPeKIy9RAyIA=; b=S79S7sEQHo111z3klaQ2A//opsbih0hYCxF9YOIlo3DuHJSAkjvF9B4C V70praE77u5WPYrafjaxtMAN/uxqLzIu1sQBjMlG2THrwzf251kclD3+d W02Mxz1gd5cRoDhO+rgGXxjTR5T/r5qilSg1H8FOvB0oELJNhewFwdIqO Lhk+hViniaGEy16U3H6A2VNhCcCAAqQS/cpw26uwZGTDaWzeHC3vhUORS XdB7hYKGhhCCyq8SCd1HTTMy0g1gOfZv32tAmutERwkGbsEiSPfuYiHt7 9d57JRizN1WaJdwQZnmpxMR3l22K/LAl6VGWXtdVrwf1NPedRqiguvwc2 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994279" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994279" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601516" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601516" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:27 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Babu Moger , Sai Praneeth Prakhya , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 01/24] selftests/resctrl: Add resctrl.h into build deps Date: Tue, 18 Apr 2023 14:44:43 +0300 Message-Id: <20230418114506.46788-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514568046457988?= X-GMAIL-MSGID: =?utf-8?q?1763514568046457988?= Makefile only lists *.c as build dependecies for the restctrl_tests executable which excludes resctrl.h. Add *.h to wildcard() cover also resctrl.h. Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file system operations and data") Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile index 73d53257df42..2dc7da221795 100644 --- a/tools/testing/selftests/resctrl/Makefile +++ b/tools/testing/selftests/resctrl/Makefile @@ -7,4 +7,4 @@ TEST_GEN_PROGS := resctrl_tests include ../lib.mk -$(OUTPUT)/resctrl_tests: $(wildcard *.c) +$(OUTPUT)/resctrl_tests: $(wildcard *.c *.h) From patchwork Tue Apr 18 11:44:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781249vqo; Tue, 18 Apr 2023 04:50:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZXnzWEJqxZ9tPlfi6s8teja1gL9y2f/lR1rg10shz6064R6O9Ees4ferTE49q652Jt611p X-Received: by 2002:a05:6a20:4403:b0:f0:a6a0:3c0e with SMTP id ce3-20020a056a20440300b000f0a6a03c0emr2173488pzb.29.1681818615093; Tue, 18 Apr 2023 04:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818615; cv=none; d=google.com; s=arc-20160816; b=XHwNXDoobIqUx5XznyGom6k1QnWdgqmc2/urw+K2CJ/mrEsIPbVB4zryS2yseQ+OyE yk1e+qgSzku295bTgr84ZvKz68nSJSTQjeojimaJFc/5sQubnjsB7DErNsQXeM0TCp4a J+0MBwA+1fq6uVbelfKcnwzm7/hyy/daE1lUBWolLjIFo4V4tHD/4hdr2EUKnEup17Tp ftok/12rruwe2/G1etJCdDjFabsiCBW+1BjrjJ+dzcsMmoSwHhthfRjkmf4i62llXHc1 qMQ964jzSWqlpelHQEzG2m/BaY2GpbgPQYnYoLvUNM+cK3iGsBFbQTr4qbZkDN7txAfq HmOg== 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 :dkim-signature; bh=zUiTWm1zCTVDhTrgJrqIIuNPok2zL77LTwzVXwgCdEc=; b=hh71PYLkqh9veeYxgHQ8Vc+R7bY1Ip+Ol0nJmECUMKUsnTrjBJ2P+DptO/mdR6PDv7 Q5IeShB5UQ+jr9OgEZNnJkn554LSkFIZjQmD82T8cE/2K1NuE463NSW4/8MrKzh0IlF6 8Qt926d1LrHjoxFJQByNah4D5CAe1HNfpOGr4mPhkOwTXfUc92bv1aMCkgJYR6yNJ8a0 uksPvp28ualLLYp8ex9zCpBxHoNvbn81isXsHG8s9dLJF+teGkEPmlP5eel5Rl7U66QW 0bjcJBnpbjRAMqKHUqe2ohLaKUic6LFwLBaC5WG7h0gMa1V1xtOVE+r3J2JMhceHTOGU deMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mjl366wT; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b0051f3c811e2csi1499070pge.98.2023.04.18.04.50.02; Tue, 18 Apr 2023 04:50:15 -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=@intel.com header.s=Intel header.b=Mjl366wT; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbjDRLpi (ORCPT + 99 others); Tue, 18 Apr 2023 07:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjDRLpf (ORCPT ); Tue, 18 Apr 2023 07:45:35 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 852686588; Tue, 18 Apr 2023 04:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818333; x=1713354333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GJB674v5NrvIZOn3jfZ46l+HF/VsfpsEZVPcKvhkSv8=; b=Mjl366wT9jjlusq9UztVP+XJC/5WTxjV3dZSQOe3I60eCVpb3EUa0rzr BoIEQpPg67It6DdHW/99X7rwj2JmNPEqQCfhwbkqq9iDVDCKFqkz7ASbr MANXL65AylIvlrO1Ijw5IldOZcGEe8NDDj1FECEVub1qUa462OJEowKts +qXk28pZMhT4oBKHjzw/8r8QW8lzLgIKtd7KlfxlSkWvS0VCIe7G6+F54 ur4eaTTWMjfGO75FwMsmjAsElBqhKpgRdQgcQSnl+iwRZ61VIBBDvFjC1 WhChfRjDqylCGNg/dJ8wzb0bbSGjcrqhBD+xrCXWWhDWszsDfFMPSuqFR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994286" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994286" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601532" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601532" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:30 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 02/24] selftests/resctrl: Check also too low values for CBM bits Date: Tue, 18 Apr 2023 14:44:44 +0300 Message-Id: <20230418114506.46788-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514636248264722?= X-GMAIL-MSGID: =?utf-8?q?1763514636248264722?= CAT test only validates that the number of CBM bits is not too large but it could be too small too. Check and return error before starting the CAT test if the number of CBM bits is too small. Fixes: 09a67934625a ("selftests/resctrl: Don't hard code value of "no_of_bits" variable") Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index fb1443f888c4..722c9cd4120d 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -129,7 +129,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) if (!n) n = count_of_bits / 2; - if (n > count_of_bits - 1) { + if (n < 1 || n > count_of_bits - 1) { ksft_print_msg("Invalid input value for no_of_bits n!\n"); ksft_print_msg("Please enter value in range 1 to %d\n", count_of_bits - 1); From patchwork Tue Apr 18 11:44:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2792863vqo; Tue, 18 Apr 2023 05:08:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/31Xx8cODjksGC4GWqRQNaryKu79uxYFg4bOtY57zVlHHh9KwfPbmohEjqMpNXVYs1+Ol X-Received: by 2002:a17:90a:f0c6:b0:23f:d487:1bc8 with SMTP id fa6-20020a17090af0c600b0023fd4871bc8mr2067395pjb.13.1681819690693; Tue, 18 Apr 2023 05:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819690; cv=none; d=google.com; s=arc-20160816; b=szwpKzuHaf5BIotRwYnzH+I5TOlcfhHqr74dp/V749AWHUuAsBpw/usf4k7ByjwMkJ /PyvaCgYkvlFApDcqjRYGKyQSB+lXHU2dvSsroX0UsBz/v//uVS7bsdud8LxTwfSF+/b DA+u7myZsDLJsil8I/KRqS05IqQY62/wWPN5SgUrbJ7SKKSLpiJ/VqsGYIVOw4PuGlFB xRwNCmRuDNpFsSDnKm8CsywenMEhO3VWzbq3p0O8WuAipMn6Xvjr82EY7U0OepajQKJm Xyx7aeiBPtJv4N9eXRJ+ELTi/rN4OjuunhvkAoWmHkuFYeBspqOUEZR7AqR/b6ctybF6 8z7Q== 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 :dkim-signature; bh=GZDy01/ZWL/mMJyMXrl+i5FJgs42KoS7N0aw3qPz548=; b=TDpYwevqJ+3w1bK3gZ69ipoz9SVxQ6lVljMVMgicCsAEwtVWn/3DDO4avgbYj5Nme3 U8Jh36avjLJ3b+SWZhHDfbGM0jP2Qg6S798kvAWa+SvWQFddzko+1BIknzsdnXgudHUc Lc137KW1hjHs1pMfx80a6tONIAi2AxOnWQ7c0CqsPeWXwbq8PNmUfR0go04pRkG/HUI6 /RKtwV0N0FbDFkgYOKnm/6d6C99BKDgIJeYeGq/y5pyKNXN/qcacblyobQ3rHdsKhTgZ 72q5w+iIICn/+GkreRunH11r/nwT/3//xEUkAs3uIrhecBDqmGoNqfpwaRt6fhDcWmhd 8lqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="OGV41f/5"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a17090abc8200b00246869a3320si13539459pjr.178.2023.04.18.05.07.54; Tue, 18 Apr 2023 05:08:10 -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=@intel.com header.s=Intel header.b="OGV41f/5"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231571AbjDRLpr (ORCPT + 99 others); Tue, 18 Apr 2023 07:45:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjDRLpk (ORCPT ); Tue, 18 Apr 2023 07:45:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7FF55AC; Tue, 18 Apr 2023 04:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818337; x=1713354337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/lNNQ1ryS2nUiXdhxYrGQzDTl9xz2Ge6O9SJ7c4eETs=; b=OGV41f/5jAd9wQpL0H5MWBSJgmksXMTwZI8+QJLtL6iX73tfCOkPKOuV ENneDoo1DAh5zxmaB244XqMD9Act1ntSGI6gykPtJt/5gaMomvEchd8nb pYR4ayIyJ+OS9fhldM7bUMUFWV3PBSddDWCWyipLvL+HuimbdaG7mc5e0 7+9t1od4vEee/6z9KKGR3svMDXjW3llHP0geOq0/q9pz1SJpa2yRoXwrZ 1NxKRDa8vlm/Yyv4vLFO44lv9n5upeh+qf7n2MVDhEjkxEjDOEGB/7hj6 HOw6yt71jc/g4eHV7kBCpb2n9fCPliCUsZl+C8ckXZYgIIUkD7uM8kDnq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994297" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994297" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601542" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601542" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:33 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Sai Praneeth Prakhya , Babu Moger , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 03/24] selftests/resctrl: Move resctrl FS mount/umount to higher level Date: Tue, 18 Apr 2023 14:44:45 +0300 Message-Id: <20230418114506.46788-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515764077809291?= X-GMAIL-MSGID: =?utf-8?q?1763515764077809291?= A few places currently lack umounting resctrl FS on error paths. Each and every test does require resctrl FS to be present already for feature check. Thus, it makes sense to just mount it on higher level in resctrl_tests.c. Move resctrl FS mount/unmount into each test function in resctrl_tests.c. Make feature validation to simply check that resctrl FS is mounted. Fixes: 790bf585b0ee ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest") Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Fixes: f1dd71982d19 ("selftests/resctrl: Skip the test if requested resctrl feature is not supported") Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 6 --- tools/testing/selftests/resctrl/cmt_test.c | 4 -- .../testing/selftests/resctrl/resctrl_tests.c | 48 ++++++++++++++++--- tools/testing/selftests/resctrl/resctrl_val.c | 5 -- tools/testing/selftests/resctrl/resctrlfs.c | 7 ++- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 722c9cd4120d..dec3151cf888 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -106,10 +106,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) cache_size = 0; - ret = remount_resctrlfs(true); - if (ret) - return ret; - /* Get default cbm mask for L3/L2 cache */ ret = get_cbm_mask(cache_type, cbm_mask); if (ret) @@ -227,8 +223,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) out: cat_test_cleanup(); - if (bm_pid) - umount_resctrlfs(); return ret; } diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index af71b2141271..426d11189a99 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -86,10 +86,6 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) cache_size = 0; - ret = remount_resctrlfs(true); - if (ret) - return ret; - if (!validate_resctrl_feature_request(CMT_STR)) return -1; diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 9b9751206e1c..5c9ed52b69f2 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -77,9 +77,15 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBM BW change ...\n"); + res = remount_resctrlfs(false); + if (res) { + ksft_exit_fail_msg("Failed to mount resctrl FS\n"); + return; + } + if (!validate_resctrl_feature_request(MBM_STR) || (get_vendor() != ARCH_INTEL)) { ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n"); - return; + goto umount; } if (!has_ben) @@ -88,6 +94,9 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ksft_test_result(!res, "MBM: bw change\n"); if ((get_vendor() == ARCH_INTEL) && res) ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); + +umount: + umount_resctrlfs(); } static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, @@ -97,15 +106,24 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBA Schemata change ...\n"); + res = remount_resctrlfs(false); + if (res) { + ksft_exit_fail_msg("Failed to mount resctrl FS\n"); + return; + } + if (!validate_resctrl_feature_request(MBA_STR) || (get_vendor() != ARCH_INTEL)) { ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n"); - return; + goto umount; } if (!has_ben) sprintf(benchmark_cmd[1], "%d", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); + +umount: + umount_resctrlfs(); } static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) @@ -113,9 +131,16 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) int res; ksft_print_msg("Starting CMT test ...\n"); + + res = remount_resctrlfs(false); + if (res) { + ksft_exit_fail_msg("Failed to mount resctrl FS\n"); + return; + } + if (!validate_resctrl_feature_request(CMT_STR)) { ksft_test_result_skip("Hardware does not support CMT or CMT is disabled\n"); - return; + goto umount; } if (!has_ben) @@ -124,6 +149,9 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) ksft_test_result(!res, "CMT: test\n"); if ((get_vendor() == ARCH_INTEL) && res) ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); + +umount: + umount_resctrlfs(); } static void run_cat_test(int cpu_no, int no_of_bits) @@ -132,13 +160,23 @@ static void run_cat_test(int cpu_no, int no_of_bits) ksft_print_msg("Starting CAT test ...\n"); + res = remount_resctrlfs(false); + if (res) { + ksft_exit_fail_msg("Failed to mount resctrl FS\n"); + return; + } + if (!validate_resctrl_feature_request(CAT_STR)) { ksft_test_result_skip("Hardware does not support CAT or CAT is disabled\n"); - return; + goto umount; } res = cat_perf_miss_val(cpu_no, no_of_bits, "L3"); ksft_test_result(!res, "CAT: test\n"); + + +umount: + umount_resctrlfs(); } int main(int argc, char **argv) @@ -266,7 +304,5 @@ int main(int argc, char **argv) if (cat_test) run_cat_test(cpu_no, no_of_bits); - umount_resctrlfs(); - ksft_finished(); } diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index ab1eab1e7ff6..e8f1e6a59f4a 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -648,10 +648,6 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) return ret; } - ret = remount_resctrlfs(param->mum_resctrlfs); - if (ret) - return ret; - /* * If benchmark wasn't successfully started by child, then child should * kill parent, so save parent's pid @@ -788,7 +784,6 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) signal_handler_unregister(); out: kill(bm_pid, SIGKILL); - umount_resctrlfs(); return ret; } diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index fb00245dee92..42f547a81e25 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -611,7 +611,8 @@ char *fgrep(FILE *inf, const char *str) * validate_resctrl_feature_request - Check if requested feature is valid. * @resctrl_val: Requested feature * - * Return: True if the feature is supported, else false + * Return: True if the feature is supported, else false. False is also + * returned if resctrl FS is not mounted. */ bool validate_resctrl_feature_request(const char *resctrl_val) { @@ -619,11 +620,13 @@ bool validate_resctrl_feature_request(const char *resctrl_val) bool found = false; char *res; FILE *inf; + int ret; if (!resctrl_val) return false; - if (remount_resctrlfs(false)) + ret = find_resctrl_mount(NULL); + if (ret) return false; if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { From patchwork Tue Apr 18 11:44:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2788107vqo; Tue, 18 Apr 2023 05:02:21 -0700 (PDT) X-Google-Smtp-Source: AKy350YBCcebmi3avTXmKS1yt/u8Udbaz+8wJSySBKPg1f/fcdMDAMcUAfTxdFm/C2yzkBLkRSpp X-Received: by 2002:a17:902:a98b:b0:1a1:c7b2:e7c7 with SMTP id bh11-20020a170902a98b00b001a1c7b2e7c7mr2000075plb.49.1681819340637; Tue, 18 Apr 2023 05:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819340; cv=none; d=google.com; s=arc-20160816; b=rC/06f4rdJhHHZlvbk3tlFb7sI04j/tan31184KrfVk/KiYsYPNzcboIwN/678ypzD bmGhdYubQm6mZXWBsGktDTODi+KRzxe8VSelmI7n4h0GUxfh9Lmq8zKUKJs4AIBxOTsm cuKtz0zweEgfEoamUEEhxZZFi7Ss/DZzblx3zrjYxunEPMLfPyy/89JQxvEevij63zuN SqgCUZ6mrt7FcBl6x5YcdblN/yLDsLCYVwC8MnP5JoZPXAq34Pa0u9BUxxBOuwGBkTaT NRCwIwdEv+tARVCeuCxRoyPhoLSiB1RGc+beLRfVczernWuaZlCRgNlIMa7o4h4ZZPA5 8Kmg== 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 :dkim-signature; bh=TAHvmelG93RbHGqlt2GjsRBWE+CGMqiWLbXDZEpbm/g=; b=S1M2A8fKl8UJP0NKlxNPJBAwESu5HOF+/j0PRKmlXbBVjO48qxKzV9tuPUs9yBnXwc QaWsDLZI30pN7vKOImWJJY4E36LstfvKXL6lOOnDpsKrxaiZbWdU3EZl8boeOEa6sxrt P/oPogMFTTmRy8zi3KM0UDzpt8ZPmGh/VLVoVzqXnOEHi7NmHdEuGEa5WK59NhCZMjky Dlqh98kWqLyU8hdeBtExcn8g6n6rHP/t+F4uF1ylJEgxYQm7NB9scDH2jeIe8MSDx9tC InNrY0z6h8z4Ov53cbMM99/QcjyzXVElITDWatKE6DEgHPdFm2sRzJGo37B+qM1dsIMn KEjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="m1Ln5/dh"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170902b70c00b001a0442e0038si13874584pls.414.2023.04.18.05.02.06; Tue, 18 Apr 2023 05:02:20 -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=@intel.com header.s=Intel header.b="m1Ln5/dh"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbjDRLpw (ORCPT + 99 others); Tue, 18 Apr 2023 07:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjDRLpq (ORCPT ); Tue, 18 Apr 2023 07:45:46 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42DEA8694; Tue, 18 Apr 2023 04:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818340; x=1713354340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Uf3vHyHTkkipMIet9UuxLalFY0HOARu70226ErvP9Bw=; b=m1Ln5/dhg41NVQ6N32n60hlymuISzv/aSjqNfcipzY2tve4uz6diXMay hFI45P2cMSYqR9/7QlDF7iguZN3M17nhatyfF8VrFqKwECf+ra3ExGTEr YIUeeMwR0KaY6L86bmGgQ69S3TAeBebLlJsZWIsBW/RbTrZ05A3DGkAal 9Kza676oTZ3uhj3xtjWYDNdMze1YtYQLHrKpvruta/teBHnKduUlPlP6d 8zahVhKyqx9b/7PASQoVKHfO5fiMz0CByvrk1kGxmyiht3lRu24wx+Euz Ms8qisGikrt6ZXqHt6kp3mW2wJ6jamHm4fzJ/HORhV70eRjkZt2pGqNxz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994304" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994304" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601560" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601560" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:37 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 04/24] selftests/resctrl: Remove mum_resctrlfs Date: Tue, 18 Apr 2023 14:44:46 +0300 Message-Id: <20230418114506.46788-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515396567136950?= X-GMAIL-MSGID: =?utf-8?q?1763515396567136950?= Resctrl FS mount/umount are now cleanly paired. Removed mum_resctrlfs that is what is left of the earlier remount trickery to make the code cleaner. Rename remount_resctrlfs() to mount_resctrlfs() to match the reduced functionality. While at it, group the mount/umount prototypes in the header. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 1 - tools/testing/selftests/resctrl/cmt_test.c | 1 - tools/testing/selftests/resctrl/mba_test.c | 1 - tools/testing/selftests/resctrl/mbm_test.c | 1 - tools/testing/selftests/resctrl/resctrl.h | 4 +--- .../testing/selftests/resctrl/resctrl_tests.c | 8 ++++---- tools/testing/selftests/resctrl/resctrlfs.c | 20 +++++-------------- 7 files changed, 10 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index dec3151cf888..86c62dfd8e78 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -140,7 +140,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) struct resctrl_val_param param = { .resctrl_val = CAT_STR, .cpu_no = cpu_no, - .mum_resctrlfs = false, .setup = cat_setup, }; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 426d11189a99..d31e28416bb7 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -113,7 +113,6 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) .ctrlgrp = "c1", .mongrp = "m1", .cpu_no = cpu_no, - .mum_resctrlfs = false, .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .span = cache_size * n / count_of_bits, diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index cde3781a9ab0..3d53c6c9b9ce 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -154,7 +154,6 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd) .ctrlgrp = "c1", .mongrp = "m1", .cpu_no = cpu_no, - .mum_resctrlfs = true, .filename = RESULT_FILE_NAME, .bw_report = bw_report, .setup = mba_setup diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 538d35a6485a..24326cb7bc21 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -123,7 +123,6 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) .mongrp = "m1", .span = span, .cpu_no = cpu_no, - .mum_resctrlfs = true, .filename = RESULT_FILE_NAME, .bw_report = bw_report, .setup = mbm_setup diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 87e39456dee0..c737eb47eacc 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -53,7 +53,6 @@ * @mongrp: Name of the monitor group (mon grp) * @cpu_no: CPU number to which the benchmark would be binded * @span: Memory bytes accessed in each benchmark iteration - * @mum_resctrlfs: Should the resctrl FS be remounted? * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) * @setup: Call back function to setup test environment @@ -64,7 +63,6 @@ struct resctrl_val_param { char mongrp[64]; int cpu_no; unsigned long span; - bool mum_resctrlfs; char filename[64]; char *bw_report; unsigned long mask; @@ -84,8 +82,8 @@ extern char llc_occup_path[1024]; int get_vendor(void); bool check_resctrlfs_support(void); int filter_dmesg(void); -int remount_resctrlfs(bool mum_resctrlfs); int get_resource_id(int cpu_no, int *resource_id); +int mount_resctrlfs(void); int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); bool validate_resctrl_feature_request(const char *resctrl_val); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 5c9ed52b69f2..f3303459136d 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBM BW change ...\n"); - res = remount_resctrlfs(false); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -106,7 +106,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBA Schemata change ...\n"); - res = remount_resctrlfs(false); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -132,7 +132,7 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) ksft_print_msg("Starting CMT test ...\n"); - res = remount_resctrlfs(false); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -160,7 +160,7 @@ static void run_cat_test(int cpu_no, int no_of_bits) ksft_print_msg("Starting CAT test ...\n"); - res = remount_resctrlfs(false); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 42f547a81e25..45f785213143 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -48,29 +48,19 @@ static int find_resctrl_mount(char *buffer) } /* - * remount_resctrlfs - Remount resctrl FS at /sys/fs/resctrl - * @mum_resctrlfs: Should the resctrl FS be remounted? + * mount_resctrlfs - Mount resctrl FS at /sys/fs/resctrl * * If not mounted, mount it. - * If mounted and mum_resctrlfs then remount resctrl FS. - * If mounted and !mum_resctrlfs then noop * * Return: 0 on success, non-zero on failure */ -int remount_resctrlfs(bool mum_resctrlfs) +int mount_resctrlfs(void) { - char mountpoint[256]; int ret; - ret = find_resctrl_mount(mountpoint); - if (ret) - strcpy(mountpoint, RESCTRL_PATH); - - if (!ret && mum_resctrlfs && umount(mountpoint)) - ksft_print_msg("Fail: unmounting \"%s\"\n", mountpoint); - - if (!ret && !mum_resctrlfs) - return 0; + ret = find_resctrl_mount(NULL); + if (!ret) + return -1; ksft_print_msg("Mounting resctrl to \"%s\"\n", RESCTRL_PATH); ret = mount("resctrl", RESCTRL_PATH, "resctrl", 0, NULL); From patchwork Tue Apr 18 11:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2793538vqo; Tue, 18 Apr 2023 05:09:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bK+t8oya2Z0MLfp73GhkwwjBUjLq/6XNpFBfDXPMgQ79KhZnU/g7HRbp2gwjVmPTNfNPSr X-Received: by 2002:a17:90b:315:b0:247:4c28:311f with SMTP id ay21-20020a17090b031500b002474c28311fmr1857335pjb.34.1681819745118; Tue, 18 Apr 2023 05:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819745; cv=none; d=google.com; s=arc-20160816; b=hnD/oDUCJJXMvFSws/TBv3dV7Wl7rA4wGFtKo9Tk6U/YHtU+hYYBCsuTD1VXliTOVP eSmwoaCaleQqPTj01h+6KGusL60hJHBOHnUdyhI76jjiYFFa36BTc4L++KytcG9jlhE8 AE7POx7xLSXusx7uQRBaElk1PT3lmlYG5gXYQiiwdeqh4WPoF5bdJTbsYp4quZZCt5iM ROMYK6UtOkU6sOwuTxow0cWA1MYwmuKdcNVg6RXrNqOZGStKwdEr1TOycmJNVhD5UXnF 0byGeAVtPg5CwMvxtRB0241J8OlSOeKwjtDMEVIyYiWrJi9U8tVZZUNWA2fMAukwMkdN dwxQ== 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 :dkim-signature; bh=l4MoWBwuFKa90/eShM5WS1p4WDHcHNXHGLZtAncVEec=; b=qUNtlc3+lXTaD9irbGggvVbPMbb2fR3uSjKxEi6zFjEf+swcxIErPRXB9uNQXy+e1A XSRodwM6RLmcqQ1XsS0PriZnY5Of60BRuId6lwgu4Nd7kTfloLHsHd9Z4jmb49hJCUfR Th6cUwVsksc+5xV/wt5Voz03lN4ePhD1yykhTZweiftc7fxuDZajOoM5klBtM1INcc6K rJF54UVpkTXoI+TSqNfhQ80VBOC/DndQX+GUGbs6cKaFr9erm5k52+niuvNRKw/xgNYN ype+Cl3sjhhXJjNUTXi8kID8YUp7gnGGLmQSWZGhB8pTjj9rzxKpnnBvMBjiAvyXTpcI V3Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nMZc4pec; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a63db44000000b005030859019fsi14337779pgi.675.2023.04.18.05.08.48; Tue, 18 Apr 2023 05:09:04 -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=@intel.com header.s=Intel header.b=nMZc4pec; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbjDRLqF (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjDRLpv (ORCPT ); Tue, 18 Apr 2023 07:45:51 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B84893E8; Tue, 18 Apr 2023 04:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818343; x=1713354343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uEDV7s33ghMTtcqD+BKI2d0Qj/HCSr2RAHpjP1pxMq8=; b=nMZc4pecJ8Yjk7zwNZAepIVOVK16qLG2Wt9ozzdIlxtEQP4yyXxqSs4y eUXLtdX+CAIUsKTkmqMC5grrLdN4VY57i7WDDc8fLIaDydfmSL+P9eTC+ izpUEouUVDnGzAzCJZ9HrPD3hkkhOg4AP4uSUVahgp6G7+oJ2MQIeBoHw 2EIAvmxZ8axlexUhB7ksprCvHeLG6zzbBPQtoc5RzHhNcqJobapXkmeSM irR8iVbqT84VKE8cAOUpuBJ45KpRh/ES/1tNxOdsPqu3IbQWXHsXhc4YD 7VdaQmXzHRyT+DEVk2O/1URKopvY3XihpA7skYDxfU0XpHX1YySxFxUkd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994316" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994316" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601572" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601572" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:40 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 05/24] selftests/resctrl: Make span unsigned long everywhere Date: Tue, 18 Apr 2023 14:44:47 +0300 Message-Id: <20230418114506.46788-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515820706567090?= X-GMAIL-MSGID: =?utf-8?q?1763515820706567090?= fill_buf(), show_bw_info(), and resctrl_val_param.span define span as unsigned long. Consistently use unsigned long elsewhere too for span parameters. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mbm_test.c | 8 ++++---- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrl_tests.c | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 24326cb7bc21..3c389ccfea41 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -15,7 +15,7 @@ #define NUM_OF_RUNS 5 static int -show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) +show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, unsigned long span) { unsigned long avg_bw_imc = 0, avg_bw_resc = 0; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; @@ -40,14 +40,14 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) ksft_print_msg("%s Check MBM diff within %d%%\n", ret ? "Fail:" : "Pass:", MAX_DIFF_PERCENT); ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per); - ksft_print_msg("Span (MB): %d\n", span); + ksft_print_msg("Span (MB): %lu\n", span); ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc); ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc); return ret; } -static int check_results(int span) +static int check_results(unsigned long span) { unsigned long bw_imc[NUM_OF_RUNS], bw_resc[NUM_OF_RUNS]; char temp[1024], *token_array[8]; @@ -115,7 +115,7 @@ void mbm_test_cleanup(void) remove(RESULT_FILE_NAME); } -int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) +int mbm_bw_change(unsigned long span, int cpu_no, char *bw_report, char **benchmark_cmd) { struct resctrl_val_param param = { .resctrl_val = MBM_STR, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index c737eb47eacc..fe54c2b4f014 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -99,7 +99,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int run_fill_buf(unsigned long span, int malloc_and_init_memory, int memflush, int op, char *resctrl_va); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); -int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd); +int mbm_bw_change(unsigned long span, int cpu_no, char *bw_report, char **benchmark_cmd); void tests_cleanup(void); void mbm_test_cleanup(void); int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index f3303459136d..6bc0eda25e5d 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -70,7 +70,7 @@ void tests_cleanup(void) cat_test_cleanup(); } -static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, +static void run_mbm_test(bool has_ben, char **benchmark_cmd, unsigned long span, int cpu_no, char *bw_report) { int res; @@ -99,7 +99,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, umount_resctrlfs(); } -static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, +static void run_mba_test(bool has_ben, char **benchmark_cmd, unsigned long span, int cpu_no, char *bw_report) { int res; @@ -118,7 +118,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, } if (!has_ben) - sprintf(benchmark_cmd[1], "%d", span); + sprintf(benchmark_cmd[1], "%lu", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); @@ -182,9 +182,10 @@ static void run_cat_test(int cpu_no, int no_of_bits) int main(int argc, char **argv) { bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; - int c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 0; char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64]; char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE]; + int c, cpu_no = 1, argc_new = argc, i, no_of_bits = 0; + unsigned long span = 250; int ben_ind, ben_count, tests = 0; bool cat_test = true; @@ -274,7 +275,7 @@ int main(int argc, char **argv) benchmark_cmd[i] = benchmark_cmd_area[i]; strcpy(benchmark_cmd[0], "fill_buf"); - sprintf(benchmark_cmd[1], "%d", span); + sprintf(benchmark_cmd[1], "%lu", span); strcpy(benchmark_cmd[2], "1"); strcpy(benchmark_cmd[3], "1"); strcpy(benchmark_cmd[4], "0"); From patchwork Tue Apr 18 11:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2780846vqo; Tue, 18 Apr 2023 04:49:29 -0700 (PDT) X-Google-Smtp-Source: AKy350aSsy/s6QdIQE5hELMFvaxHvEj0l7P77iWUQeCYJfYo/qW3Q5EURplG0W0IoqoXIVSPoRbu X-Received: by 2002:a17:903:41c2:b0:1a6:4118:6f9e with SMTP id u2-20020a17090341c200b001a641186f9emr2045751ple.20.1681818569030; Tue, 18 Apr 2023 04:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818569; cv=none; d=google.com; s=arc-20160816; b=a7JxOoeGK8OcOL25B0fJeqH0+pqJcfJljneOB0vmzc9IeBR8rvxv9uzhN6tYSnk5AF YzBwy00pY+BgfsqbP3eTVQiBMX/pZlLPgReMR/A9XKvcBad9oMZZSCBx7woK65hq7z1V gqEVo/oYqqgn75cDYFJye6qzJgvFPz/Oc81DdulqSo4uciPUsRlqvwn3Zg0zeXsynsqf KxLCH4WcXL11eUJ02yMEn7QXNbzpYL5S1+j3MDESmwjZ0SttnF98jmIFDzgKM7z6NH4U rHyBFsYK7POCoAXiRem0i19kKROdSWztnrStZogl41TGscNM8oNaUCwDX1ZTjThyqQjK EGvA== 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 :dkim-signature; bh=7BvCkBadX8MRud8PwS3ajYEMaUvOoIG0PQ5MfEKjVn0=; b=Y9qlMTQ0R12coOPobkR9tGrYX1T0QH8RbGsSADOOV2/9AIr/dDu2zgafdWHaItvRE0 cCdNK9Wojpmw9p80/FLJRPcCN4SKzSkBzea0Y4pDW8SxEJxzrA/p7heCow0wlH3TSuQI x7N/i2Am9DbHaB49LlzoSXHKWSoMMZf0/+zrEmz3qonR36LR3ZFI+YJY+ahKg/YXXs5T FjtD9idvmWh9tGEuUIeNCHRbt9FvWxUAcA8bWTeN4Ylf5wji80TwRRIg9MxnCtC8ltmC j5UlidHNNYWn7ceTsD7Tg3x4GFDeNwG5NMI8V6KLNlC6piDf2LuW664xeCkiG77q57Rd 5Byw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fJmWGDkx; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o23-20020a170902779700b001a699fc81e8si10974117pll.98.2023.04.18.04.49.16; Tue, 18 Apr 2023 04:49:29 -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=@intel.com header.s=Intel header.b=fJmWGDkx; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjDRLqQ (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbjDRLqC (ORCPT ); Tue, 18 Apr 2023 07:46:02 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCD5769F; Tue, 18 Apr 2023 04:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818347; x=1713354347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lvb0alft8tDAwmxKOkP23wdr8h3cPgxIKtA/80FlHYM=; b=fJmWGDkxQeYjHLIVJTGRSaPruP4HF1zs5sBZvHw3XOS8LK9v1AWqxyEa /CU/5OYE+EbY4BpN8Aw+CUCSAK6NSw8LllvBOc0rUFJkpInt4461Dk9fb 1P/L4h7XhCBl6hdWUvzw6Fgsuh3X1aENOqF98dnh087BpdHJ6y+/gpa/V OdlHjfsT7R8mjAcAC22boJ9tzfyvkuXguE3CL5eOgjIIpBp91Yli7pAyv ACd7A3YFvekWKWapUuAl6vinjwXIFSfogc/G+rwLkpwD9cp+5Wr3++LzQ 9HgscnCcAPYWGmZv1DDzWr0X7cYV07wf3Kfl6IuessAtcJeU29mt4bqNx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994324" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994324" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601583" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601583" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:43 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 06/24] selftests/resctrl: Express span in bytes Date: Tue, 18 Apr 2023 14:44:48 +0300 Message-Id: <20230418114506.46788-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514587669096639?= X-GMAIL-MSGID: =?utf-8?q?1763514587669096639?= Make MBA and MBM tests to use megabytes to represent span. CMT test uses bytes. Convert MBA and MBM tests to use bytes like CMT test to remove the inconsistency between the tests. This also allows removing test dependent buffer sizing from run_benchmark(). Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mbm_test.c | 2 +- tools/testing/selftests/resctrl/resctrl_tests.c | 2 +- tools/testing/selftests/resctrl/resctrlfs.c | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 3c389ccfea41..ea2ea5721e76 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -40,7 +40,7 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, unsigned long span) ksft_print_msg("%s Check MBM diff within %d%%\n", ret ? "Fail:" : "Pass:", MAX_DIFF_PERCENT); ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per); - ksft_print_msg("Span (MB): %lu\n", span); + ksft_print_msg("Span in bytes: %lu\n", span); ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc); ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 6bc0eda25e5d..f1ed2c89f228 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -185,7 +185,7 @@ int main(int argc, char **argv) char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64]; char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE]; int c, cpu_no = 1, argc_new = argc, i, no_of_bits = 0; - unsigned long span = 250; + unsigned long span = 250 * MB; int ben_ind, ben_count, tests = 0; bool cat_test = true; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 45f785213143..09e0a69c81c4 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -296,7 +296,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no) void run_benchmark(int signum, siginfo_t *info, void *ucontext) { int operation, ret, malloc_and_init_memory, memflush; - unsigned long span, buffer_span; + unsigned long span; char **benchmark_cmd; char resctrl_val[64]; FILE *fp; @@ -319,12 +319,7 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) operation = atoi(benchmark_cmd[4]); sprintf(resctrl_val, "%s", benchmark_cmd[5]); - if (strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - buffer_span = span * MB; - else - buffer_span = span; - - if (run_fill_buf(buffer_span, malloc_and_init_memory, memflush, + if (run_fill_buf(span, malloc_and_init_memory, memflush, operation, resctrl_val)) fprintf(stderr, "Error in running fill buffer\n"); } else { From patchwork Tue Apr 18 11:44:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781500vqo; Tue, 18 Apr 2023 04:50:43 -0700 (PDT) X-Google-Smtp-Source: AKy350awV5tJI0pXSi5kuu7e8ZtYgRW6Ojt9oe7iGA4feFyV4lubmcaAJeJHd8fgAD/07UyU9jGm X-Received: by 2002:a17:902:8ecc:b0:1a5:2760:74ef with SMTP id x12-20020a1709028ecc00b001a5276074efmr2015771plo.25.1681818642881; Tue, 18 Apr 2023 04:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818642; cv=none; d=google.com; s=arc-20160816; b=PNG/qn7ERqtWB0lro3CiUeGv7GQ+hRuvHV4mUdF5dv4tqBBeF/HJgxs/3dVyme4hlY JfanL2nE4vwbEnNm9pjqswNwO5v7KIiYTzjke5LYa9SylkPIlzHC1k2prIxzZBL7h1IU erDNgahb2SvSKczmkFdiQgmdM3QLpTe0kM4Zf9KBAxQ5UOdXl0+0KRck27X6IPEP1Yrk HJAYguunhqEAuR5wpcr1VEGfD1CJbDv1UfO0dSc9i4xSRMPThb4yFdL4LUg8KkzFxutR Bm9JpCREBX1aUcToJCLF4omuKEw8YgCyWCwJNfLvIWMxcC2IP37dFuJqBmbIQmZG+urb oozQ== 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 :dkim-signature; bh=WwKDQF91fMIKQyfYhueIEImrv9WMHVr603duA4Q1te0=; b=j4vr7Of6gW+GzGaCzsNkBC6wOZWP0314rG9vrl1c9lx5HbddoNunZM4gc0XH/niHv7 FF2sOt+TD6EehtKGVzqShXicCTQSd/Rya/L730esSQsVQEmbucLTkKmtjdKjpYWF/EWW sdK5/jLRrn3y6A/Y+74asIDrye/NxPx8hL25fXJ+6CyxGKyZax82Ls9WGAGgZxvKG02Q IfJStoh2OA45P0Ft5Iz9zBgYXiNRqvxxDSJ8x+KG7IfpXZhQxlJaHgsZoswNL9Xe8vF3 0BbbxiVECTQJrmmeJrFtUvU0Tl6N8KfwWCA9l7JxJP3UD/xwWwwMkdncGcVmyMnGicMN UaTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nH+Zml/U"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a4ee96c00bsi15304188plr.357.2023.04.18.04.50.31; Tue, 18 Apr 2023 04:50: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=@intel.com header.s=Intel header.b="nH+Zml/U"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231578AbjDRLqU (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbjDRLqJ (ORCPT ); Tue, 18 Apr 2023 07:46:09 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4E89EFA; Tue, 18 Apr 2023 04:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818349; x=1713354349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XvnhBQByfg3h7H+zzMbDixJv01cITD/50orz6/f0R8s=; b=nH+Zml/U6v7XXiV6TAYMPj640qDVeIKur3/O8rozyx2so/ngUiV9tgOW TR8+szejk/amPB7WadP5e2VHsN9k2sH5fRftFiVDME2zoUBxEkvpDVaEA lRW3/qgvirbWtEm3HFdsM9NZK4PB5TtR/aYSkDPdQjAqQcxQBinQGPzPe GmbPXkMda8C8e4GAmySsQi99WWxSYsi0JEEX7rHZdmZ+d9mWy4fvrR9fB sl62H+lHJINKzsAQ6Ei6tzuW8D/s13+j7lQ0uvFBqSzDrnn2cwW1/Wjji 2OZ5bWpGrlvitjMpoXJI3COnF2sgfN/baT8tYdHnDiLlw6I4T7rBMnJ4d A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994331" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994331" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601600" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601600" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:46 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 07/24] selftests/resctrl: Remove duplicated preparation for span arg Date: Tue, 18 Apr 2023 14:44:49 +0300 Message-Id: <20230418114506.46788-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514665080841246?= X-GMAIL-MSGID: =?utf-8?q?1763514665080841246?= When no benchmark_cmd is given, benchmark_cmd[1] is set to span in main(). There's no need to do it again in run_mba_test(). Remove the duplicated preparation for span argument into benchmark_cmd[1] from run_mba_test(). It enables also removing has_ben argument from run_mba_test() as unnecessary. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_tests.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index f1ed2c89f228..3c8ec68eb507 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -99,8 +99,8 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, unsigned long span, umount_resctrlfs(); } -static void run_mba_test(bool has_ben, char **benchmark_cmd, unsigned long span, - int cpu_no, char *bw_report) +static void run_mba_test(char **benchmark_cmd, unsigned long span, int cpu_no, + char *bw_report) { int res; @@ -117,8 +117,6 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, unsigned long span, goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[1], "%lu", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); @@ -297,7 +295,7 @@ int main(int argc, char **argv) run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); if (mba_test) - run_mba_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); + run_mba_test(benchmark_cmd, span, cpu_no, bw_report); if (cmt_test) run_cmt_test(has_ben, benchmark_cmd, cpu_no); From patchwork Tue Apr 18 11:44:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2793989vqo; Tue, 18 Apr 2023 05:09:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZnSdmp4htIo5AaHOXpkmXRfpiib2pN0eRoQ5egsIaVp8utcQtsg51Fg1XhwHeZlI84+ti8 X-Received: by 2002:a17:903:70c:b0:1a6:3b9c:7fea with SMTP id kk12-20020a170903070c00b001a63b9c7feamr1847754plb.36.1681819781465; Tue, 18 Apr 2023 05:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819781; cv=none; d=google.com; s=arc-20160816; b=uAXYgP0j/Cf2VQkhi6auaO+firdJAOrhCKXzQgnb8/k4lRkeksDRTYz+PXyH3v242W MlblQf0cqgBvLEqCRuq5/ztCIcm9GCVCsdSf6BapgRAOylJK19zyB+/fon4yGvamRsO6 WlbIerS7xk8L8E9ONbE63ugZQKmHmOwwxzVeE57x3FCiH3GFVudUMmNgk96VFnMjqsoh B/1f2h+MZFYviNRwcp+EQF3UvMEiCgvZTkYxjH0VBf7uehbRPBZTHLnSZklf7En+gA3A g0y6/1As5zz7nkFEYealZRDbl47RbcVYb0rfISOMndf2J4/krfK/tJvq6LxqI3pkHwLj sG2w== 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 :dkim-signature; bh=kFHS99qAqcl8X2cwxH52KuUyi1mTRfIhD5VK1xGqEmQ=; b=RFkK3uqiGOSRP5heaCQBvb5FCUzZRTKA16qb4DI4G8BbNOuxLF8WN2O1PHzlOgRHq8 pFRT4cNzKCRb5KhkDuyPDfyTa3nEiCawUUIeJ6YdO7KPdluoLnw9KDbj+BXMvt2/0Alb wyUznXp81C213GsOXYzMuLYzbtY5bThBK5QM9vSg0HtarI3gqZ9mgTdPr0yUWiARV3Vt Lzs5BHY7CZnJOhsAhlG0Vs1JEpZwlCP+sLckRuAIYZpr7YoqlmTweMKICgMBIYQS9jc7 27unsTX7baZfZTS1cBDSGDPhVCUgQjUnxJmKkPXd//VTEtp7FzO8NBqOqZiA2bl9YtCR 9maQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iJQSg1eL; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a170902db0d00b001a64541624asi14593242plx.484.2023.04.18.05.09.24; Tue, 18 Apr 2023 05:09:41 -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=@intel.com header.s=Intel header.b=iJQSg1eL; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbjDRLqZ (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbjDRLqQ (ORCPT ); Tue, 18 Apr 2023 07:46:16 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35336AD1A; Tue, 18 Apr 2023 04:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818352; x=1713354352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9In+I9Z9X5Iz5xEzsu53yNiUH7AWd3qUitVjPSQ+pLU=; b=iJQSg1eL88KtXt6r4UTiaesFT/fgDWc3/WCvu4SiVyUeq48RmwG5dhSb ZZ8AUzwUKswVKH+B1ukewcNFBwBzVQMAqaHxgDtYP3TFEWNjbOfng7rvg NKYXqI7hSdtxLhcp5vh40Nfhjl/eKvcqz9Hs7H/vYqaEDvfwhVwO9KDbn LKgHpLdvNlglPm5DUyb9uvgj3UpgDENpHdwo1ef07yFosb9R6vcszQJEG sPzJ8+PcUzXq+toz0W+2PBkN117xuFfShyCowHQ5GR/z7vRp7/iQvFffP ZdXTKTDhDzubzP7ZC0kuGUysGXukKPCly7T3/CouR1erwDV5x9o7QtJnV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994338" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994338" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601622" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601622" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:49 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 08/24] selftests/resctrl: Don't use variable argument list for ->setup() Date: Tue, 18 Apr 2023 14:44:50 +0300 Message-Id: <20230418114506.46788-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515859208815693?= X-GMAIL-MSGID: =?utf-8?q?1763515859208815693?= struct resctrl_val_param has ->setup() function that accepts variable argument list. All test cases use only 1 argument as input and it's the struct resctrl_val_param pointer. Instead of variable argument list, directly pass struct resctrl_val_param pointer as the only parameter to ->setup(). Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 2 +- tools/testing/selftests/resctrl/cat_test.c | 8 +------- tools/testing/selftests/resctrl/cmt_test.c | 9 +-------- tools/testing/selftests/resctrl/mba_test.c | 8 +------- tools/testing/selftests/resctrl/mbm_test.c | 8 +------- tools/testing/selftests/resctrl/resctrl.h | 3 +-- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 7 files changed, 7 insertions(+), 33 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 8a4fe8693be6..11105ba30eff 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -238,7 +238,7 @@ int cat_val(struct resctrl_val_param *param) /* Test runs until the callback setup() tells the test to stop. */ while (1) { if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { - ret = param->setup(1, param); + ret = param->setup(param); if (ret == END_OF_TESTS) { ret = 0; break; diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 86c62dfd8e78..a998e6397518 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -27,17 +27,11 @@ static unsigned long cache_size; * con_mon grp, mon_grp in resctrl FS. * Run 5 times in order to get average values. */ -static int cat_setup(int num, ...) +static int cat_setup(struct resctrl_val_param *p) { - struct resctrl_val_param *p; char schemata[64]; - va_list param; int ret = 0; - va_start(param, num); - p = va_arg(param, struct resctrl_val_param *); - va_end(param); - /* Run NUM_OF_RUNS times */ if (p->num_of_runs >= NUM_OF_RUNS) return END_OF_TESTS; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index d31e28416bb7..2d434c03cbba 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -21,15 +21,8 @@ static char cbm_mask[256]; static unsigned long long_mask; static unsigned long cache_size; -static int cmt_setup(int num, ...) +static int cmt_setup(struct resctrl_val_param *p) { - struct resctrl_val_param *p; - va_list param; - - va_start(param, num); - p = va_arg(param, struct resctrl_val_param *); - va_end(param); - /* Run NUM_OF_RUNS times */ if (p->num_of_runs >= NUM_OF_RUNS) return END_OF_TESTS; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 3d53c6c9b9ce..4d2f145804b8 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -22,18 +22,12 @@ * con_mon grp, mon_grp in resctrl FS. * For each allocation, run 5 times in order to get average values. */ -static int mba_setup(int num, ...) +static int mba_setup(struct resctrl_val_param *p) { static int runs_per_allocation, allocation = 100; - struct resctrl_val_param *p; char allocation_str[64]; - va_list param; int ret; - va_start(param, num); - p = va_arg(param, struct resctrl_val_param *); - va_end(param); - if (runs_per_allocation >= NUM_OF_RUNS) runs_per_allocation = 0; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index ea2ea5721e76..90ee57e5b94b 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -86,16 +86,10 @@ static int check_results(unsigned long span) return ret; } -static int mbm_setup(int num, ...) +static int mbm_setup(struct resctrl_val_param *p) { - struct resctrl_val_param *p; - va_list param; int ret = 0; - va_start(param, num); - p = va_arg(param, struct resctrl_val_param *); - va_end(param); - /* Run NUM_OF_RUNS times */ if (p->num_of_runs >= NUM_OF_RUNS) return END_OF_TESTS; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index fe54c2b4f014..4fd2eaf641e0 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -3,7 +3,6 @@ #ifndef RESCTRL_H #define RESCTRL_H #include -#include #include #include #include @@ -67,7 +66,7 @@ struct resctrl_val_param { char *bw_report; unsigned long mask; int num_of_runs; - int (*setup)(int num, ...); + int (*setup)(struct resctrl_val_param *param); }; #define MBM_STR "mbm" diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index e8f1e6a59f4a..f0f6c5f6e98b 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -759,7 +759,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) /* Test runs until the callback setup() tells the test to stop. */ while (1) { - ret = param->setup(1, param); + ret = param->setup(param); if (ret == END_OF_TESTS) { ret = 0; break; From patchwork Tue Apr 18 11:44:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2793637vqo; Tue, 18 Apr 2023 05:09:13 -0700 (PDT) X-Google-Smtp-Source: AKy350azTZJmDV2XMXXa3tTXPZZKUmeFWUwg2G9Ku0bWUH1GFxCwRH4N6OZ/tvZWaaoIw3KvBBWW X-Received: by 2002:a17:903:743:b0:1a6:961e:fd09 with SMTP id kl3-20020a170903074300b001a6961efd09mr1659504plb.14.1681819753604; Tue, 18 Apr 2023 05:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819753; cv=none; d=google.com; s=arc-20160816; b=dQcW7xitignpfBTSzchShKchkUGQbyluT3bB7Fb2BM3DFHEirA9tIoJX+C8GRCbg8A gKiWek5rN6wYHzrkcIMvMPCssl1OFiO8h2hZ24F2LMgpbzJzr+ZyWHg3NqIHUGCE2EAO fEAKvy0NOShcnvCcq7+C0gQfop4Jc9vcEzL8L8Eoba8ufm/y3GLIde7eAmgRW4yY3d7x n7gcYfGtm3UWzVSocelDx7FO370HN0OrqK3LJT3GP0RnoTfiuuV5w5YXC/P1qbknoqzs Y8M8cPFiu82lKvNvG5MiHDjz5NhpLSjGfbUGLJpIlrV02JvFgxV63LNdfQ7/nN34q6eR TLEg== 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 :dkim-signature; bh=uaAG5TZWDg2Fo/JGScGm8WLun7e0/cuV9vtg9U2/niI=; b=qOCZuRbZ9p43UZfKrjmngJFNO3rx6G80zu2BYKfIsPfu84+DaIqVIIpsmUjH+p712p AHBzNR1n8Fsw+U/aX42c+UGpnVe0v9Sq43wsRoi5hdNrN6zs02a4wJ/N+uZxbhZkeiLB Q9GEuwZ3AkV29LqMiFNIkNhs7fpWyfeJG/FBPGn081QWGB7pgDsXaxyi2wdpEgP/WYW2 4RDReRfvyQidoSkzjxv9dm9McJU0odwfGJ0cLCDzL0NXuAXisUb1WaxoH7pyEXEoVzfr 4vaFSyfAqDYH24QFpY5+rNZ7ciTlSDekj/WvttyI9DIjdIXEp1uGIF07BbWiAuzK4an4 GmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lMOLZCZP; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l72-20020a63914b000000b00513f9dbbdb9si9688226pge.275.2023.04.18.05.08.58; Tue, 18 Apr 2023 05:09:13 -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=@intel.com header.s=Intel header.b=lMOLZCZP; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbjDRLqi (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbjDRLq3 (ORCPT ); Tue, 18 Apr 2023 07:46:29 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178A29747; Tue, 18 Apr 2023 04:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818361; x=1713354361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XHJ2GUd5k0MdI2CtmQnbJhZrefndWCwGDZ1J6X0FNXE=; b=lMOLZCZPbE7v5TiIBTfBrvQhHWBdMToUY9WqGHnBKEifie3BrWeJOmbI KpjqmOqbN43zF3EDwi3ehtrBh4sOfslOIyAFZXNN7DJlBuXYC9LYBRsOY SeR6YYucazJdbPhJUhQzx9FtsYtwpWEQ7Qesj1ulLyo7Ecq3rjyiEweMP 9YUMMDf60mCrv6lhWoZwmv/LpsLgXO7V8SosbhvQhEIEyckvKAufPDvae qW+wAKE0t3Rc7P1BRjNzq5mWaSYVisxSrOiqubpVarX+aGS14dL8o6IyP dMjnQR3PzNC0ZQqMDVrdK6eTKd0ROZYEgNpJGnwMkRpuJgpg2xGwjN3YJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994346" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994346" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601636" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601636" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:52 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 09/24] selftests/resctrl: Remove "malloc_and_init_memory" param from run_fill_buf() Date: Tue, 18 Apr 2023 14:44:51 +0300 Message-Id: <20230418114506.46788-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515830122785590?= X-GMAIL-MSGID: =?utf-8?q?1763515830122785590?= run_fill_buf()'s malloc_and_init_memory parameter is always 1. There's also duplicated memory init code for malloc_and_init_memory == 0 case in fill_buf() which is unused. Remove the malloc_and_init_memory parameter and the duplicated mem init code. While at it, fix also a typo in run_fill_buf() prototype's argument. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 6 ++--- tools/testing/selftests/resctrl/fill_buf.c | 27 +++---------------- tools/testing/selftests/resctrl/resctrl.h | 3 +-- .../testing/selftests/resctrl/resctrl_tests.c | 13 +++++---- tools/testing/selftests/resctrl/resctrlfs.c | 12 ++++----- 5 files changed, 19 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 11105ba30eff..ed5ec8a78c30 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -212,7 +212,7 @@ int measure_cache_vals(struct resctrl_val_param *param, int bm_pid) */ int cat_val(struct resctrl_val_param *param) { - int malloc_and_init_memory = 1, memflush = 1, operation = 0, ret = 0; + int memflush = 1, operation = 0, ret = 0; char *resctrl_val = param->resctrl_val; pid_t bm_pid; @@ -249,8 +249,8 @@ int cat_val(struct resctrl_val_param *param) if (ret) break; - if (run_fill_buf(param->span, malloc_and_init_memory, - memflush, operation, resctrl_val)) { + if (run_fill_buf(param->span, memflush, operation, + resctrl_val)) { fprintf(stderr, "Error-running fill buffer\n"); ret = -1; break; diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 341cc93ca84c..5cdb421a2f6c 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -139,35 +139,18 @@ static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr, } static int -fill_cache(unsigned long long buf_size, int malloc_and_init, int memflush, - int op, char *resctrl_val) +fill_cache(unsigned long long buf_size, int memflush, int op, char *resctrl_val) { unsigned char *start_ptr, *end_ptr; - unsigned long long i; int ret; - if (malloc_and_init) - start_ptr = malloc_and_init_memory(buf_size); - else - start_ptr = malloc(buf_size); - + start_ptr = malloc_and_init_memory(buf_size); if (!start_ptr) return -1; startptr = start_ptr; end_ptr = start_ptr + buf_size; - /* - * It's better to touch the memory once to avoid any compiler - * optimizations - */ - if (!malloc_and_init) { - for (i = 0; i < buf_size; i++) - *start_ptr++ = (unsigned char)rand(); - } - - start_ptr = startptr; - /* Flush the memory before using to avoid "cache hot pages" effect */ if (memflush) mem_flush(start_ptr, buf_size); @@ -187,14 +170,12 @@ fill_cache(unsigned long long buf_size, int malloc_and_init, int memflush, return 0; } -int run_fill_buf(unsigned long span, int malloc_and_init_memory, - int memflush, int op, char *resctrl_val) +int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val) { unsigned long long cache_size = span; int ret; - ret = fill_cache(cache_size, malloc_and_init_memory, memflush, op, - resctrl_val); + ret = fill_cache(cache_size, memflush, op, resctrl_val); if (ret) { printf("\n Error in fill cache\n"); return -1; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4fd2eaf641e0..574adac8932d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -95,8 +95,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); -int run_fill_buf(unsigned long span, int malloc_and_init_memory, int memflush, - int op, char *resctrl_va); +int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); int mbm_bw_change(unsigned long span, int cpu_no, char *bw_report, char **benchmark_cmd); void tests_cleanup(void); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 3c8ec68eb507..ef2977b5ecd4 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -89,7 +89,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, unsigned long span, } if (!has_ben) - sprintf(benchmark_cmd[5], "%s", MBA_STR); + sprintf(benchmark_cmd[4], "%s", MBA_STR); res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBM: bw change\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -142,7 +142,7 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) } if (!has_ben) - sprintf(benchmark_cmd[5], "%s", CMT_STR); + sprintf(benchmark_cmd[4], "%s", CMT_STR); res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); ksft_test_result(!res, "CMT: test\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -269,16 +269,15 @@ int main(int argc, char **argv) benchmark_cmd[ben_count] = NULL; } else { /* If no benchmark is given by "-b" argument, use fill_buf. */ - for (i = 0; i < 6; i++) + for (i = 0; i < 5; i++) benchmark_cmd[i] = benchmark_cmd_area[i]; strcpy(benchmark_cmd[0], "fill_buf"); sprintf(benchmark_cmd[1], "%lu", span); strcpy(benchmark_cmd[2], "1"); - strcpy(benchmark_cmd[3], "1"); - strcpy(benchmark_cmd[4], "0"); - strcpy(benchmark_cmd[5], ""); - benchmark_cmd[6] = NULL; + strcpy(benchmark_cmd[3], "0"); + strcpy(benchmark_cmd[4], ""); + benchmark_cmd[5] = NULL; } sprintf(bw_report, "reads"); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 09e0a69c81c4..79e030065da8 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -295,7 +295,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no) */ void run_benchmark(int signum, siginfo_t *info, void *ucontext) { - int operation, ret, malloc_and_init_memory, memflush; + int operation, ret, memflush; unsigned long span; char **benchmark_cmd; char resctrl_val[64]; @@ -314,13 +314,11 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) if (strcmp(benchmark_cmd[0], "fill_buf") == 0) { /* Execute default fill_buf benchmark */ span = strtoul(benchmark_cmd[1], NULL, 10); - malloc_and_init_memory = atoi(benchmark_cmd[2]); - memflush = atoi(benchmark_cmd[3]); - operation = atoi(benchmark_cmd[4]); - sprintf(resctrl_val, "%s", benchmark_cmd[5]); + memflush = atoi(benchmark_cmd[2]); + operation = atoi(benchmark_cmd[3]); + sprintf(resctrl_val, "%s", benchmark_cmd[4]); - if (run_fill_buf(span, malloc_and_init_memory, memflush, - operation, resctrl_val)) + if (run_fill_buf(span, memflush, operation, resctrl_val)) fprintf(stderr, "Error in running fill buffer\n"); } else { /* Execute specified benchmark */ From patchwork Tue Apr 18 11:44:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2794642vqo; Tue, 18 Apr 2023 05:10:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bkF0HSncl1ugi6P1OX/WJC7KiURpHmez9xyIX7iQsyHgspnHtHDP5CE4PsL2OZ40F3BZ1L X-Received: by 2002:a17:90a:f3cf:b0:234:7ccf:3c7c with SMTP id ha15-20020a17090af3cf00b002347ccf3c7cmr2120800pjb.9.1681819835859; Tue, 18 Apr 2023 05:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819835; cv=none; d=google.com; s=arc-20160816; b=wL9fZeUXi4wz+MyJugT6vcooaoPbIWHRGJhFKXp4FM5Me9hXFr+TKctqqAMwtywxhO HW7W5O6wG67NSkLDOGRdBvKe38UPuI6AFYUipgmxXNzD+pZGHtAFslItz1p4fc80VgJO w0jsETnxIIuZvDI2sr+LrPKheejlGmXOnFcaH8MkHf2XepR9oK9priR2Ih+e5cOJWSQH IAzpGGsCIXfFzMAnzaXR+UY0sVoxK11VU8+VUiXg99AeQR24wlS6dK+td4uirGULG3j6 4HmnANpldWRppCBSE6dEC+Q9Txv8rcz5KeS2BHdw9c6ou+Qqb1F2b0LfWUOMBvgWamvW wxiA== 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 :dkim-signature; bh=x6P3aDbAWcG5VoHayeHDgCJLvOH94KuzPkx1pFZKV5c=; b=CBHVyepKaV4mIsVLKZoMmg3f0V0j5PTOvL3hRSPl7d5lmTmYluV2ZW2Y3hszv58JbZ lZw1Yu5TIu2Ijk+lIK3sJWopbq+OoGdOgyDIZmcRtolKGJSYMFupYKwMwZZBqEZ3VJV+ vCD5EZ1hQuUD1eW/LyPjMBhcDHGttwVG06G2XqBBatOsL96CODsKpwHI0tz5LsyNd6/s cqDCSfZpRiMEnKNTZC93R51laW6csbAaVYd+1GviCJYuFz0o+lTJGA70RY/6X+1s2OqI RHHRY2upluGADHK++iGPHUuKAVrn70blANsLHIkKkhZFQzzQryNwjCJ12Mgy6b4I5GCz +Ncg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FYhv2eg1; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h5-20020a654685000000b0050726756edesi13940746pgr.76.2023.04.18.05.10.21; Tue, 18 Apr 2023 05:10:35 -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=@intel.com header.s=Intel header.b=FYhv2eg1; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbjDRLqv (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjDRLqk (ORCPT ); Tue, 18 Apr 2023 07:46:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F45E78; Tue, 18 Apr 2023 04:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818369; x=1713354369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UXzBCe+HMFj+CW/PyVKY25ygKi4rEwQRoqZga+3wvGs=; b=FYhv2eg1X7PqtkCadNzc5jdInvhS6rCVmuTzBVq6Q9Smh8gbdK0BzHEH YOsY1hKeyoOGAYi3B8LqWLEsVX2PXU13ZUOchVqlgYVSsibSa+XhQjDfa 6BTK0t8cgDfNgqftqbubh2jJps02X7MJ1IKuhqtnPGK2afqX1x1yRCHy1 7fYjpXtl8KVzkTo5uoC6ORjgbDZHzvbbRNv2SR34bv3tu6lzR4oftbZK+ 2qNcKdMhYBjMsHLrvoUqRB5GHwGcn9Obq2jhE8GbWOqqhpxvGuva0HXAu Lx+SeFOff7XGdPJGL9MO+DUoU4OBRdO8/49jEGCp1qpLq/0TAMoK1Goxc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994352" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994352" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601648" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601648" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:55 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 10/24] selftests/resctrl: Split run_fill_buf() to alloc, work, and dealloc helpers Date: Tue, 18 Apr 2023 14:44:52 +0300 Message-Id: <20230418114506.46788-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515916123658572?= X-GMAIL-MSGID: =?utf-8?q?1763515916123658572?= MBM, MBA and CMT test cases use run_fill_buf() to loop indefinitely loop around the buffer. CAT test case is different and doesn't want to loop around the buffer continuously. Split run_fill_buf() into helpers so that both the use cases are easier to control by creating separate functions for buffer allocation, looping around the buffer and the deallocation. Make those functions available for tests. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/fill_buf.c | 46 ++++++++++++++++------ tools/testing/selftests/resctrl/resctrl.h | 3 ++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 5cdb421a2f6c..6f0438aa71a6 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -24,6 +24,11 @@ static unsigned char *startptr; +void free_buffer(void) +{ + free(startptr); +} + static void sb(void) { #if defined(__i386) || defined(__x86_64) @@ -138,36 +143,53 @@ static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr, return 0; } -static int -fill_cache(unsigned long long buf_size, int memflush, int op, char *resctrl_val) +int alloc_buffer(unsigned long long buf_size, int memflush) { - unsigned char *start_ptr, *end_ptr; - int ret; + unsigned char *start_ptr; start_ptr = malloc_and_init_memory(buf_size); if (!start_ptr) return -1; startptr = start_ptr; - end_ptr = start_ptr + buf_size; /* Flush the memory before using to avoid "cache hot pages" effect */ if (memflush) mem_flush(start_ptr, buf_size); + return 0; +} + +int use_buffer(unsigned long long buf_size, int op, char *resctrl_val) +{ + unsigned char *end_ptr; + int ret; + + end_ptr = startptr + buf_size; if (op == 0) - ret = fill_cache_read(start_ptr, end_ptr, resctrl_val); + ret = fill_cache_read(startptr, end_ptr, resctrl_val); else - ret = fill_cache_write(start_ptr, end_ptr, resctrl_val); + ret = fill_cache_write(startptr, end_ptr, resctrl_val); - if (ret) { + if (ret) printf("\n Error in fill cache read/write...\n"); - return -1; - } - free(startptr); + return ret; +} - return 0; +static int +fill_cache(unsigned long long buf_size, int memflush, int op, char *resctrl_val) +{ + int ret; + + ret = alloc_buffer(buf_size, memflush); + if (ret) + return ret; + + ret = use_buffer(buf_size, op, resctrl_val); + free_buffer(); + + return ret; } int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 574adac8932d..75bfa2b2746d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -95,6 +95,9 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); +void free_buffer(void); +int alloc_buffer(unsigned long long buf_size, int memflush); +int use_buffer(unsigned long long buf_size, int op, char *resctrl_val); int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); int mbm_bw_change(unsigned long span, int cpu_no, char *bw_report, char **benchmark_cmd); From patchwork Tue Apr 18 11:44:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781019vqo; Tue, 18 Apr 2023 04:49:49 -0700 (PDT) X-Google-Smtp-Source: AKy350YWeTTFizIxIuaGMKvSgf1iT89p9ucKnsM+H4td/fu93xMJIvA5GbLRxNhordcwpmEpvvc+ X-Received: by 2002:a17:90a:9283:b0:247:1418:ad28 with SMTP id n3-20020a17090a928300b002471418ad28mr1762922pjo.22.1681818588801; Tue, 18 Apr 2023 04:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818588; cv=none; d=google.com; s=arc-20160816; b=H2nub80JTDraBicdXmXSpxaTGAP3evPT6CHQou6e9ifsN/yElgynn8DQWS2X2tsShy t1SdrHUJxBoDbor1lgfwU/R0BQaS0PURH03TfCooJURvCaZIUWIkuhyIevPrMtkNGUhp yk32upiVG08k3vGhnSLjevgzKoON0ptDZSWXGZ9PLpTs0tn0A94XjeEe6o531MJ5oACU rAdT52PL89Cx2jzLiu5gfivmvMjr+WGPxCEHeaDvQkQKtOm6py5O/EEOYJ6RIt3UJW0P i+wsl7yufgHFKGwztgvqgz3yt+s2T7Q9fL9HkKA3Esxy078CdwZjsNW+aW3JytlU9osS Qq1Q== 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 :dkim-signature; bh=RSLTsYdws30UteBbth/1B//xD1kTRcauB1Zky+pDJt4=; b=sULLHRxH7cOq8nVGnD7977Q7jDcKTBCMkK5d4/m88qjr2U60EwbkYxIHoxmYkyk/1G S4XNc4nGhD0YW7HdcrAgftrUrxuFylsqqgkAguY1/zXYprSoLTjRT6Fq3G+5F+L66lpU eCW24kMiBDI7mjOmSKPRBmrkKu6/GeMv8l8yrCz4k15t/HxgQxRSdh8mAYygFunRzdl9 F+M5hGrIj4BwL/tNrq5JIV88oSFU8vOn4f6J0gxJMZ+Z4LecO8nGz9P20Pah8JP5+hbq F9b4GC37T7J379DYo6cZ4dmy84bnmKIUWUV8UfBkPOOVYxCpcEuiKo3LarKbfa+AzWPf qQkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="VxW/m9p+"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mj12-20020a17090b368c00b00246799bf0c2si13457168pjb.187.2023.04.18.04.49.36; Tue, 18 Apr 2023 04:49:48 -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=@intel.com header.s=Intel header.b="VxW/m9p+"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230428AbjDRLqx (ORCPT + 99 others); Tue, 18 Apr 2023 07:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbjDRLqq (ORCPT ); Tue, 18 Apr 2023 07:46:46 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D40468E; Tue, 18 Apr 2023 04:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818376; x=1713354376; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DtsmLDO5mFl9wMfAHngLijzuH7IwO+uKW2gw4UdECuo=; b=VxW/m9p+NP/86N3pYXDv0OMFv4/twRcCufFUZo1VbRUU2+HnurFG7NrL Oqi2LEsIMvWJJFVZ1ZyG2ktW6at9KBzwoiDrEkcoQWE8qCAKUnlrws6LX 13KEAPwllDHYYykTe1YhY29YC28qsIU9GmJMsC5FkmmAYIRsuhA5yYXEQ ou6LDVzj+7KDiVxnCHRHGJx3tT14TQLb2X/afcGLfMOHmCiJ7n9Yr3P2W CaAOEZZEJZCTXoDHmt1TqPeMXyhYF5C25SRV3nr8AKevSxlcgiFGvlJcw fDIT4wz7TBu4QW4NbmJkAjnaXWtRoQw/kUUfm4pZi5k/7/PiYEp1NlEfC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994361" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994361" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601661" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601661" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:45:58 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 11/24] selftests/resctrl: Remove start_buf local variable from buffer alloc func Date: Tue, 18 Apr 2023 14:44:53 +0300 Message-Id: <20230418114506.46788-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514608666575512?= X-GMAIL-MSGID: =?utf-8?q?1763514608666575512?= alloc_buffer() has local start_ptr variable which is unnecessary. Assign the pointer of the allocated buffer directly to startptr that is a global variable in fill_buf to simplify the code in alloc_buffer(). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/fill_buf.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 6f0438aa71a6..3a10b554d778 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -145,17 +145,13 @@ static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr, int alloc_buffer(unsigned long long buf_size, int memflush) { - unsigned char *start_ptr; - - start_ptr = malloc_and_init_memory(buf_size); - if (!start_ptr) + startptr = malloc_and_init_memory(buf_size); + if (!startptr) return -1; - startptr = start_ptr; - /* Flush the memory before using to avoid "cache hot pages" effect */ if (memflush) - mem_flush(start_ptr, buf_size); + mem_flush(startptr, buf_size); return 0; } From patchwork Tue Apr 18 11:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781106vqo; Tue, 18 Apr 2023 04:49:59 -0700 (PDT) X-Google-Smtp-Source: AKy350aFDFwkJzO6ReykzIqY/UzU2iDxG0PqlHV/paUMfpLVZC1J+IkEL3gxjjr7jGZ9Jf2dV68+ X-Received: by 2002:a05:6a20:394c:b0:ee:cc76:5023 with SMTP id r12-20020a056a20394c00b000eecc765023mr14733172pzg.22.1681818599045; Tue, 18 Apr 2023 04:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818599; cv=none; d=google.com; s=arc-20160816; b=g2QTvvtvo3wEVxtV1vMevP37LglR+fFg/8f6y9gQnpSxE2s0iG8ewxK7ik674czuzP Wqt6FfxBGD0NV43oRuthf+daMwcBvwodujlQmKOEo85Cpes2OCnL283DYj7OjhXpw/DO ZbdGLxMJb+VBOQMjE6cSt1u40mbsIn+4CcJvYOsd7NqejwDACl3Jp6pg1sRfeMU0aaXs +qBtzvMaW8miBZDWoxvUMqSp8kQy+77buiqqyWl6F9k9kJHpgpnTRBQIHxdybnOm6hk6 +PMTqmbeLjZcIe2WSnMk2avoQAeDc5XXZCSHa2mrkdoDO+RHbBwqCoGaiQuLS+3/0Gy5 xmKQ== 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 :dkim-signature; bh=1X93w/VsTKjSeSfJIZo+79lH+pObXRaOm6eCDJ/rjb4=; b=m53FYJZ4t62E/ViyjTvyzdbFPNjkR2cvgDMWEwDxg8/Eefkn6/iWYiYMjsGCtZZsdJ vDaGgP7neJEm4Ru9TJO3HOenPIkEj/Xo4lRxjdRyYrvtI2bJhbL78PyYm2Is6ZPB7AEe aGyExJurPox0Sbt1znbX8uIka8oAHCYLzeBjOHyrrCe/whupO+pH3mXgxDsafOgaFElC NGrwFEntVK0GDRkRo15uHtbSbmVVJ3oJeQ5oBDJ9QfgxN12L1HuyZQxtEq1ZC3G8XSB2 bFKfHOxVHQ5H5x1KH4P5Va8IZh8XZiSATxg8EwpqznhZ+FVXLUfIzif5+caLgIRHGxYx vrXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q7nGJCAg; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c131-20020a621c89000000b005a8b856ad47si13191066pfc.7.2023.04.18.04.49.46; Tue, 18 Apr 2023 04:49:59 -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=@intel.com header.s=Intel header.b=Q7nGJCAg; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231352AbjDRLrG (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbjDRLrC (ORCPT ); Tue, 18 Apr 2023 07:47:02 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562EFAF0D; Tue, 18 Apr 2023 04:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818389; x=1713354389; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2cJvkLl7uJW3RSLVTBlhZ4q2eZfLppbJ88qjoc9yDa0=; b=Q7nGJCAgfkHihVbT/A7NtW5YJMlBa50WI7X9dtDsYYXSUQL0uywAbKRm WyOA1S0YSEoWci1oLwMc9Fll/7NgDWV2qARISGCUDjMjGg8T5YWFqiaOO l3FaHUynWlzxr7h1bMv+RXeqvCOr8JNO1/cEu4Wt/siinhh0p800xNcaN hZDyMfDXSRpOKdxFkJSyI35degQRmQHcfersQMfY9GQPXZ+iFaimDc+6D A29YxQnsp9sDQxinDHSsg2T9qU7Ahfc2fh8ZdWmuM0grCzxdOkm8ktxzu Adhf7XTFpee9D5eNYkuCEgolyxOu6SXb0ZVD6VHdNm6yWxxNbPexPMtKV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994375" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994375" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601690" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601690" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:01 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 12/24] selftests/resctrl: Don't pass test name to fill_buf Date: Tue, 18 Apr 2023 14:44:54 +0300 Message-Id: <20230418114506.46788-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514619291152137?= X-GMAIL-MSGID: =?utf-8?q?1763514619291152137?= Test name is passed to fill_buf functions so that they can loop around buffer only once. This is required for CAT test case. To loop around buffer only once, we don't need to let fill_buf know which test case it is. Instead, use a boolean argument 'once' which makes fill_buf more generic. As the benchmark_cmd no longer needs to include the test name, a few test running functions can be simplified to not write the test name into the default benchmark_cmd which allows dropping has_ben argument from the functions too. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 3 +-- tools/testing/selftests/resctrl/fill_buf.c | 22 +++++++++---------- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- .../testing/selftests/resctrl/resctrl_tests.c | 14 +++++------- tools/testing/selftests/resctrl/resctrlfs.c | 11 +++++++--- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index ed5ec8a78c30..a15f1f2715cd 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -249,8 +249,7 @@ int cat_val(struct resctrl_val_param *param) if (ret) break; - if (run_fill_buf(param->span, memflush, operation, - resctrl_val)) { + if (run_fill_buf(param->span, memflush, operation, true)) { fprintf(stderr, "Error-running fill buffer\n"); ret = -1; break; diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 3a10b554d778..677e1a113629 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -108,14 +108,14 @@ void fill_one_span_write(unsigned char *start_ptr, unsigned char *end_ptr) } static int fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr, - char *resctrl_val) + bool once) { int ret = 0; FILE *fp; while (1) { ret = fill_one_span_read(start_ptr, end_ptr); - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) + if (once) break; } @@ -132,11 +132,11 @@ static int fill_cache_read(unsigned char *start_ptr, unsigned char *end_ptr, } static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr, - char *resctrl_val) + bool once) { while (1) { fill_one_span_write(start_ptr, end_ptr); - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) + if (once) break; } @@ -156,16 +156,16 @@ int alloc_buffer(unsigned long long buf_size, int memflush) return 0; } -int use_buffer(unsigned long long buf_size, int op, char *resctrl_val) +int use_buffer(unsigned long long buf_size, int op, bool once) { unsigned char *end_ptr; int ret; end_ptr = startptr + buf_size; if (op == 0) - ret = fill_cache_read(startptr, end_ptr, resctrl_val); + ret = fill_cache_read(startptr, end_ptr, once); else - ret = fill_cache_write(startptr, end_ptr, resctrl_val); + ret = fill_cache_write(startptr, end_ptr, once); if (ret) printf("\n Error in fill cache read/write...\n"); @@ -174,7 +174,7 @@ int use_buffer(unsigned long long buf_size, int op, char *resctrl_val) } static int -fill_cache(unsigned long long buf_size, int memflush, int op, char *resctrl_val) +fill_cache(unsigned long long buf_size, int memflush, int op, bool once) { int ret; @@ -182,18 +182,18 @@ fill_cache(unsigned long long buf_size, int memflush, int op, char *resctrl_val) if (ret) return ret; - ret = use_buffer(buf_size, op, resctrl_val); + ret = use_buffer(buf_size, op, once); free_buffer(); return ret; } -int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val) +int run_fill_buf(unsigned long span, int memflush, int op, bool once) { unsigned long long cache_size = span; int ret; - ret = fill_cache(cache_size, memflush, op, resctrl_val); + ret = fill_cache(cache_size, memflush, op, once); if (ret) { printf("\n Error in fill cache\n"); return -1; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 75bfa2b2746d..8748121345f3 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -97,8 +97,8 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); void free_buffer(void); int alloc_buffer(unsigned long long buf_size, int memflush); -int use_buffer(unsigned long long buf_size, int op, char *resctrl_val); -int run_fill_buf(unsigned long span, int memflush, int op, char *resctrl_val); +int use_buffer(unsigned long long buf_size, int op, bool once); +int run_fill_buf(unsigned long span, int memflush, int op, bool once); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); int mbm_bw_change(unsigned long span, int cpu_no, char *bw_report, char **benchmark_cmd); void tests_cleanup(void); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index ef2977b5ecd4..6e710989f368 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -70,7 +70,7 @@ void tests_cleanup(void) cat_test_cleanup(); } -static void run_mbm_test(bool has_ben, char **benchmark_cmd, unsigned long span, +static void run_mbm_test(char **benchmark_cmd, unsigned long span, int cpu_no, char *bw_report) { int res; @@ -88,8 +88,6 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, unsigned long span, goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[4], "%s", MBA_STR); res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBM: bw change\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -124,7 +122,7 @@ static void run_mba_test(char **benchmark_cmd, unsigned long span, int cpu_no, umount_resctrlfs(); } -static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) +static void run_cmt_test(char **benchmark_cmd, int cpu_no) { int res; @@ -141,8 +139,6 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[4], "%s", CMT_STR); res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); ksft_test_result(!res, "CMT: test\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -276,7 +272,7 @@ int main(int argc, char **argv) sprintf(benchmark_cmd[1], "%lu", span); strcpy(benchmark_cmd[2], "1"); strcpy(benchmark_cmd[3], "0"); - strcpy(benchmark_cmd[4], ""); + strcpy(benchmark_cmd[4], "false"); benchmark_cmd[5] = NULL; } @@ -291,13 +287,13 @@ int main(int argc, char **argv) ksft_set_plan(tests ? : 4); if (mbm_test) - run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); + run_mbm_test(benchmark_cmd, span, cpu_no, bw_report); if (mba_test) run_mba_test(benchmark_cmd, span, cpu_no, bw_report); if (cmt_test) - run_cmt_test(has_ben, benchmark_cmd, cpu_no); + run_cmt_test(benchmark_cmd, cpu_no); if (cat_test) run_cat_test(cpu_no, no_of_bits); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 79e030065da8..7fef9068d7fd 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -298,7 +298,7 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) int operation, ret, memflush; unsigned long span; char **benchmark_cmd; - char resctrl_val[64]; + bool once; FILE *fp; benchmark_cmd = info->si_ptr; @@ -316,9 +316,14 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) span = strtoul(benchmark_cmd[1], NULL, 10); memflush = atoi(benchmark_cmd[2]); operation = atoi(benchmark_cmd[3]); - sprintf(resctrl_val, "%s", benchmark_cmd[4]); + if (!strcmp(benchmark_cmd[4], "true")) + once = true; + else if (!strcmp(benchmark_cmd[4], "false")) + once = false; + else + PARENT_EXIT("Invalid once parameter"); - if (run_fill_buf(span, memflush, operation, resctrl_val)) + if (run_fill_buf(span, memflush, operation, once)) fprintf(stderr, "Error in running fill buffer\n"); } else { /* Execute specified benchmark */ From patchwork Tue Apr 18 11:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2795221vqo; Tue, 18 Apr 2023 05:11:19 -0700 (PDT) X-Google-Smtp-Source: AKy350YfU/a0sH+dlLyQvwiOUlNgNf5giKkdKVT0oZM1ZdrXycNSeLd67I0/FJ0wmxnmY4DY29Xt X-Received: by 2002:a17:902:ecc4:b0:1a6:c366:1603 with SMTP id a4-20020a170902ecc400b001a6c3661603mr2169257plh.19.1681819879386; Tue, 18 Apr 2023 05:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819879; cv=none; d=google.com; s=arc-20160816; b=OHw/lP+D7YNPG0OX2cJnxlCHCwGZkHzE1xU5ldY7msYMH9UslHqEy3xFkm89U9htYt XS5nxTdOvVRY1bxnDKw3dtvy+VkE9ON0WtBiNLaet74M0Kt9+xIWhaz+ru0Ounch6SP7 696LrLg8+7br145oIdsVS+ebWK3GbYBatsF3up27T/cqrBDcmy2Je+UcHAdm6b0pF6kC n9ULhAqKydoXQaFUVYONrhIako7WS2nQVfV0wyseUqQNh7M4rfVUxAZChWXH2vBM00+Q tb2W6jQqfTqVtmonnHGZj/ME3PnaiP193Y1WEjafws6y+FDbx3mGzIJA6fN+NtYCH3P9 Tq9w== 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 :dkim-signature; bh=QKqQX6Dgfm4mjVAEws17fl8wz+B6+EfeYTSByy9yB9E=; b=IBa6F4QKt9cYbItrjYhGqZbdUjnl7CT28bdwwg8L7/t3tZln83s4BNCajnBLo+Tzx/ MfSnDQKY0PuWnGc+eDSh3ERkjolCrHXzgoZzg0N1IakPpzPQnz6OfQwcVfMqlzCatdRp Cy75I0hI3+y5vKctgJWyLGk2a6jnyxBHmCtFxU6rA9fOtGUy0LKE4jgUOl17pUSPHZg+ I5KC05hdwLJKH7KaR5+f0lGKsftX+Qe3167yuxGnwHB7+oQQwgCgkbNmnWK8TMyHgl7j qERVIJX2xOlULTayANU1qqkugvnmu2ryaTnpIJEcu+GhMkb9MYx1Pse2hHftKcKR/xd5 Rngw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=licig384; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a170902f68600b001a66c369e0fsi13951381plg.510.2023.04.18.05.11.00; Tue, 18 Apr 2023 05:11:19 -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=@intel.com header.s=Intel header.b=licig384; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbjDRLrT (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbjDRLrN (ORCPT ); Tue, 18 Apr 2023 07:47:13 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30129023; Tue, 18 Apr 2023 04:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818400; x=1713354400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R9lx3mKsxWCICNzKODU56YjOQHjE2EbrIY9NXu/7ouA=; b=licig3845S1bzRzEzqCsqYnz2iu+UkIYKxS6nuQhgdGIdfsmN1sJto5G I8CzAQtLo1TgPytGMcmk6p9Nous6AOyTi/3ileVkDzoV1HXS3NUVRV2h0 4eKBAH3h8HARGhd/t9OME38mFr3p34zArEa8QjiEyDVTQkZwrH5q/SxZI s5l5YpGPBmPDNYc4JjadLvS/lREyH0Giu/JuyMs/kPQLzqrP4KLVsSfpC 97qLDw2hC45TXMvuM2cbmBmDVUZKxxm/acivgWM7CjyrvQIoHLyXXNc6v NqsAvB70qyjQ+KrJ/gBNgziFH1aeG2OgshzqGUplvVQBetg9QDHNoMeM2 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994387" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994387" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601705" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601705" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:04 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 13/24] selftests/resctrl: Add flush_buffer() to fill_buf Date: Tue, 18 Apr 2023 14:44:55 +0300 Message-Id: <20230418114506.46788-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515961691206481?= X-GMAIL-MSGID: =?utf-8?q?1763515961691206481?= Currently, flushing is only done after allocating and filling the buffer and cannot be controlled by the test cases. The new CAT test will want to control flushing within a test so introduce flush_buffer() for that purpose. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/fill_buf.c | 5 +++++ tools/testing/selftests/resctrl/resctrl.h | 1 + 2 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 677e1a113629..7e0d3a1ea555 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -58,6 +58,11 @@ static void mem_flush(void *p, size_t s) sb(); } +void flush_buffer(unsigned long long span) +{ + mem_flush(startptr, span); +} + static void *malloc_and_init_memory(size_t s) { void *p = NULL; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 8748121345f3..ba36eb5fdf0d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -97,6 +97,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); void free_buffer(void); int alloc_buffer(unsigned long long buf_size, int memflush); +void flush_buffer(unsigned long long span); int use_buffer(unsigned long long buf_size, int op, bool once); int run_fill_buf(unsigned long span, int memflush, int op, bool once); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); From patchwork Tue Apr 18 11:44:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781599vqo; Tue, 18 Apr 2023 04:50:52 -0700 (PDT) X-Google-Smtp-Source: AKy350bQgsqDc6c+/a5HOqT4xZbC/PPVxOCj+XZM1Yb7Achbpi/Zcd7mj6vd1i7Lsk3Dh9CG4bPR X-Received: by 2002:a05:6a20:12c6:b0:ef:f558:b80 with SMTP id v6-20020a056a2012c600b000eff5580b80mr6855431pzg.58.1681818652397; Tue, 18 Apr 2023 04:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818652; cv=none; d=google.com; s=arc-20160816; b=EvHYB/9t7n0EkmPW2dRVTeQlvMebptE1lc2I/ewvFBvweVwXQzyMYGeAVsL7/s/jK0 TePyDVx7ZGt8yGYzlqCkzWLYQzFQcegCtNbUDhcHiyNFEO5O86eFTCv/GcaDeLnAmAqc 53mtigyCMwfp6SHBM5ZmpXULw/wnBZjTo3Up6ZgdFhhmc1wLtV+Nh9o1kWBfkUJXFdDS +wMpO5gqfwdaPzXBzNZt00LhtXNmYv4Ru1GIV+f2BgojUQuQm9YuV59cxOWIiaEZkOtw PagThrj0z2tFyPCNZGF8LLk4lWjskX6sRf5DHqNCwCO9XOtQUWggp8M5jWFdkCX9F5K7 jx9g== 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 :dkim-signature; bh=DTq17vKTdm6RTlzlLD7l6kwwBHXrfgEgVCiKataYfDA=; b=sSzZ2nFVG2oxioo6fKUISKxmbWsMR7OVZy4hr/WsmYsr25EbiucqWsDvX8cKGAem0m QKKB4fj9fK2nuhhOIBvVRjZF3XFZOBKfGKTD6zz63i6vS5NwNR9Ob903RCI77oradOtG wuBeJfMAaVsOzHLi/0I8uKLeoSWkSgXm3TuJGZ4dzSPFKUMjtVT2fW12QeUa1C08dPgt 88W9lE+1TbIrzfK5yzO3BCtWg8k5JW+PNpF25MDY/wmWenaMbw0+eOgKjOYnc6N0g3UJ 4Ys2jIoNWqMfp4athittpZnbDzNX8LfLyfYooF4SakQ5KquBqtKt7tIYpEst3uLnko9/ MwTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="j6LDF3/l"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b0051f3c811e2csi1499070pge.98.2023.04.18.04.50.39; Tue, 18 Apr 2023 04:50:52 -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=@intel.com header.s=Intel header.b="j6LDF3/l"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbjDRLrW (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjDRLrP (ORCPT ); Tue, 18 Apr 2023 07:47:15 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B18E7ED1; Tue, 18 Apr 2023 04:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818406; x=1713354406; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fToQ+8SOAxiSfN3ZiH5XH4bjEW4BAV3bTtI/uobe8NE=; b=j6LDF3/lxwCsDZDJMVM5xBj3gKcschUKrdQ+/p78Wr8uSYwyEqbbQn3M 4o8ex6VCEI7LYbGiST5hvsiiJcdZsccCiFCB/wzkmks/Z3/G5l4psXDUy 2WUZsfC18ZIha4s/8Ut9oXaRtOAfOry4WuPFr8KtHO4wMjgx3DLW8neMs uA1TfhDq9HZ2/KGr8zwDr8QnNKRh0BLJ2Uh76XiTEF4ThnZ+py2WXtkZQ kcW4BzOjc9KEVcIWH1S1+XM6HecYYBjmu7scORdnaHLVbEnxghKAEcKlm Fsr0KN02WVkCE92I9clHv1ZrM6dOyeDggXd6xKRsHKjS1u3MXL3Q6kLNa Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994396" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994396" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601712" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601712" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:07 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 14/24] selftests/resctrl: Remove test type checks from cat_val() Date: Tue, 18 Apr 2023 14:44:56 +0300 Message-Id: <20230418114506.46788-15-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514675458254136?= X-GMAIL-MSGID: =?utf-8?q?1763514675458254136?= cat_val() is only used during CAT test but it checks for test type. Remove test type checks and the unused else branch from cat_val(). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 45 +++++++++++-------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index a15f1f2715cd..6bc912de38be 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -232,36 +232,31 @@ int cat_val(struct resctrl_val_param *param) if (ret) return ret; - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) - initialize_llc_perf(); + initialize_llc_perf(); /* Test runs until the callback setup() tells the test to stop. */ while (1) { - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { - ret = param->setup(param); - if (ret == END_OF_TESTS) { - ret = 0; - break; - } - if (ret < 0) - break; - ret = reset_enable_llc_perf(bm_pid, param->cpu_no); - if (ret) - break; - - if (run_fill_buf(param->span, memflush, operation, true)) { - fprintf(stderr, "Error-running fill buffer\n"); - ret = -1; - break; - } - - sleep(1); - ret = measure_cache_vals(param, bm_pid); - if (ret) - break; - } else { + ret = param->setup(param); + if (ret == END_OF_TESTS) { + ret = 0; break; } + if (ret < 0) + break; + ret = reset_enable_llc_perf(bm_pid, param->cpu_no); + if (ret) + break; + + if (run_fill_buf(param->span, memflush, operation, true)) { + fprintf(stderr, "Error-running fill buffer\n"); + ret = -1; + break; + } + + sleep(1); + ret = measure_cache_vals(param, bm_pid); + if (ret) + break; } return ret; From patchwork Tue Apr 18 11:44:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2795972vqo; Tue, 18 Apr 2023 05:12:24 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2YlKdB3wOeqK4a71aTUNSOxDB129kHq2smvEYQCO5veNSf9eqxvkhv2qSraKq6DovDRa7 X-Received: by 2002:a17:90a:4302:b0:247:3548:e470 with SMTP id q2-20020a17090a430200b002473548e470mr1873564pjg.29.1681819944704; Tue, 18 Apr 2023 05:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819944; cv=none; d=google.com; s=arc-20160816; b=mx8ZEQiyVJ0CtDKHpEN7yhqVu9hISwQ59Dc+sOykg1mXqS4XAPRxg/6fgpIyqVLXeA IVbPb4SKTmJ59EPJTfjCj79HZLQkvoFUBwBcmC36uDpcqGFTUm8YzArPYuySZIJevalG SiMcnf/yUbBaUOpXSM+ErD1orB/4K1FKUMJm7HNQvU80+gcm3fmWdzxrYIn57L5hY6I4 XV3kiSpVvmhFuhRa6hnnSuo2P7N2a/39wi/EgasWrYnIrU+bYwi4YuBJ6nuZKIRtOwxg rIwO6DtkRqKMsuihubnWQfFU0pQE/yqv3ceW2YnHANiRnMvHf96jVlvHfIbseFT2EWch onQw== 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 :dkim-signature; bh=NX2rhM4smGeR67mb9vSiqQ5/73Wo/rWbOqWekFlZRgQ=; b=vnBd+I9g4yaDW7U7tFzgXJkab9xX4fD5/XUNhogqMgIZlzjtbOKc6Lef+DalWVW5Pf FASSvZtgQiEl5OgNwt4SCGe8vJxyLJJY4nrmTRuAnwXaZmm6edRXg2Z7FTTAcbpXlcak jH5kS7bsRhmS9mjoziiJ8/YwMTCBj2ytV9kL2wcT3aKdZ6BEwaaMH8D1AhBK2bbEwCVp Ey5O7XgfUjY6mO6VKbRaxBLXpK/Eh6++3ZGcgLISECKPY/k6F6+oxojsiARK/hNyY6wT 7u6SMsyZVB632hpmYsLdcrU4l3ubw3W1HEbKgCl4fjgkKYyXMzgHMYVIVO7QxuETVY4e O2LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vg478K9A; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a1709027b9200b001a6d4eab490si4980128pll.63.2023.04.18.05.12.09; Tue, 18 Apr 2023 05:12:24 -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=@intel.com header.s=Intel header.b=Vg478K9A; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbjDRLre (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231415AbjDRLra (ORCPT ); Tue, 18 Apr 2023 07:47:30 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2C79031; Tue, 18 Apr 2023 04:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818422; x=1713354422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M3QYJlujzdfz5vfq0+dLmr81y7Nf7gohRl1ZFTz21cI=; b=Vg478K9AKuNAJ41zmaZhEEOEy53oZPw526haAn5d3nZ/MrYhHXJlJrKs MTnFYt5oUNtlcKhWObcgCQrlf2QkFO5EB4XbziNwb8dO/N8pXLf6CHNWR Fp1zDeYardnnpYLfdO2csI6nDakBidyC1kCSuNtek+0V47is0Tfqlc/Gp fjrCT8/0AtiUzXW6j43GwglXAgbHaCdACyjPxZsvcLUFJfBWPCYmFHcgI RVoX2Sr44nM2RRawCh+lJkMb1ZC9WpUJ8mo/cV6JJMsGb46bvtAPi48j+ p1mqlpbuOL43cMw2yg6QX+aEbLLDleMPo+NC4Bfwk+53HYGYcAJ72pS9z Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994410" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994410" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601722" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601722" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:10 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 15/24] selftests/resctrl: Refactor get_cbm_mask() Date: Tue, 18 Apr 2023 14:44:57 +0300 Message-Id: <20230418114506.46788-16-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763516030090847839?= X-GMAIL-MSGID: =?utf-8?q?1763516030090847839?= Callers of get_cbm_mask() are required to pass a string into which the CBM bit mask is read into. Neither CAT nor CMT tests need the mask as string but just convert it into an unsigned long value. The bit mask reader can only read .../cbm_mask files. Generalize the bit mask reading function into get_bit_mask() such that it can be used to handle other files besides the .../cbm_mask and handle the unsigned long conversion within within get_bit_mask() using fscanf(). Alter get_cbm_mask() to construct the filename for get_bit_mask(). Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 5 +-- tools/testing/selftests/resctrl/cmt_test.c | 5 +-- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrlfs.c | 50 +++++++++++++++------ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index a998e6397518..9bf5d05d9e74 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -18,7 +18,6 @@ #define MAX_DIFF 1000000 static int count_of_bits; -static char cbm_mask[256]; static unsigned long long_mask; static unsigned long cache_size; @@ -101,12 +100,10 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) cache_size = 0; /* Get default cbm mask for L3/L2 cache */ - ret = get_cbm_mask(cache_type, cbm_mask); + ret = get_cbm_mask(cache_type, &long_mask); if (ret) return ret; - long_mask = strtoul(cbm_mask, NULL, 16); - /* Get L3/L2 cache size */ ret = get_cache_size(cpu_no, cache_type, &cache_size); if (ret) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 2d434c03cbba..ae54bbabbd91 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -17,7 +17,6 @@ #define MAX_DIFF_PERCENT 15 static int count_of_bits; -static char cbm_mask[256]; static unsigned long long_mask; static unsigned long cache_size; @@ -82,12 +81,10 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) if (!validate_resctrl_feature_request(CMT_STR)) return -1; - ret = get_cbm_mask("L3", cbm_mask); + ret = get_cbm_mask("L3", &long_mask); if (ret) return ret; - long_mask = strtoul(cbm_mask, NULL, 16); - ret = get_cache_size(cpu_no, "L3", &cache_size); if (ret) return ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index ba36eb5fdf0d..bcc95faa5b4e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -106,7 +106,7 @@ void tests_cleanup(void); void mbm_test_cleanup(void); int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); void mba_test_cleanup(void); -int get_cbm_mask(char *cache_type, char *cbm_mask); +int get_cbm_mask(char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size); void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 7fef9068d7fd..f01ecfa64063 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -186,30 +186,29 @@ int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size) #define CORE_SIBLINGS_PATH "/sys/bus/cpu/devices/cpu" /* - * get_cbm_mask - Get cbm mask for given cache - * @cache_type: Cache level L2/L3 - * @cbm_mask: cbm_mask returned as a string + * get_bit_mask - Get bit mask from given file + * @filename: File containing the mask + * @mask: The bit mask returned as unsigned long * * Return: = 0 on success, < 0 on failure. */ -int get_cbm_mask(char *cache_type, char *cbm_mask) +static int get_bit_mask(char *filename, unsigned long *mask) { - char cbm_mask_path[1024]; FILE *fp; - if (!cbm_mask) + if (!filename || !mask) return -1; - sprintf(cbm_mask_path, "%s/%s/cbm_mask", INFO_PATH, cache_type); - - fp = fopen(cbm_mask_path, "r"); + fp = fopen(filename, "r"); if (!fp) { - perror("Failed to open cache level"); - + fprintf(stderr, "Failed to open bit mask file '%s': %s\n", + filename, strerror(errno)); return -1; } - if (fscanf(fp, "%s", cbm_mask) <= 0) { - perror("Could not get max cbm_mask"); + + if (fscanf(fp, "%lx", mask) <= 0) { + fprintf(stderr, "Could not read bit mask file '%s': %s\n", + filename, strerror(errno)); fclose(fp); return -1; @@ -219,6 +218,31 @@ int get_cbm_mask(char *cache_type, char *cbm_mask) return 0; } +/* + * get_cbm_bits - Get number of bits in cbm mask + * @cache_type: Cache level L2/L3 + * @mask: cbm_mask returned as unsigned long + * + * Return: = 0 on success, < 0 on failure. + */ +int get_cbm_mask(char *cache_type, unsigned long *mask) +{ + char cbm_mask_path[1024]; + int ret; + + if (!cache_type) + return -1; + + snprintf(cbm_mask_path, sizeof(cbm_mask_path), "%s/%s/cbm_mask", + INFO_PATH, cache_type); + + ret = get_bit_mask(cbm_mask_path, mask); + if (ret) + return -1; + + return 0; +} + /* * get_core_sibling - Get sibling core id from the same socket for given CPU * @cpu_no: CPU number From patchwork Tue Apr 18 11:44:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84811 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2794146vqo; Tue, 18 Apr 2023 05:09:55 -0700 (PDT) X-Google-Smtp-Source: AKy350bzzDTI0sWGMPCc4yaAhWo9imqQrEJCaoPYi7PclsK6lmO4IteN02T1h4X8iaXvVkooWeqA X-Received: by 2002:a17:90a:5288:b0:246:7582:b76f with SMTP id w8-20020a17090a528800b002467582b76fmr2170743pjh.0.1681819795073; Tue, 18 Apr 2023 05:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819795; cv=none; d=google.com; s=arc-20160816; b=FOXRGPZzvuYfOe+Uxc+cHU6EtyfdUIvXdzaIHz0c5o/0U4WCydH2hSqqPdE8hQ2Tqc Pp/uvq3g9LxPkFMs/BQNcBSZh+yBytt9c+eeQw1Vkm7I5vgCSQpzTJuli8UrB/vmGmmP IZz0wUUQs0fDzfJAdmiJx1byF1n+HzlcfJPbYpNHK0KeFu9tzJdXn4w3qTCcpjNo5eFs P1bKSmRrtoU+drgEwbAAIMyJVQRl09qiAmaciRQ3YAY3HTLa4NZkJK2pRo/K7JNHDZY3 DKxdxLtrDI+bt9zPW1hU0Hunwz6F4zwz8cb+LAhpswgGDvqBeA8AU9Gdf6NuzeNFy55b 1F6g== 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 :dkim-signature; bh=12A23c86wgFjh0NwQYT5ty5LjoS9AA5d8dgLON/0QIo=; b=c+UrkyXWayfkVU0PIac+Dw1Iidia/eS0oi6A+yQogAzUpF7atX/3jnnMylR2CeTp/S bhn0woJaJRds/Bd6rF6hq8wejazNrjjZ0U0GoODnaeIzwcB6UZuT5l94Lb3rWZU21g3G sqk6aAnsIsC1CZlXKOoAAAA2D7yT8bboWz7YRgxXXiDO5Jiyr5sWHOtF4HeyD6qJkkSF ia+JW1PHt7Nb5+BgOFGeLQ7jgPlRRqEDfWmGKV3q2diIx8HDGVm3ZXVczdHV3q9ZrDkn t7QiKkdjESt4Zv5oUhBYhXW9oUPKsGFiqkJnfjj0LiWv6aROa28drAEVPIZGfUnZZHOr T5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YYABdEFa; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a17090274cb00b001a19bd8aa63si13894386plt.36.2023.04.18.05.09.36; Tue, 18 Apr 2023 05:09:55 -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=@intel.com header.s=Intel header.b=YYABdEFa; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjDRLrn (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjDRLrk (ORCPT ); Tue, 18 Apr 2023 07:47:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA65F1BC0; Tue, 18 Apr 2023 04:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818430; x=1713354430; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FadlcAYLzZZPP+wLU1eQDR/Sf3rZoeCx35VWKn+SAM4=; b=YYABdEFakR3339ALEyPEXxbTcdTTqMxiJVeiq/30OD13j9TAqUOWF0YG H0sLgYqJGNk5cXx9T5xEAhPMpqadnEXtzWAHrQUWo/7ODKcAAdRlTSmwB 1sTdav5jbU9NXw7W34OmSXxCt6Bxs8ELpm8w6bllV39QVTLnfU5l+KPSD bt38jBWqAfDnM6u26gVL6J2eRXIwu8lbyJBB9+5IIM7l5YeBKrnYxy/v3 4bpRwNDkOQWG+vBK+5UYs5VEdxBJBIFor5agONSFnmgIdmY3CSE1PzD9z YWjn3Ayvp3/Vaw/psI0/QsXAOdgqn0qrm8NE/FwMYkZK0vreQdJFKRsqu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994418" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994418" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601753" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601753" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:13 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 16/24] selftests/resctrl: Create cache_alloc_size() helper Date: Tue, 18 Apr 2023 14:44:58 +0300 Message-Id: <20230418114506.46788-17-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515873671300477?= X-GMAIL-MSGID: =?utf-8?q?1763515873671300477?= CAT and CMT tests calculate the span size from the n-bits cache allocation on their own. Add cache_alloc_size() helper which calculates size of the cache allocation for the given number of bits to avoid duplicating code. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 27 ++++++++++++++++++++++ tools/testing/selftests/resctrl/cat_test.c | 8 +++++-- tools/testing/selftests/resctrl/cmt_test.c | 4 +++- tools/testing/selftests/resctrl/resctrl.h | 2 ++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 6bc912de38be..b983af394e33 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -15,6 +15,33 @@ static struct read_format rf_cqm; static int fd_lm; char llc_occup_path[1024]; +/* + * cache_alloc_size - Calculate alloc size for given cache alloc mask + * @cpu_no: CPU number + * @cache_type: Cache level L2/L3 + * @alloc_mask: Cache alloc mask + * @alloc_size: Alloc size returned on success + * + * Returns: 0 on success with @alloc_size filled, non-zero on error. + */ +int cache_alloc_size(int cpu_no, char *cache_type, unsigned long alloc_mask, + unsigned long *alloc_size) +{ + unsigned long cache_size, full_mask; + int ret; + + ret = get_cbm_mask(cache_type, &full_mask); + if (ret) + return ret; + + ret = get_cache_size(cpu_no, cache_type, &cache_size); + if (ret) + return ret; + + *alloc_size = cache_size * count_bits(alloc_mask) / count_bits(full_mask); + return 0; +} + static void initialize_perf_event_attr(void) { pea_llc_miss.type = PERF_TYPE_HARDWARE; diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 9bf5d05d9e74..d3fbd4de9f8a 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -140,7 +140,9 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) /* Set param values for parent thread which will be allocated bitmask * with (max_bits - n) bits */ - param.span = cache_size * (count_of_bits - n) / count_of_bits; + ret = cache_alloc_size(cpu_no, cache_type, l_mask, ¶m.span); + if (ret) + return ret; strcpy(param.ctrlgrp, "c2"); strcpy(param.mongrp, "m2"); strcpy(param.filename, RESULT_FILE_NAME2); @@ -162,7 +164,9 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) param.mask = l_mask_1; strcpy(param.ctrlgrp, "c1"); strcpy(param.mongrp, "m1"); - param.span = cache_size * n / count_of_bits; + ret = cache_alloc_size(cpu_no, cache_type, l_mask_1, ¶m.span); + if (ret) + exit(-1); strcpy(param.filename, RESULT_FILE_NAME1); param.num_of_runs = 0; param.cpu_no = sibling_cpu_no; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index ae54bbabbd91..efe77e0f1d4c 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -105,10 +105,12 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) .cpu_no = cpu_no, .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, - .span = cache_size * n / count_of_bits, .num_of_runs = 0, .setup = cmt_setup, }; + ret = cache_alloc_size(cpu_no, "L3", param.mask, ¶m.span); + if (ret) + return ret; if (strcmp(benchmark_cmd[0], "fill_buf") == 0) sprintf(benchmark_cmd[1], "%lu", param.span); diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index bcc95faa5b4e..65425d92684e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -108,6 +108,8 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); void mba_test_cleanup(void); int get_cbm_mask(char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size); +int cache_alloc_size(int cpu_no, char *cache_type, unsigned long alloc_mask, + unsigned long *alloc_size); void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); void signal_handler_unregister(void); From patchwork Tue Apr 18 11:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2781952vqo; Tue, 18 Apr 2023 04:51:33 -0700 (PDT) X-Google-Smtp-Source: AKy350boaUS5lWF1HHUYIRLPnfjEQ/s/377Quh+qv58ucgoxqKJ8uPM6fkD7283hZgamBfUwmm4A X-Received: by 2002:a05:6a00:1acb:b0:63b:23b0:a72e with SMTP id f11-20020a056a001acb00b0063b23b0a72emr24837427pfv.15.1681818692860; Tue, 18 Apr 2023 04:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818692; cv=none; d=google.com; s=arc-20160816; b=FxW+bIzBSGgfbFwTHkvPqvmyctWCV6zCO/nLRJ0czmKw7zl1Aw0bdHXge2aVck+zyj rhd9zfgISROEGhlOvdGH8rEQ4cYboW0YfIAEDjKGyKyPBcdT5n15LWD20udAL1BbORJi GOHn0GxFgsWFQp6ea6+VkyXvvwkEl1boguJEqA+l+a+6/7Iq9MjUVs5o7EdHlCfdWXiY UTliMwcWTo3j1SD5KC2lH31E9mkuVnmDX9SQcsZasGGDLBFIDnJ58r9ev28sDMaiE/8D opusKoestsnBerv2t/SaNScn3WSTAcBZaLciQPAoG5xd12WmItAocADXSBjAxeYbnCbq +2BA== 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 :dkim-signature; bh=pgeeBvvTpj2cDJN7h1f/ToDXKwCYK5j5aicL6h+nsRc=; b=UWr4wbD9nq8GwaKqFj3ocuEWllIUSH/drA8+SovtV43bJqCaNyKvKLvad88u2+J+58 2+0WUIiueFgm+WvM1PPd3v8IFUB7Imf84g5EopPg5SY5asT0acKEDwdf7dp38XF4DMZ5 /2C24hSe8GC+0OeCH87xS2PAXopm2YZGh9qCCsEAnYj818ecTGzrv4xn3gfOIf/gKb+k JzfuU2ZCwYgWtV8zRv/u5hmaI9Iw/gwkiG1oSz81N7/qFZ4WvlTPEvr1pUn+Z60IpmH6 v8oQHHTCGysID6VtguAiap1k6L9oJnOPULnGe1Pst6r0gm2Tm6PA0Ga/TkU+TuGAF6/x 1/pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aVIIw4IA; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b0051f3c811e2csi1499070pge.98.2023.04.18.04.51.19; Tue, 18 Apr 2023 04:51:32 -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=@intel.com header.s=Intel header.b=aVIIw4IA; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231384AbjDRLro (ORCPT + 99 others); Tue, 18 Apr 2023 07:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbjDRLrm (ORCPT ); Tue, 18 Apr 2023 07:47:42 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2633265BF; Tue, 18 Apr 2023 04:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818434; x=1713354434; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dr2l2TxlFFiREWwatq8+29/dJHLAULNZVHaY9hHY5v4=; b=aVIIw4IA6Nwgvvw4j8dLZmZrP2G301kXP+dPzr5r1suQzeEDD/oFB6zz VAGFYfNarM5GgRDqzAuMdVHql9W2jco7ZYjY78qI/f62AslUbex2jLryr cifHvaCGgsCmvmY+YgsBBvgPePAJubN40ISTf5keaG5yJo+NLpDa4EhYk 3wzpb3Mchy6S4cVRdXn3SO98qYap46G2sWTMDIKhb6hrAb5pPGD4qaHVa N8ZhnueX1S83fZCpodWxzMV6vCwhdtc5OjOBmp/RYn0NaPL1eu/0S1AhW jgDEstRHUbitJ4uFmsiPtcQ3ov8ZlaJ0KdvhUUFOeRDDcBfCod3u11Dj7 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994436" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994436" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601795" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601795" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:16 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 17/24] selftests/resctrl: Replace count_bits with count_consecutive_bits() Date: Tue, 18 Apr 2023 14:44:59 +0300 Message-Id: <20230418114506.46788-18-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514717460382170?= X-GMAIL-MSGID: =?utf-8?q?1763514717460382170?= CAT and CMT tests depends on masks being continuous. Replace count_bits with more appropriate variant that counts consecutive bits. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 6 ++--- tools/testing/selftests/resctrl/cmt_test.c | 3 +-- tools/testing/selftests/resctrl/resctrl.h | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 30 +++++++++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index d3fbd4de9f8a..a1834dd5ad9a 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -78,7 +78,7 @@ static int check_results(struct resctrl_val_param *param) } fclose(fp); - no_of_bits = count_bits(param->mask); + no_of_bits = count_consecutive_bits(param->mask, NULL); return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64, MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS, @@ -103,6 +103,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) ret = get_cbm_mask(cache_type, &long_mask); if (ret) return ret; + count_of_bits = count_consecutive_bits(long_mask, NULL); /* Get L3/L2 cache size */ ret = get_cache_size(cpu_no, cache_type, &cache_size); @@ -110,9 +111,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) return ret; ksft_print_msg("Cache size :%lu\n", cache_size); - /* Get max number of bits from default-cabm mask */ - count_of_bits = count_bits(long_mask); - if (!n) n = count_of_bits / 2; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index efe77e0f1d4c..98e7d3accd73 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -84,14 +84,13 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) ret = get_cbm_mask("L3", &long_mask); if (ret) return ret; + count_of_bits = count_consecutive_bits(long_mask, NULL); ret = get_cache_size(cpu_no, "L3", &cache_size); if (ret) return ret; ksft_print_msg("Cache size :%lu\n", cache_size); - count_of_bits = count_bits(long_mask); - if (n < 1 || n > count_of_bits) { ksft_print_msg("Invalid input value for numbr_of_bits n!\n"); ksft_print_msg("Please enter value in range 1 to %d\n", count_of_bits); diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 65425d92684e..aa5dc8b95a06 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -106,6 +106,7 @@ void tests_cleanup(void); void mbm_test_cleanup(void); int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); void mba_test_cleanup(void); +unsigned int count_consecutive_bits(unsigned long val, unsigned int *start); int get_cbm_mask(char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size); int cache_alloc_size(int cpu_no, char *cache_type, unsigned long alloc_mask, diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index f01ecfa64063..4efaf69c8152 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -10,6 +10,8 @@ */ #include "resctrl.h" +#include + static int find_resctrl_mount(char *buffer) { FILE *mounts; @@ -218,6 +220,34 @@ static int get_bit_mask(char *filename, unsigned long *mask) return 0; } +/* + * count_consecutive_bits - Returns the longest train of bits in a bit mask + * @val A bit mask + * @start The location of the least-significant bit of the longest train + * + * Return: The length of the consecutive bits in the longest train of bits + */ +unsigned int count_consecutive_bits(unsigned long val, unsigned int *start) +{ + unsigned long last_val; + int count = 0; + + while (val) { + last_val = val; + val &= (val >> 1); + count++; + } + + if (start) { + if (count) + *start = ffsl(last_val) - 1; + else + *start = 0; + } + + return count; +} + /* * get_cbm_bits - Get number of bits in cbm mask * @cache_type: Cache level L2/L3 From patchwork Tue Apr 18 11:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2782820vqo; Tue, 18 Apr 2023 04:53:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YlUH5dVr30ZIWfTgQNA87cKIyGSI/7OW8KIeVEejQM77fDIthy4JIqUUjahfRwBBRj/3A2 X-Received: by 2002:a05:6a20:4413:b0:ee:b102:2efd with SMTP id ce19-20020a056a20441300b000eeb1022efdmr15095894pzb.3.1681818796966; Tue, 18 Apr 2023 04:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818796; cv=none; d=google.com; s=arc-20160816; b=rYnc9/AB5nmoDKzza10lpMEAXJ60Ucn95wxs8TixTeJGgBz+rZe3QBzO8zmMBbwszF U6LpspaAVg7qMBJq2dZcyYIY3U7iVxIy1ik1M6twjJwsopgdumeMxaeDij38tr9MmwpJ Xi3etZsph6sFMczIwKxguVNv30lISbCsYTJ1+8eLjV7SRfrSkOJrke3y+l6aVW7jd9aR N4Ub8qYTOG2OfNiCmlJlSevbiSPSO2JTScVnnzWgmOm8FH8tgyF9ci+dQJH0A2Wy1XNs 13oz8HkpnSmYbfsuC1njCHveeJ/K8Mmxs1YVhS3vMFoZpm6TP5vPz/eI0swBgG/7LFmd S6Zg== 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 :dkim-signature; bh=AspQudTNRABI6yHl64LPehdxtc7V6qt8wEUPTaVjk+0=; b=cE+rnl/8Bo7pNpkiuT21dYb2r7GmFBx2e5uHyKGX375Lx8DHMu0eok1K2SPIjUFOBz +dJ2ja0U1wXyaVy8l1adznFii7MILKS//V8Wo7V5VyHVPXi8xv6haFV5vYoankiWhQl5 B71kvM3JT9l0N7qUg8iL1LLZMskHe11mEhLllZfry6gWYWH7N15p0MBp1PGxPKN0YlvG NIKecbYjG8jhn4L3SlvOqhTRiTR8hvGPMgnSmO7xDTtXF7eCUvKIXWj658mM6zkRXeJJ XG389aeITNVW9Lk7URGf4J8/VjNMlm7YEBbfFP0cji3r6/dmWk329wFSl/vvmeZ5vXo4 RnPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QfiCP5As; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b0051f3c811e2csi1499070pge.98.2023.04.18.04.53.04; Tue, 18 Apr 2023 04:53:16 -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=@intel.com header.s=Intel header.b=QfiCP5As; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231253AbjDRLsI (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231387AbjDRLsF (ORCPT ); Tue, 18 Apr 2023 07:48:05 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE88D86AD; Tue, 18 Apr 2023 04:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818450; x=1713354450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wk7rUmbwOKLeLGgJ6ksj1ofr3mRBg8GwCrF45mjaYLI=; b=QfiCP5AsnvodJu7pEEbDG6lBfWO5J46463v2X3yaAg7UxOA3GeOgH3s2 BteBO56U782ubDjjEXyeStTO18kIL8pWx8f8TA6B+7zNbHPvqx6a900f/ WtilkvcorGjuTMt/ypU3BNm6+mQI3VvpA2OQ1vM9X9S3Y0RjPC3jTaXYw Dz5mPGVACe/LWPd3F/kAgRYegjnNGCXNnq6O51cgHZLhDFoJTd0bTHetA NdzNgG1Nsi6CXSaERUWB8Xl9QfH2zjclN8DchEHzqaN0YORn5rKsAUSjY LcfWHVwXnrS3zHehRPTI/zSNhe65Htg8OsRrva3DNOrkzBSHEhMdXI35S Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994456" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994456" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601817" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601817" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:19 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 18/24] selftests/resctrl: Exclude shareable bits from schemata in CAT test Date: Tue, 18 Apr 2023 14:45:00 +0300 Message-Id: <20230418114506.46788-19-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514826413202754?= X-GMAIL-MSGID: =?utf-8?q?1763514826413202754?= CAT test doesn't take shareable bits into account, i.e., the test might be sharing cache with some devices (e.g., graphics). Introduce get_mask_no_shareable() and use it to provision an environment for CAT test where the allocated LLC is isolated better. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 2 +- tools/testing/selftests/resctrl/resctrl.h | 3 ++ tools/testing/selftests/resctrl/resctrlfs.c | 56 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index a1834dd5ad9a..e2d10124cdb1 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -100,7 +100,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) cache_size = 0; /* Get default cbm mask for L3/L2 cache */ - ret = get_cbm_mask(cache_type, &long_mask); + ret = get_mask_no_shareable(cache_type, &long_mask); if (ret) return ret; count_of_bits = count_consecutive_bits(long_mask, NULL); diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index aa5dc8b95a06..be5a61e7fbcc 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -106,8 +106,11 @@ void tests_cleanup(void); void mbm_test_cleanup(void); int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); void mba_test_cleanup(void); +unsigned long create_bit_mask(unsigned int start, unsigned int len); unsigned int count_consecutive_bits(unsigned long val, unsigned int *start); int get_cbm_mask(char *cache_type, unsigned long *mask); +int get_shareable_mask(char *cache_type, unsigned long *shareable_mask); +int get_mask_no_shareable(char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size); int cache_alloc_size(int cpu_no, char *cache_type, unsigned long alloc_mask, unsigned long *alloc_size); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 4efaf69c8152..94b99b06bc89 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -220,6 +220,16 @@ static int get_bit_mask(char *filename, unsigned long *mask) return 0; } +/* + * create_bit_mask- Create bit mask from start,len pair + * @start: LSB of the mask + * @len Number of bits in the mask + */ +unsigned long create_bit_mask(unsigned int start, unsigned int len) +{ + return ((1UL << len) - 1UL) << start; +} + /* * count_consecutive_bits - Returns the longest train of bits in a bit mask * @val A bit mask @@ -273,6 +283,52 @@ int get_cbm_mask(char *cache_type, unsigned long *mask) return 0; } +/* + * get_shareable_mask - Get shareable mask from shareable_bits for given cache + * @cache_type: Cache level L2/L3 + * @shareable_mask: shareable mask returned as unsigned long + * + * Return: = 0 on success, < 0 on failure. + */ +int get_shareable_mask(char *cache_type, unsigned long *shareable_mask) +{ + char mask_path[1024]; + + if (!cache_type) + return -1; + + snprintf(mask_path, sizeof(mask_path), "%s/%s/shareable_bits", + INFO_PATH, cache_type); + + return get_bit_mask(mask_path, shareable_mask); +} + +/* + * get_mask_no_shareable - Get CBM mask without shareable_bits for given cache + * @cache_type: Cache level L2/L3 + * @mask: mask returned as unsigned long + * + * Return: = 0 on success, < 0 on failure. + */ +int get_mask_no_shareable(char *cache_type, unsigned long *mask) +{ + unsigned long full_mask, shareable_mask; + unsigned int start, len; + + if (get_cbm_mask(cache_type, &full_mask) < 0) + return -1; + if (get_shareable_mask(cache_type, &shareable_mask) < 0) + return -1; + + len = count_consecutive_bits(full_mask & ~shareable_mask, &start); + if (!len) + return -1; + + *mask = create_bit_mask(start, len); + + return 0; +} + /* * get_core_sibling - Get sibling core id from the same socket for given CPU * @cpu_no: CPU number From patchwork Tue Apr 18 11:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2782666vqo; Tue, 18 Apr 2023 04:52:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YKfOtR5eavdTQdUrf5jWE2cgJ1U2yUZXd6AKw+nj3ZCiG9KF6uuSJjPEJr+BJTxMd4Mt/B X-Received: by 2002:a17:902:e74c:b0:1a6:cd08:5594 with SMTP id p12-20020a170902e74c00b001a6cd085594mr1808721plf.69.1681818776409; Tue, 18 Apr 2023 04:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818776; cv=none; d=google.com; s=arc-20160816; b=m31hmkKk/yyafiwMTsq/3uozM9F5bRKlqFGdjtJ3a824NjNP+bN22fWaIR/1CoPvSY ZEHZRDhrcc9IMeZKvD0GWv0B4zpMpdNKYGZ0lByaLB/4fL0wrR/5pNjej5D78cNZ2Mcb gkEctFB2EQPdEqxr4qhOhcgZcOLzep+XCmsmZKv+J9E84dCW+7fuw5BLsoCVQLIYXosI fJIT9G0vRKiAkSEuKo9144LRP3CxhXzFUsbBbRtu/zvdpQe4FgY6YInoWZU4nXJKuQhO iDxq1WUt7duxSHSbmGeo3Ok1KfNnzQPeMf5LCLvHIqLNRGBu2JfHkiId2NKegHRK+xfU 3WzA== 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 :dkim-signature; bh=4O1GmtjiqrvN6+UXeob2GFRq+HAwX2vmD7ApeLd2MIw=; b=iQ+oKBOvDVFPGYoh0igA0RyLBeH04vQYd6n6a58syTaI+f6oVqHh13CsISPc/SyhOS vLRuz8prHWnVM5Y4sMD2jbvRSHFsJqLPrm00XEjyA5bUhluIdzdOZQDy+/TGpq2/fShW DxjIMqEByJiLHkY/DtI1/uQHQImDqB9FTDvILSm8HBDEQ4dWfUDJUB2uZTJnaRDVANHx BUwDEDNypSswtL7CGpqYSlHC8OI/x0vc6/sfKgpf5LWdsfaPyAjdtUg6D1FRe00cGJNI nGc+E3Dlx0GJGAmuBKrCo7RWJphmc/tdntdQATU7z/SHm24Ir0pdGTod6RmZRcGndG1z AiLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aIuzDXFK; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a4ee96c00bsi15304188plr.357.2023.04.18.04.52.43; Tue, 18 Apr 2023 04:52:56 -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=@intel.com header.s=Intel header.b=aIuzDXFK; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjDRLsP (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbjDRLsL (ORCPT ); Tue, 18 Apr 2023 07:48:11 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C7A230E4; Tue, 18 Apr 2023 04:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818458; x=1713354458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CvYgU7P/mUo+lerWgOGHrYSwnUvkU/Rq7wcifjwteuM=; b=aIuzDXFKUWLtyhtuY/BTiPJpb/R+Yobv4YnWkdOtTjgK3QwAGtQ6VYUE P4VMPM7BpXqUFm0dfyZHiLKgfzc90L/tbz8ICdGboxw5+pGwWWmgWJbvD ifqrwmVBtNIbrc3IqWiYIQUnm85QCvh/m1RU7PbyGLdL5A9AGf0Yjh3xq bVsbtQyXAvM6QsLFuASv2eNa2sCgHwOKpRwzCdcQjZQfauLl9lerQ4Glu ebUeM8FgSeGE4YmVgou5GmVh8VcGSGyI8fZKi80fOVl6euyD6gs6d3ahQ lIjsvjQ/73xdLR6L5ueEdn4whpYQYzyUiEIlp3oIeunMvFiIRAWFZSBUD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994469" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994469" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601834" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601834" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:22 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 19/24] selftests/resctrl: Pass the real number of tests to show_cache_info() Date: Tue, 18 Apr 2023 14:45:01 +0300 Message-Id: <20230418114506.46788-20-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514805422900235?= X-GMAIL-MSGID: =?utf-8?q?1763514805422900235?= Some results include warm-up tests which are discarded before passing the sum to show_cache_info(). Currently, show_cache_info() handles this by subtracting one from the number of tests in divisor. It is a trappy construct to have sum and number of tests parameters to disagree like this. A more logical place for subtracting the skipped tests is where the sum is calculated so move it there. Pass the correct number of tests to show_cache_info() soit can use directly as the divisor for calculating the average. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 2 +- tools/testing/selftests/resctrl/cat_test.c | 2 +- tools/testing/selftests/resctrl/cmt_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index b983af394e33..c93f5d2bc66e 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -312,7 +312,7 @@ int show_cache_info(unsigned long sum_llc_val, int no_of_bits, long avg_diff = 0; int ret; - avg_llc_val = sum_llc_val / (num_of_runs - 1); + avg_llc_val = sum_llc_val / num_of_runs; avg_diff = (long)abs(cache_span - avg_llc_val); diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index e2d10124cdb1..ae21e656cf6e 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -81,7 +81,7 @@ static int check_results(struct resctrl_val_param *param) no_of_bits = count_consecutive_bits(param->mask, NULL); return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64, - MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS, + MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, get_vendor() == ARCH_INTEL, false); } diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 98e7d3accd73..087378a775ee 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -63,7 +63,7 @@ static int check_results(struct resctrl_val_param *param, int no_of_bits) fclose(fp); return show_cache_info(sum_llc_occu_resc, no_of_bits, param->span, - MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS, + MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, true, true); } From patchwork Tue Apr 18 11:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2783747vqo; Tue, 18 Apr 2023 04:55:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ZEbWqtZDWfUoksdUgd3jsbabA7t1jvb/s+/BK4YgRjdYZX5WylmFY7LsGMJUWE632kth4N X-Received: by 2002:a05:6a20:440a:b0:ef:412:8e8c with SMTP id ce10-20020a056a20440a00b000ef04128e8cmr13727473pzb.58.1681818905274; Tue, 18 Apr 2023 04:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818905; cv=none; d=google.com; s=arc-20160816; b=UF4cX2UVtfo+jQpVrPnGvi+ldTy/id9RkNzPnkcFFO3tQWoh73PtVsjvpuB4dEnCsR FYxcP8dMnClhgHr5npPJ+pFMxHKIx3+oQs0upyJ0jXnrv6C4VEuCjZ+YQhbfXTspNg2t mybwDrZInbUNcos/CMFs+Do7OfLJC4AkvkmkJ9+MWbuerrMNEjca83Ayx/tmuRn4kPZS spybPFKq9dc+zOH5gWextnVAV9OTO4hFfblo5N2jIpGgvwPvXd2GgaSGgjcK61BvCCz7 V8MsNDXwTqynW4KbqivU2pV54mb2pZ7b2JPWe+QL1jwmDdI+MkWBKk3OXjjsa9tQX1Q1 jc5w== 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 :dkim-signature; bh=ZFW0GmoAuo7rPWWVc42aESIW2TQUeOCb8D9C2m0vO5I=; b=d6yUVzkRiI+sBdchY3DgNGWNBWKk99r208aYPA/QK8WjMdsMdQRA0i+E9GCuUcgorx +bUUHu3ZT/JUUJ6H+c8WfhR1XfvN7RIWp/bGdXP1iw8vc0O/FFfme9MzrcDidN9hZqj1 Pxm0mHclWGTpQgjUzjQxBQIav6iJGiz9dVDn7703YDxp2JmaXyYqRzvj27NiTd1IC8+E 8yDcxcCxYGMXo1429l0H/ZqX/s1DTED4nWOtZV9AaI9xpwlolC/VRmnnK9ZfI26Jicqv f0/XViNwIrHlDeq9jo0z7balJ1BMK8Wt3xR/XwjbQiqoQzdSFCYSyAG8UeEyEzRcDoeV Fm+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kUjxbTiR; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i191-20020a6387c8000000b0051f3c811e2csi1499070pge.98.2023.04.18.04.54.52; Tue, 18 Apr 2023 04:55:05 -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=@intel.com header.s=Intel header.b=kUjxbTiR; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbjDRLsU (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbjDRLsR (ORCPT ); Tue, 18 Apr 2023 07:48:17 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E387DB1; Tue, 18 Apr 2023 04:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818463; x=1713354463; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KE5DE/VP3tizpaCKNJsP8NjVpWGqNNHqkbWqi0EEH4k=; b=kUjxbTiRA5OiKQ2QH9P2knJvnPYQgORMrM4PElcSYrrD6OY3oghUy1eC HCk2qenJTZdhh3wUQsrh4GoLa4D4yIcO6nMtHvwbTVUdQtVOZdjMUI/Kn UoFUy1wfAcqlaPwcTdBpGhCVw+DK36EFnLJXKCRqmGRPD+GthKCjwB1lb qEYVdraxi4EgdBLgZrvtvOBMIxustjCuMk0vXcYCOabqaBNt6DmAHXupZ lLozMX4qYv8ItjmJhKc6mIMd6YEK9btqJJ4Fgix+71z37jR9zXrY3/QnL 7GnqQiwbyUMcMmoyVh8BTkjXRMbhOcgqWNSbQyUzKREAZqWx2tP9lY41t Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994480" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994480" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601851" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601851" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:25 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 20/24] selftests/resctrl: Move CAT/CMT test global vars to func they are used Date: Tue, 18 Apr 2023 14:45:02 +0300 Message-Id: <20230418114506.46788-21-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763514940413925276?= X-GMAIL-MSGID: =?utf-8?q?1763514940413925276?= CAT and CMT tests have count_of_bits, long_mask, and cache_size global variables that can be moved into the sole using function. Make the global variables local variables of the relevant function to scope them better. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 7 +++---- tools/testing/selftests/resctrl/cmt_test.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index ae21e656cf6e..ef3ba22bdde5 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -17,10 +17,6 @@ #define MAX_DIFF_PERCENT 4 #define MAX_DIFF 1000000 -static int count_of_bits; -static unsigned long long_mask; -static unsigned long cache_size; - /* * Change schemata. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -95,6 +91,9 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) { unsigned long l_mask, l_mask_1; int ret, pipefd[2], sibling_cpu_no; + unsigned long cache_size; + unsigned long long_mask; + int count_of_bits; char pipe_message; cache_size = 0; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 087378a775ee..6adee08661e7 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -16,10 +16,6 @@ #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 -static int count_of_bits; -static unsigned long long_mask; -static unsigned long cache_size; - static int cmt_setup(struct resctrl_val_param *p) { /* Run NUM_OF_RUNS times */ @@ -74,6 +70,9 @@ void cmt_test_cleanup(void) int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) { + unsigned long cache_size; + unsigned long long_mask; + int count_of_bits; int ret; cache_size = 0; From patchwork Tue Apr 18 11:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2795329vqo; Tue, 18 Apr 2023 05:11:29 -0700 (PDT) X-Google-Smtp-Source: AKy350aE0IImrXcXpdRi57iL8Li3n8zho5BlI2vhpmvXhUt21aOc2zmIpaENNgfZuckprofvR711 X-Received: by 2002:a05:6a00:cc1:b0:634:970e:ca09 with SMTP id b1-20020a056a000cc100b00634970eca09mr24498007pfv.30.1681819889687; Tue, 18 Apr 2023 05:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819889; cv=none; d=google.com; s=arc-20160816; b=CVQ+Ub+WTiiGgQsscCMyfOt9M5mrhSNfDGXxTXXDbkpmNeucDyJsS4NI6m5DjyQ+ZQ pDY0Mkt04yBQ2Sk6B+Xjm0uHTQQv6PTgRFqBVKbZtnj7RySBxYxqmu0j5a9kv7nvKf88 Tr+1f34fgtAPsjtt5RrH6AbtBB9muAyAPDMluBWC3+cwqPzbuHRJ/PaH6rbkaP3S7Iyt 9nHFue6Nc/YDHicLz0sA0vzcNU8Bfo8yVCUp9I56ECuIdVr90P8LYJG1/G5HA6PwFCgK 4v8ZouP+QAfwfvlRkJjWFBB+Wvhgtx/dsPTglNMba28EISqMddtDrL3lvo9TR6yDvqqt HnNA== 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 :dkim-signature; bh=OKVYUlw0BbhJrClUgbZmRWqk1rMXLffgQ6ocyLLIxGk=; b=V1dtnouGq2ZQyq9a+Pl/ZCfmD2MQdNLPi1dPhMTrKqFmKW9wn1WhILdu3ol59inC5+ XNlybZIS5dqHwXTCCY2TXrnTtsuUq1xSOGjf4j9/lroIncYcHQAMra/1PJtWzu0/FNrO c9M+4fftyCoCnEGxSjedCSApgdjJYvtTpYoYXAwGWPOD3mVhOeCiGHSUAsJU4ZPqAlGD SKc3bef8Fq0oJziif/UJykSb3pyJ2LapoEqFB/b0sl7yEx70tFi+7D5yiwjrcfWG9qQt I9LoSWPuqErsXLoBiPkAPj9u39i7Nfy8mkhp3a9JrV8X1JZBmcYJ9el+tJRNdL2UJih9 o4KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bLqJKe+R; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020aa78e8f000000b0063b6e660b65si10193466pfr.288.2023.04.18.05.11.15; Tue, 18 Apr 2023 05:11:29 -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=@intel.com header.s=Intel header.b=bLqJKe+R; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230502AbjDRLsi (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbjDRLsd (ORCPT ); Tue, 18 Apr 2023 07:48:33 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCF283C0; Tue, 18 Apr 2023 04:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818485; x=1713354485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o4xwHdOVMGdLd6NXJ0J9sSmWMj5I0QfO/TqlAoKy0Ng=; b=bLqJKe+Rw7RWmE2yvcbABIsf23dQmD5YpmB20Qzo3uULU8/f6yLv4u83 oHE5PVmyG3NPIXd2b6kgLYJIi/RMaFa5tj1e5TLItSjUB8e1R0PzoULiD mDbE2z+sVYQe26l3Q7sJAylt/weNPgoFgFtf7bx9SFkh4mjqb/2qlak7x 66XYQ7paAiZ6L8wF+ICrktNM/gjXdxs4snS5lCvDzEsqXWu9rOCll0JDK 9+T3e35643Vq5f9Iynes/jkKSmOQgo5/VlvZBekIIsQjodafQJzCdo8ig bcMPguswyuqEJtdPwqIDx3qzGhwIUinzUHrotbMoIwbwaZmwVx7deXDtk g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994490" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994490" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601868" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601868" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:28 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 21/24] selftests/resctrl: Read in less obvious order to defeat prefetch optimizations Date: Tue, 18 Apr 2023 14:45:03 +0300 Message-Id: <20230418114506.46788-22-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515972816852570?= X-GMAIL-MSGID: =?utf-8?q?1763515972816852570?= When reading memory in order, HW prefetching optimizations will interfere with measuring how caches and memory are being accessed. This adds noise into the results. Change the fill_buf reading loop to not use an obvious in-order access using multiply by a prime and modulo. Signed-off-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/fill_buf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 7e0d3a1ea555..049a520498a9 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -88,14 +88,17 @@ static void *malloc_and_init_memory(size_t s) static int fill_one_span_read(unsigned char *start_ptr, unsigned char *end_ptr) { - unsigned char sum, *p; - + unsigned int size = (end_ptr - start_ptr) / (CL_SIZE / 2); + unsigned int count = size; + unsigned char sum; + + /* + * Read the buffer in an order that is unexpected by HW prefetching + * optimizations to prevent them interfering with the caching pattern. + */ sum = 0; - p = start_ptr; - while (p < end_ptr) { - sum += *p; - p += (CL_SIZE / 2); - } + while (count--) + sum += start_ptr[((count * 59) % size) * CL_SIZE / 2]; return sum; } From patchwork Tue Apr 18 11:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2784336vqo; Tue, 18 Apr 2023 04:56:16 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0MRInT0kFMQ2UyQg/FJ8fdnFRRj11EZ5m2NV3zcEZjxyFmjE9P/xfP54QQtbAqht5RIMw X-Received: by 2002:a17:902:da82:b0:19c:f232:21ca with SMTP id j2-20020a170902da8200b0019cf23221camr2624810plx.3.1681818976327; Tue, 18 Apr 2023 04:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681818976; cv=none; d=google.com; s=arc-20160816; b=Stuv6vpy7+76+s/gGAwlzMnNdpmrPnaR5lJY/oHdUcvkrb4B+D4GRpoM7DISx6jXXa 7+Lr81GNOaPnJtfswhHfzF7uhzpGEYeqs25iFQ+KVfgfVJa/QH2eetqeX3kvyhM7ejhz +4U6VFBYETPngo/zc7LfeiZ5k9h7gOI0cdv6vfuiW27KOrQtO/bFclw+tUjHTEpdraCP TKUTCYBoj4gvPEpNXA+PG5mteMTdgiY10vvk5QBYicE0Pq9R+DnKgKmXSR1Yb2cKmHiX emjbJyq6M3cmDhryKO2J5LNu6/aqo34OOFgLKeiPAMDWRh6yGZCUl80WAohcfDRJQSFT XWEQ== 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 :dkim-signature; bh=IWogXjw3Z5PfY6KzLqzrGxk775GsTWEL8E9sMUreFw8=; b=W2xFy8cJ3cjnPoiqEFuW1ymS6FxsOnA9cGSosuJSqwYijlCzK9/QdBVUbRzbQrwO3E 4DdP2IUN15QDF0jWtyUbu1xCSpuUyfEAwWiwlWVGlydm3SGvq2AfEqWm+XQIRCzYjHKX fInN2TupJm6PKSFry70T8QuVn/erMCONlooIzaJTAHB4H5TppAM+dEiJn04kCHfaEqSd y079wed3FVpo/1O3sqhgAPdeMblvBgoQjDVFJf+m/funqP2h/hZy4FsIUdIoOZZF6Z5Y pZzbQTPrV45J2vohK05oVM5/V/Ai/BDi5YjuMQztwyPm4+E0FYbVqt9lkr+uDozA+BKS fO7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SwoAYpKt; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a4ee96c00bsi15304188plr.357.2023.04.18.04.56.03; Tue, 18 Apr 2023 04:56:16 -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=@intel.com header.s=Intel header.b=SwoAYpKt; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbjDRLsq (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjDRLsl (ORCPT ); Tue, 18 Apr 2023 07:48:41 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9B7E9742; Tue, 18 Apr 2023 04:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818491; x=1713354491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jaOCRYxcj3LDYMPNeQhfGhOtBkAd1hyZ1bFX0DhyAqk=; b=SwoAYpKtlRZsJdK6FWUQjAnHGP8hGPLGiyOlY7nbm1VkiyPzthQG03uQ mktMyp7auY/InfMFjCGfkl/uJAiPLMDOY04ypFYVlWPVgtMw36WuTDuKt wDVKWDPOgdGID6kZeqbsU7xI1+ZmKyCwXFGcej3HgaLXuqwS1X7SzLffc NkYnh3wYXhhhypBu19KRU8dKpUZdTu/mwe45xrzwY3Blg7YmWWUgHECww twSo8sLVf+RWPLXrjidg6BnFFtbBn1JaoyEBztI8bU4k5fztellRJT96B jJp6oatb7J9METL5KMLbfkSA/Y0tU/i73Zqtd/0PwtAZHhwechgYCDOc3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994497" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994497" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601877" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601877" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:31 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 22/24] selftests/resctrl: Split measure_cache_vals() function Date: Tue, 18 Apr 2023 14:45:04 +0300 Message-Id: <20230418114506.46788-23-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515014891774336?= X-GMAIL-MSGID: =?utf-8?q?1763515014891774336?= The measure_cache_vals() function does a different thing depending on the test case that called it: - For CAT, it measures LLC perf misses 2. - For CMT, it measures LLC occupancy through resctrl. Split these two functionalities such that CMT test calls a new function called measure_llc_resctrl() to get LLC occupancy through resctrl and CAT test directly calls get_llc_perf(). Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 37 ++++++++----------- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index c93f5d2bc66e..a015ce2d0a3c 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -199,35 +199,20 @@ static int print_results_cache(char *filename, int bm_pid, return 0; } -int measure_cache_vals(struct resctrl_val_param *param, int bm_pid) +int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid) { - unsigned long llc_perf_miss = 0, llc_occu_resc = 0, llc_value = 0; + unsigned long llc_occu_resc = 0; int ret; - /* - * Measure cache miss from perf. - */ - if (!strncmp(param->resctrl_val, CAT_STR, sizeof(CAT_STR))) { - ret = get_llc_perf(&llc_perf_miss); - if (ret < 0) - return ret; - llc_value = llc_perf_miss; - } - /* * Measure llc occupancy from resctrl. */ - if (!strncmp(param->resctrl_val, CMT_STR, sizeof(CMT_STR))) { - ret = get_llc_occu_resctrl(&llc_occu_resc); - if (ret < 0) - return ret; - llc_value = llc_occu_resc; - } - ret = print_results_cache(param->filename, bm_pid, llc_value); - if (ret) + ret = get_llc_occu_resctrl(&llc_occu_resc); + if (ret < 0) return ret; - return 0; + ret = print_results_cache(param->filename, bm_pid, llc_occu_resc); + return ret; } /* @@ -241,6 +226,7 @@ int cat_val(struct resctrl_val_param *param) { int memflush = 1, operation = 0, ret = 0; char *resctrl_val = param->resctrl_val; + unsigned long llc_perf_miss = 0; pid_t bm_pid; if (strcmp(param->filename, "") == 0) @@ -281,7 +267,14 @@ int cat_val(struct resctrl_val_param *param) } sleep(1); - ret = measure_cache_vals(param, bm_pid); + + /* Measure cache miss from perf */ + ret = get_llc_perf(&llc_perf_miss); + if (ret) + break; + + ret = print_results_cache(param->filename, bm_pid, + llc_perf_miss); if (ret) break; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index be5a61e7fbcc..12754733126f 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -124,7 +124,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd); unsigned int count_bits(unsigned long n); void cmt_test_cleanup(void); int get_core_sibling(int cpu_no); -int measure_cache_vals(struct resctrl_val_param *param, int bm_pid); +int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid); int show_cache_info(unsigned long sum_llc_val, int no_of_bits, unsigned long cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index f0f6c5f6e98b..0ffe4694bf47 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -774,7 +774,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { sleep(1); - ret = measure_cache_vals(param, bm_pid); + ret = measure_llc_resctrl(param, bm_pid); if (ret) break; } From patchwork Tue Apr 18 11:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2785149vqo; Tue, 18 Apr 2023 04:57:59 -0700 (PDT) X-Google-Smtp-Source: AKy350aAiluQS6laNwxy79wkR3EGbHi63Kz01OiMOVzRlLL3g9H2URKr7P0t9BvkKEdtUa4htpqO X-Received: by 2002:a17:902:c44c:b0:1a6:d15f:3cde with SMTP id m12-20020a170902c44c00b001a6d15f3cdemr1575057plm.54.1681819079646; Tue, 18 Apr 2023 04:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819079; cv=none; d=google.com; s=arc-20160816; b=06Swf68FqQx2D5oUhRZBv2ne0TxeN9bexOM/orQHzjnoCvcZksaPtOa48P0ei0SfPl g00VgIQtqqvStB6H8B24dZdsdozDD4SOPHi7nGY3H5Nbk8mwRQ6Np3AztXVYTH8EHNZ0 ZLJzc4rwLhkcsKFEGGV9YbJGeYZEOGbCnBbiv+5c/H87OvSs4YrbpjAx6noJ1B831H6U Y9jEdsEueM9nQyACZasU4wy7Ikb2huA/LBQ4lffThymwKCFGmZphTgc5epPzJn/GUJ8z uQS6AI9MaZ9KQp7PbcLfY9yv/svvTk7VOoX5dbbLyEszK+HACqg5C0QuYMzabnqyirM8 8afw== 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 :dkim-signature; bh=MwRBWQbe2V1iJKal4OOHtHXK9JNhTSR9tETkntoXptw=; b=Jy1SXAvN61+xpIUTRF1JkQuUso2O1Wlbt/CDlUDNmDc73UzW8g5rtOFC8MEy3CZqm0 JBceFR0G5g2ByE2oSc4zh9NIoqYooR06GV/y5vD5TyBoWdksAW4gTbW8nGmJBnu/LE0H V4BA3CtiJ4E04sysMdDsvnBMdnFrvs3r1vNowK11MTYkQsq4TM4lQMq58uqYTiLcY4QQ 2lk0rzkdgi3R5DQO0mqukRtx9gXU49mW/DTMEk9uDzplgW8T01p97/D8IujiDdIdJCNz mtwCvsukj7eOZM6ROHpKz1/ISgWvyCoYKKEdQhCstJu6PdMTeTZv9XpvjDJAKGJjdGie zZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mg2M9s3F; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a4ee96c00bsi15304188plr.357.2023.04.18.04.57.47; Tue, 18 Apr 2023 04:57:59 -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=@intel.com header.s=Intel header.b=Mg2M9s3F; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbjDRLsx (ORCPT + 99 others); Tue, 18 Apr 2023 07:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbjDRLsp (ORCPT ); Tue, 18 Apr 2023 07:48:45 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F659A276; Tue, 18 Apr 2023 04:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818497; x=1713354497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3kC1cIvW3Ly4ZuJDs2oLZ6s9guHuS3vAGx7X5+zB3q0=; b=Mg2M9s3FOyjwMO8gNClK1h6XHJi59CqVwwk6EmxegebdkWskb6i48nDo vkYEJfGm8x/9UWgHwHRt7paZmVowsRUL8uD184vhfpUC2c/MKQI33iyHA v/3K6m44kzTaBWZcwDxKO6UJ6GogAaqGVA8Mgz3j4CTJPgd5S2O82GRvQ NTHKfDc5lBYzVBYEcR40aNzLFvszWYoTUBJTrXcYYPZSxB3gIt2aMBT/M 0/eGFymYGPqqGeNPngXP8hxAQxz5vzCPeRAsJkcr0oPL9+K+Dg8HWQWn9 a/hMZvFDTGPRYhm+FvUt4jFdaArgnLafI/SFt4621z3kVExSqdc8oejpY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994509" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994509" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601891" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601891" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:34 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 23/24] selftests/resctrl: Split show_cache_info() to test specific and generic parts Date: Tue, 18 Apr 2023 14:45:05 +0300 Message-Id: <20230418114506.46788-24-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515123283636541?= X-GMAIL-MSGID: =?utf-8?q?1763515123283636541?= show_cache_info() attempts to do calculate the results and provide generic cache information. It makes hard to alter the pass/fail conditions. Separate the the test specific checks into CAT and CMT test files and leave only the generic information part into show_cache_info(). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 40 ++++------------------ tools/testing/selftests/resctrl/cat_test.c | 30 ++++++++++++++-- tools/testing/selftests/resctrl/cmt_test.c | 32 +++++++++++++++-- tools/testing/selftests/resctrl/resctrl.h | 6 ++-- 4 files changed, 65 insertions(+), 43 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index a015ce2d0a3c..7970239413da 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -283,43 +283,17 @@ int cat_val(struct resctrl_val_param *param) } /* - * show_cache_info: show cache test result information - * @sum_llc_val: sum of LLC cache result data + * show_cache_info: show generic cache test information * @no_of_bits: number of bits - * @cache_span: cache span in bytes for CMT or in lines for CAT - * @max_diff: max difference - * @max_diff_percent: max difference percentage - * @num_of_runs: number of runs - * @platform: show test information on this platform - * @cmt: CMT test or CAT test - * - * Return: 0 on success. non-zero on failure. + * @avg_llc_val: avg of LLC cache result data + * @cache_span: cache span + * @lines: cache span in lines or bytes */ -int show_cache_info(unsigned long sum_llc_val, int no_of_bits, - unsigned long cache_span, unsigned long max_diff, - unsigned long max_diff_percent, unsigned long num_of_runs, - bool platform, bool cmt) +void show_cache_info(int no_of_bits, unsigned long avg_llc_val, + unsigned long cache_span, bool lines) { - unsigned long avg_llc_val = 0; - float diff_percent; - long avg_diff = 0; - int ret; - - avg_llc_val = sum_llc_val / num_of_runs; - avg_diff = (long)abs(cache_span - avg_llc_val); - diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; - - ret = platform && abs((int)diff_percent) > max_diff_percent && - (cmt ? (abs(avg_diff) > max_diff) : true); - - ksft_print_msg("%s Check cache miss rate within %d%%\n", - ret ? "Fail:" : "Pass:", max_diff_percent); - - ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent)); ksft_print_msg("Number of bits: %d\n", no_of_bits); ksft_print_msg("Average LLC val: %lu\n", avg_llc_val); - ksft_print_msg("Cache span (%s): %lu\n", cmt ? "bytes" : "lines", + ksft_print_msg("Cache span (%s): %lu\n", !lines ? "bytes" : "lines", cache_span); - - return ret; } diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index ef3ba22bdde5..4b505fdb35d7 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -41,6 +41,30 @@ static int cat_setup(struct resctrl_val_param *p) return ret; } +static int show_results_info(unsigned long sum_llc_val, int no_of_bits, + unsigned long cache_span, unsigned long max_diff, + unsigned long max_diff_percent, unsigned long num_of_runs, + bool platform) +{ + unsigned long avg_llc_val = 0; + float diff_percent; + int ret; + + avg_llc_val = sum_llc_val / num_of_runs; + diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; + + ret = platform && abs((int)diff_percent) > max_diff_percent; + + ksft_print_msg("%s Check cache miss rate within %d%%\n", + ret ? "Fail:" : "Pass:", max_diff_percent); + + ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent)); + + show_cache_info(no_of_bits, avg_llc_val, cache_span, true); + + return ret; +} + static int check_results(struct resctrl_val_param *param) { char *token_array[8], temp[512]; @@ -76,9 +100,9 @@ static int check_results(struct resctrl_val_param *param) fclose(fp); no_of_bits = count_consecutive_bits(param->mask, NULL); - return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64, - MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, - get_vendor() == ARCH_INTEL, false); + return show_results_info(sum_llc_perf_miss, no_of_bits, param->span / 64, + MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, + get_vendor() == ARCH_INTEL); } void cat_test_cleanup(void) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 6adee08661e7..b3fedade583b 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -27,6 +27,33 @@ static int cmt_setup(struct resctrl_val_param *p) return 0; } +static int show_results_info(unsigned long sum_llc_val, int no_of_bits, + unsigned long cache_span, unsigned long max_diff, + unsigned long max_diff_percent, unsigned long num_of_runs, + bool platform) +{ + unsigned long avg_llc_val = 0; + float diff_percent; + long avg_diff = 0; + int ret; + + avg_llc_val = sum_llc_val / num_of_runs; + avg_diff = (long)abs(cache_span - avg_llc_val); + diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; + + ret = platform && abs((int)diff_percent) > max_diff_percent && + abs(avg_diff) > max_diff; + + ksft_print_msg("%s Check cache miss rate within %d%%\n", + ret ? "Fail:" : "Pass:", max_diff_percent); + + ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent)); + + show_cache_info(no_of_bits, avg_llc_val, cache_span, false); + + return ret; +} + static int check_results(struct resctrl_val_param *param, int no_of_bits) { char *token_array[8], temp[512]; @@ -58,9 +85,8 @@ static int check_results(struct resctrl_val_param *param, int no_of_bits) } fclose(fp); - return show_cache_info(sum_llc_occu_resc, no_of_bits, param->span, - MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, - true, true); + return show_results_info(sum_llc_occu_resc, no_of_bits, param->span, + MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, true); } void cmt_test_cleanup(void) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 12754733126f..fc914391024d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -125,9 +125,7 @@ unsigned int count_bits(unsigned long n); void cmt_test_cleanup(void); int get_core_sibling(int cpu_no); int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid); -int show_cache_info(unsigned long sum_llc_val, int no_of_bits, - unsigned long cache_span, unsigned long max_diff, - unsigned long max_diff_percent, unsigned long num_of_runs, - bool platform, bool cmt); +void show_cache_info(int no_of_bits, unsigned long avg_llc_val, + unsigned long cache_span, bool lines); #endif /* RESCTRL_H */ From patchwork Tue Apr 18 11:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 84814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2795123vqo; Tue, 18 Apr 2023 05:11:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Ze/A4YclmsxMDLXpAbwWgeGFOFrzYFq0ylIAX1qwuWawvsV+z6BUfGt1Q5uxf4ga4UXl3J X-Received: by 2002:a17:903:32ce:b0:1a4:f7c9:33e7 with SMTP id i14-20020a17090332ce00b001a4f7c933e7mr2155451plr.1.1681819871039; Tue, 18 Apr 2023 05:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681819871; cv=none; d=google.com; s=arc-20160816; b=Jgy2vEWM6Fk8T2KkLLm7axbT+PsvaEMkYHJvwS3Q6TlBDWklfbezgmRBOZcdxs+t3L KIcRTkWnLmLaapeELRSp84vvc+Q8h5dwcCQuMjk2rtb5+CgOPL6aTnaJMA+YHueX1UcW WMP00suleXpQdewGEf3zGXbK5a1x2SlGduBRbaP4tkFXHBNNDlXpEC7JoUPh8viI4A7P hE2EhVWlPZfE+9oY4LWgTY/3WlyfR0JsGHySsSXlKWzCkNugp1aKCL9hZ2ti9TdU8HHB AASc7oR8BbMSy862WNQs11dFTrqD3Gz6f7HNDAQx5uTrXa7e2fXVVHPLNQ3WYKQWj0bE uSpw== 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 :dkim-signature; bh=6E36sl+U8aAmpdThUQIqLoc9xeGy4phKx3eFZ5pmZNk=; b=KubC3HJ/t9GdFZqA553vJ+MdLZgBU/6nNdouKWSRgIU8IT3XejUPnYTF8RiS3jb4wB jfgZh0LQeYMQ8I9TIsdUVMQ3SrTHhAMiEaKTM0IVk1YgAiw6FxtteG4t2+AgKJ/2WNUR BnBm0a9Bw6rrmUIIYR9sdGJ6NtQcU/XZzpioEle4RnY9BhrWhNIfHEwBEmonALl9DJrO ZZzFfA90HSRgX05TVwy4PZesGvG3uAWn6HWuh6I+LWvaw+pD4lhwVmMrG5Eii7kaR3ix WI0/g5z620uO0j6Eis7spoXvwhrHXW81fbG5lE2Oqxh+gk+WxmtrbYSGZ/qf05rV8WtZ b9gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BO88OQHG; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902b18900b0019f3d6dfd19si13148688plr.471.2023.04.18.05.10.55; Tue, 18 Apr 2023 05:11:11 -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=@intel.com header.s=Intel header.b=BO88OQHG; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231552AbjDRLtP (ORCPT + 99 others); Tue, 18 Apr 2023 07:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbjDRLtE (ORCPT ); Tue, 18 Apr 2023 07:49:04 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC4883D4; Tue, 18 Apr 2023 04:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681818513; x=1713354513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tJ4gjGRf43MnpoYHW8bPtBTaG6etTX3413E6p2EHI74=; b=BO88OQHGoEixC5ovDq56i780n7ZOLCEdyo1czhALB9AgYD9sYvzkAOVF oDCB+LBqggUUWkjEZGgLqW5OgMOj6/9hvFZcR9A4yj7apxkP3VJi2cSyh qUJqprbIh6KQW8kSSXMQG5f2FDfW1jdtiIoNfQefWYPUE7q4hxVAqxqc5 bz3j+/LK/cdwtBNldZM0Anm597fyU8ccBqOX1ymrz9eNfnNHUgJWM41wE 3hzVY+OVdeg6YVuZLAoTKOhzfbywrVBo+xvUi9o2Hf9FEGktDAQVsoFga UlPe7ROetUR35cJ4FVcGZwoGG9P/XWWsz5+HCDWg4CZ9T7Gr0XPZyFtER g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="346994522" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="346994522" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="723601908" X-IronPort-AV: E=Sophos;i="5.99,207,1677571200"; d="scan'208";a="723601908" Received: from yvolokit-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.213.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 04:46:37 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , linux-kernel@vger.kernel.org Cc: Shaopeng Tan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 24/24] selftests/resctrl: Rewrite Cache Allocation Technology (CAT) test Date: Tue, 18 Apr 2023 14:45:06 +0300 Message-Id: <20230418114506.46788-25-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> References: <20230418114506.46788-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763515952805450431?= X-GMAIL-MSGID: =?utf-8?q?1763515952805450431?= CAT test spawns two processes into two different control groups with exclusive schemata. Both the processes alloc a buffer from memory matching their allocated LLC block size and flush the entire buffer out of caches. Since the processes are reading through the buffer only once during the measurement and initially all the buffer was flushed, the test isn't testing CAT. Rewrite the CAT test to allocated a buffer sized to half of LLC. Then perform a sequence of tests with different LLC alloc sizes starting from half of the CBM bits down to 1-bit CBM. Flush the buffer before each test and read the buffer twice. Observe the LLC misses on the second read through the buffer. As the allocated LLC block gets smaller and smaller, the LLC misses will become larger and larger giving a strong signal on CAT working properly. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 20 +- tools/testing/selftests/resctrl/cat_test.c | 204 +++++++++------------ 2 files changed, 97 insertions(+), 127 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 7970239413da..64f08ba5edc2 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -224,10 +224,10 @@ int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid) */ int cat_val(struct resctrl_val_param *param) { - int memflush = 1, operation = 0, ret = 0; char *resctrl_val = param->resctrl_val; unsigned long llc_perf_miss = 0; pid_t bm_pid; + int ret; if (strcmp(param->filename, "") == 0) sprintf(param->filename, "stdio"); @@ -245,6 +245,10 @@ int cat_val(struct resctrl_val_param *param) if (ret) return ret; + ret = alloc_buffer(param->span, 1); + if (ret) + return ret; + initialize_llc_perf(); /* Test runs until the callback setup() tells the test to stop. */ @@ -256,17 +260,15 @@ int cat_val(struct resctrl_val_param *param) } if (ret < 0) break; + + flush_buffer(param->span); + use_buffer(param->span, 0, true); + ret = reset_enable_llc_perf(bm_pid, param->cpu_no); if (ret) break; - if (run_fill_buf(param->span, memflush, operation, true)) { - fprintf(stderr, "Error-running fill buffer\n"); - ret = -1; - break; - } - - sleep(1); + use_buffer(param->span, 0, true); /* Measure cache miss from perf */ ret = get_llc_perf(&llc_perf_miss); @@ -279,6 +281,8 @@ int cat_val(struct resctrl_val_param *param) break; } + free_buffer(); + return ret; } diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 4b505fdb35d7..85053829b9c5 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -11,11 +11,12 @@ #include "resctrl.h" #include -#define RESULT_FILE_NAME1 "result_cat1" -#define RESULT_FILE_NAME2 "result_cat2" -#define NUM_OF_RUNS 5 -#define MAX_DIFF_PERCENT 4 -#define MAX_DIFF 1000000 +#define RESULT_FILE_NAME "result_cat" +#define NUM_OF_RUNS 5 +#define MIN_DIFF_PERCENT_PER_BIT 2 + +static unsigned long current_mask; +static long prev_avg_llc_val; /* * Change schemata. Write schemata to specified @@ -28,13 +29,24 @@ static int cat_setup(struct resctrl_val_param *p) int ret = 0; /* Run NUM_OF_RUNS times */ - if (p->num_of_runs >= NUM_OF_RUNS) - return END_OF_TESTS; + if (p->num_of_runs >= NUM_OF_RUNS) { + /* Remove one bit from the consecutive block */ + current_mask &= current_mask >> 1; + if (!current_mask) + return END_OF_TESTS; + + p->num_of_runs = 0; + } if (p->num_of_runs == 0) { - sprintf(schemata, "%lx", p->mask); - ret = write_schemata(p->ctrlgrp, schemata, p->cpu_no, - p->resctrl_val); + snprintf(schemata, sizeof(schemata), "%lx", p->mask & ~current_mask); + ret = write_schemata("", schemata, p->cpu_no, p->resctrl_val); + if (ret) + return ret; + snprintf(schemata, sizeof(schemata), "%lx", current_mask); + ret = write_schemata(p->ctrlgrp, schemata, p->cpu_no, p->resctrl_val); + if (ret) + return ret; } p->num_of_runs++; @@ -42,34 +54,41 @@ static int cat_setup(struct resctrl_val_param *p) } static int show_results_info(unsigned long sum_llc_val, int no_of_bits, - unsigned long cache_span, unsigned long max_diff, - unsigned long max_diff_percent, unsigned long num_of_runs, - bool platform) + unsigned long cache_span, long min_diff_percent, + unsigned long num_of_runs, bool platform) { - unsigned long avg_llc_val = 0; - float diff_percent; - int ret; + long avg_llc_val = 0; + int avg_diff_per; + float avg_diff; + int ret = 0; avg_llc_val = sum_llc_val / num_of_runs; - diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; + avg_diff = (float)(avg_llc_val - prev_avg_llc_val) / prev_avg_llc_val; + avg_diff_per = (int)(avg_diff * 100); - ret = platform && abs((int)diff_percent) > max_diff_percent; + if (prev_avg_llc_val) { + ret = platform && avg_diff_per < min_diff_percent; - ksft_print_msg("%s Check cache miss rate within %d%%\n", - ret ? "Fail:" : "Pass:", max_diff_percent); + ksft_print_msg("%s Check cache miss rate changed more than %d%%\n", + ret ? "Fail:" : "Pass:", min_diff_percent); - ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent)); + ksft_print_msg("Percent diff=%d\n", avg_diff_per); + } + prev_avg_llc_val = avg_llc_val; show_cache_info(no_of_bits, avg_llc_val, cache_span, true); return ret; } -static int check_results(struct resctrl_val_param *param) +static int check_results(struct resctrl_val_param *param, char *cache_type) { char *token_array[8], temp[512]; unsigned long sum_llc_perf_miss = 0; - int runs = 0, no_of_bits = 0; + unsigned long alloc_size; + int runs = 0; + int fail = 0; + int ret; FILE *fp; ksft_print_msg("Checking for pass/fail\n"); @@ -83,42 +102,59 @@ static int check_results(struct resctrl_val_param *param) while (fgets(temp, sizeof(temp), fp)) { char *token = strtok(temp, ":\t"); int fields = 0; + int bits; while (token) { token_array[fields++] = token; token = strtok(NULL, ":\t"); } - /* - * Discard the first value which is inaccurate due to monitoring - * setup transition phase. - */ - if (runs > 0) - sum_llc_perf_miss += strtoul(token_array[3], NULL, 0); + + sum_llc_perf_miss += strtoul(token_array[3], NULL, 0); runs++; + + if (runs < NUM_OF_RUNS) + continue; + + if (!current_mask) { + ksft_print_msg("Unexpected empty cache mask\n"); + break; + } + + ret = cache_alloc_size(param->cpu_no, cache_type, current_mask, &alloc_size); + if (ret) + return ret; + + bits = count_bits(current_mask); + + ret = show_results_info(sum_llc_perf_miss, bits, + alloc_size / 64, + MIN_DIFF_PERCENT_PER_BIT * bits, runs, + get_vendor() == ARCH_INTEL); + if (ret) + fail = 1; + + runs = 0; + sum_llc_perf_miss = 0; + current_mask &= current_mask >> 1; } fclose(fp); - no_of_bits = count_consecutive_bits(param->mask, NULL); - return show_results_info(sum_llc_perf_miss, no_of_bits, param->span / 64, - MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, - get_vendor() == ARCH_INTEL); + return fail; } void cat_test_cleanup(void) { - remove(RESULT_FILE_NAME1); - remove(RESULT_FILE_NAME2); + remove(RESULT_FILE_NAME); } int cat_perf_miss_val(int cpu_no, int n, char *cache_type) { - unsigned long l_mask, l_mask_1; - int ret, pipefd[2], sibling_cpu_no; unsigned long cache_size; unsigned long long_mask; + unsigned int start; int count_of_bits; - char pipe_message; + int ret; cache_size = 0; @@ -126,7 +162,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) ret = get_mask_no_shareable(cache_type, &long_mask); if (ret) return ret; - count_of_bits = count_consecutive_bits(long_mask, NULL); + count_of_bits = count_consecutive_bits(long_mask, &start); /* Get L3/L2 cache size */ ret = get_cache_size(cpu_no, cache_type, &cache_size); @@ -143,99 +179,29 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) count_of_bits - 1); return -1; } - - /* Get core id from same socket for running another thread */ - sibling_cpu_no = get_core_sibling(cpu_no); - if (sibling_cpu_no < 0) - return -1; + current_mask = create_bit_mask(start, n); struct resctrl_val_param param = { .resctrl_val = CAT_STR, .cpu_no = cpu_no, + .ctrlgrp = "c1", .setup = cat_setup, + .filename = RESULT_FILE_NAME, + .num_of_runs = 0, }; - - l_mask = long_mask >> n; - l_mask_1 = ~l_mask & long_mask; - - /* Set param values for parent thread which will be allocated bitmask - * with (max_bits - n) bits - */ - ret = cache_alloc_size(cpu_no, cache_type, l_mask, ¶m.span); + param.mask = long_mask; + ret = cache_alloc_size(cpu_no, cache_type, current_mask, ¶m.span); if (ret) return ret; - strcpy(param.ctrlgrp, "c2"); - strcpy(param.mongrp, "m2"); - strcpy(param.filename, RESULT_FILE_NAME2); - param.mask = l_mask; - param.num_of_runs = 0; - - if (pipe(pipefd)) { - perror("# Unable to create pipe"); - return errno; - } - - fflush(stdout); - bm_pid = fork(); - - /* Set param values for child thread which will be allocated bitmask - * with n bits - */ - if (bm_pid == 0) { - param.mask = l_mask_1; - strcpy(param.ctrlgrp, "c1"); - strcpy(param.mongrp, "m1"); - ret = cache_alloc_size(cpu_no, cache_type, l_mask_1, ¶m.span); - if (ret) - exit(-1); - strcpy(param.filename, RESULT_FILE_NAME1); - param.num_of_runs = 0; - param.cpu_no = sibling_cpu_no; - } else { - ret = signal_handler_register(); - if (ret) { - kill(bm_pid, SIGKILL); - goto out; - } - } remove(param.filename); ret = cat_val(¶m); - if (ret == 0) - ret = check_results(¶m); - - if (bm_pid == 0) { - /* Tell parent that child is ready */ - close(pipefd[0]); - pipe_message = 1; - if (write(pipefd[1], &pipe_message, sizeof(pipe_message)) < - sizeof(pipe_message)) - /* - * Just print the error message. - * Let while(1) run and wait for itself to be killed. - */ - perror("# failed signaling parent process"); - - close(pipefd[1]); - while (1) - ; - } else { - /* Parent waits for child to be ready. */ - close(pipefd[1]); - pipe_message = 0; - while (pipe_message != 1) { - if (read(pipefd[0], &pipe_message, - sizeof(pipe_message)) < sizeof(pipe_message)) { - perror("# failed reading from child process"); - break; - } - } - close(pipefd[0]); - kill(bm_pid, SIGKILL); - signal_handler_unregister(); - } + if (ret) + goto out; + current_mask = create_bit_mask(start, n); + ret = check_results(¶m, cache_type); out: cat_test_cleanup();