Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp208897ybh; Fri, 6 Mar 2020 19:46:57 -0800 (PST) X-Google-Smtp-Source: ADFU+vv7ssCwOLQ1bZBUVWv7XYXUVVWVHkCinjviABFdOEYRnTVT+/GsEyrNI2ln3vkCHvJi9lV9 X-Received: by 2002:aca:b608:: with SMTP id g8mr4994451oif.142.1583552817795; Fri, 06 Mar 2020 19:46:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583552817; cv=none; d=google.com; s=arc-20160816; b=Dwtp/E/EICrpHDFLtpP4YQnKLANSr8eW7Tn4n/iYi3h6t1pFf2olTLtRH91kgTZoMB SG54SiWignIFwVHMgWw+GxoyuKPf3XgcsdtDiqIxKEK/SV2CMRiIBsKdIzCTOB9YwAp4 c/qMtVos9SVRljAMrCRs+8MxH3KOyJZ4FPIby3LBwZlJj79GWpGVVUrmmobQugX0A6e/ /lsWEbMxfZJAMFgCXLZ2ea0hwxT2jCYDldnpxZjjRIoSk2sQY4eAtKVeeMtFlqHoFD3U HCRf8jCc4vtmask2sNs61dZD0jbP4dsp02mYTPm0h9AqguhRcxLS+4JrAnHd8VhpwsgV 1k0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cuQvc8x1FmfnBH0ZaU4KHWAaAX1S6vBf/HpYxj/jFxs=; b=i8NJl5Uc+ZQWm1Aior2wRp1X9yCTnJCfy8amPcJIBibjwCSVy6rNeEqoDNLB3vYS6A ymsuLkJUGsUNoItHJMSkhFXSz52ifa8Ee4YoHA1Zn+I3unUT+5aNLDctJvQGLBAgIpnC bL1Cs2ftndYph/fAnmweaECBKsboPIEs/zOLD8ZiBMHNEDNAExJra8rIruSGY3Pp35YS 9fNqC/TmVSJbM1ROc8GIObKVGsrYj2s6Z3IdLNOkjQQavdqXnEGIpPgA5t2RRSIl7/uk +QPWhllnYpR9heG/irBdfpWKfnGGB6QgHE4vzv1Dl+PV2tk20sKmhSb54ij71AkSxZH/ +rMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k128si746427oih.135.2020.03.06.19.46.46; Fri, 06 Mar 2020 19:46:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727095AbgCGDqS (ORCPT + 99 others); Fri, 6 Mar 2020 22:46:18 -0500 Received: from mga11.intel.com ([192.55.52.93]:57583 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727052AbgCGDqR (ORCPT ); Fri, 6 Mar 2020 22:46:17 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 19:46:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,524,1574150400"; d="scan'208";a="235036014" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by fmsmga008.fm.intel.com with ESMTP; 06 Mar 2020 19:46:16 -0800 From: Sai Praneeth Prakhya To: shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, Sai Praneeth Prakhya Subject: [PATCH V1 06/13] selftests/resctrl: Fix MBA/MBM results reporting format Date: Fri, 6 Mar 2020 19:40:47 -0800 Message-Id: <8179b975778fb1d365f3b5d88b69976332a2f061.1583657204.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently MBM/MBA tests use absolute values to check results. But, iMC values and MBM resctrl values may vary on different platforms and specifically for MBA the values may vary as schemata changes. Hence, use percentage instead of absolute values to check tests result. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/mba_test.c | 24 +++++++++++++----------- tools/testing/selftests/resctrl/mbm_test.c | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7bf8eaa6204b..165e5123e040 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -12,7 +12,7 @@ #define RESULT_FILE_NAME "result_mba" #define NUM_OF_RUNS 5 -#define MAX_DIFF 300 +#define MAX_DIFF_PERCENT 5 #define ALLOCATION_MAX 100 #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 @@ -62,31 +62,33 @@ static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) allocation++) { unsigned long avg_bw_imc, avg_bw_resc; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; - unsigned long avg_diff; + float avg_diff; + int avg_diff_per; /* * The first run is discarded due to inaccurate value from * phase transition. */ for (runs = NUM_OF_RUNS * allocation + 1; - runs < NUM_OF_RUNS * allocation + NUM_OF_RUNS ; runs++) { + runs < NUM_OF_RUNS * allocation + NUM_OF_RUNS; runs++) { sum_bw_imc += bw_imc[runs]; sum_bw_resc += bw_resc[runs]; } avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS - 1); avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS - 1); - avg_diff = labs((long)(avg_bw_resc - avg_bw_imc)); + avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff_per = (int)(avg_diff * 100); - printf("%sok MBA schemata percentage %u smaller than %d %%\n", - avg_diff > MAX_DIFF ? "not " : "", - ALLOCATION_MAX - ALLOCATION_STEP * allocation, - MAX_DIFF); - tests_run++; - printf("# avg_diff: %lu\n", avg_diff); + printf("%sok MBA: diff within %d%% for schemata %u\n", + avg_diff_per > MAX_DIFF_PERCENT ? "not " : "", + MAX_DIFF_PERCENT, + ALLOCATION_MAX - ALLOCATION_STEP * allocation); printf("# avg_bw_imc: %lu\n", avg_bw_imc); printf("# avg_bw_resc: %lu\n", avg_bw_resc); - if (avg_diff > MAX_DIFF) + printf("# avg_diff_per: %d%%\n", avg_diff_per); + tests_run++; + if (avg_diff_per > MAX_DIFF_PERCENT) failed = true; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 4700f7453f81..530ec5bec0b9 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -11,7 +11,7 @@ #include "resctrl.h" #define RESULT_FILE_NAME "result_mbm" -#define MAX_DIFF 300 +#define MAX_DIFF_PERCENT 5 #define NUM_OF_RUNS 5 static void @@ -19,29 +19,30 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) { unsigned long avg_bw_imc = 0, avg_bw_resc = 0; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; - long avg_diff = 0; - int runs; + float avg_diff = 0; + int runs, avg_diff_per; /* * Discard the first value which is inaccurate due to monitoring setup * transition phase. */ - for (runs = 1; runs < NUM_OF_RUNS ; runs++) { + for (runs = 1; runs < NUM_OF_RUNS; runs++) { sum_bw_imc += bw_imc[runs]; sum_bw_resc += bw_resc[runs]; } - avg_bw_imc = sum_bw_imc / 4; - avg_bw_resc = sum_bw_resc / 4; - avg_diff = avg_bw_resc - avg_bw_imc; + avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS - 1); + avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS - 1); + avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff_per = (int)(avg_diff * 100); printf("%sok MBM: diff within %d%%\n", - labs(avg_diff) > MAX_DIFF ? "not " : "", MAX_DIFF); - tests_run++; - printf("# avg_diff: %lu\n", labs(avg_diff)); + avg_diff_per > MAX_DIFF_PERCENT ? "not " : "", MAX_DIFF_PERCENT); printf("# Span (MB): %d\n", span); printf("# avg_bw_imc: %lu\n", avg_bw_imc); printf("# avg_bw_resc: %lu\n", avg_bw_resc); + printf("# avg_diff_per: %d%%\n", avg_diff_per); + tests_run++; } static int check_results(int span) -- 2.7.4