From patchwork Wed Feb 8 09:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 54307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355649wrn; Wed, 8 Feb 2023 01:33:04 -0800 (PST) X-Google-Smtp-Source: AK7set9WcKPe1w3m6SmIEQIKCLyq/CAVufK19i0Q4XwtFrXJWOHc8GUpCr0UZ2vYUqxJIEjnmLEu X-Received: by 2002:a62:1792:0:b0:592:705a:5a5e with SMTP id 140-20020a621792000000b00592705a5a5emr5819587pfx.9.1675848783919; Wed, 08 Feb 2023 01:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848783; cv=none; d=google.com; s=arc-20160816; b=UmU4uowglahnsrr/Mi8RBwF0AyBvQAsypM05w7mAhKbfv2iae7xZ2WgaYPO2r7k/am hlGnohCgNdSXR4ab9FXzy+wBt5YH13OT86fHPGrZddOzXu5Ij4ljJ8f9tzGnGU3hUIm1 1n2slcZkdHrbtJHNwh40Kg8AVqZ8quR23KtS/4PkcTGKrWkhSs3GT8oCrSoZL67GZ9lR daM1pEKwOlepGz6M0YqLRAgfrnUnqIrYgECJzjk4BwbtHxhik0Iz9O3g+2TcEnr7rRWM EnhwBric9JfSJ8WvBIrTPRy6BuOjUvg8ZeOTUcPW2GGVzJlTbWxeoOevvdXp++Q0nWFc 8IRg== 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:to:from :dkim-signature; bh=POZIMx4cfKB1YxjIeohVJ0GGv+Vcpea4G7mA6nU12F0=; b=yh8RRJBwaeubWTEopR0NaEb1WZGR6X951DCF9jldZXL52avvlW3xYBSEPwZXdiw+Ia oczvVuLVFxEj2v9WGN5uAo2Fssp2tYdHJUw5zMb0yKuBaukOGxu7sfWWigusm6+RMpPO 2B/FzzrX38TRZUlrJto3e1VpVkxK6Hx/Z6rr2Bfc+Wh+gEAUzt9ZaFtBlDdyEkEp9Ba7 /caWCF2cac1YRJyJdLDkfoAXqBYnNX5lqbq9PTbawRUjeFVL1pYLrW2TSyG2uE+ioTBt i/0U9paK9F1rMgIxYdDSjd4G9D4tJcP8TIVOeNOYJ2UWkj0WuGLLUy3T/qCYfJsT+sh4 IgkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DHqyuRlJ; 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 a23-20020aa794b7000000b005a70bd64eabsi5303084pfl.46.2023.02.08.01.32.51; Wed, 08 Feb 2023 01:33:03 -0800 (PST) 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=DHqyuRlJ; 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 S230469AbjBHJbb (ORCPT + 99 others); Wed, 8 Feb 2023 04:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbjBHJbM (ORCPT ); Wed, 8 Feb 2023 04:31:12 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F07545F67; Wed, 8 Feb 2023 01:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848631; x=1707384631; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=TRBoRdV3a9jOZVWAFY2ULLzhstU2pVvPebTVTTjpfxE=; b=DHqyuRlJAnYH5HKe+KtEj56wxt7U5KVrJ5vmA+Ql7NzY3lfNhCX7XTzd /fMaFvGJFDT7UOw+PxycNgBANO40CQBe2h2Qk2ELvLm5SjPGwA/l+8/kR U1WZFz5Rqqz68Fupr2t7rFXzZ9Ns/HD9TbCdubSdlUIP97VkkVC/xOuMT T+9KWiPmtCj8hWgObk1Ig2x1jQqxGvgBfAITdXmDJhgviKDL8cr2lSlmr h/3Rc+BdDwS9RQ4gV/WssYR0ImMUKcG6tX281F2X5tnZ4YxZ6lDYePvHX vleYCBiZtGcUdrOycn/O1mgp9Sp8g+D2fnn6i/x2LpCgGZMWBADbq0nfA A==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974499" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974499" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613865" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613865" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:27 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Babu Moger , Sai Praneeth Prakhya Subject: [PATCH 1/4] selftests/resctrl: Return error if memory is not allocated Date: Wed, 8 Feb 2023 11:30:13 +0200 Message-Id: <20230208093016.20670-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-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,SPF_HELO_NONE, SPF_NONE 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?1757254814441890206?= X-GMAIL-MSGID: =?utf-8?q?1757254814441890206?= From: Fenghua Yu malloc_and_init_memory() in fill_buf isn't checking if memalign() successfully allocated memory or not before accessing the memory. Check the return value of memalign() and return NULL if allocating aligned memory fails. Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark") Signed-off-by: Fenghua Yu --- tools/testing/selftests/resctrl/fill_buf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 56ccbeae0638..f4880c962ec4 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s) size_t s64; void *p = memalign(PAGE_SIZE, s); + if (!p) + return p; p64 = (uint64_t *)p; s64 = s / sizeof(uint64_t); From patchwork Wed Feb 8 09:30:14 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: 54308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355724wrn; Wed, 8 Feb 2023 01:33:16 -0800 (PST) X-Google-Smtp-Source: AK7set+xmxV+qDftWjgBN/sOJiZnjtfnF3guX9vJmqJVALVVqa6Le+bYLXsJFRF1wJT2Lpyz+I6+ X-Received: by 2002:a17:90b:4a0d:b0:230:c723:f37d with SMTP id kk13-20020a17090b4a0d00b00230c723f37dmr7828146pjb.40.1675848796014; Wed, 08 Feb 2023 01:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848796; cv=none; d=google.com; s=arc-20160816; b=JQ7i8KUxQ6ErgkxNBpuk/YkJcCWoLTYl25x/bCux89j1hLF3DDLiBks/Cqsx9WUlR+ WDrXQY0tna5OtICeI9uoFJJRtE/cLUuQkaO55MWvTFvCPILBe7PxUjlIS6D9nP8ybm5l 8a3a6zNU80rsudW35tb7QbZ5ALsFSz4rAZafmKj3OSStEQKMzaxCL89GWBBW9tQRsEq9 ozeY0pq+18j8Y69crvZh1JEHMVGoEIuMASRL1n43CjwTNKWvhGu0KXvNFFoi9mICUCxo WejiN6f1mV34DgiMk3SCxenSnQ6eHAUjHUYe+5uwZ+mpOzgkhLC7h9T/sQRf2w5oqD2S UFKw== 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=Xa3TXuN8tr5PiZ9Qve/BF6IoWGdWzSHONEqG2K1qAtQ=; b=CKRIgiBISZnKUayqWIGSOVPq2XZRM8/RuoTPpud/r4CjLQ0Rapw/gttzkfKUg9AoUr Dek+/M5iCzdu46lCXQWtUlBBcKdhNKCtkluOprJBlCdc/JUT0VZ3rkUmNd3g4IaOboGq O5asFhbHUFuxypXQa28rk4EuRKa9lC0/k29f1XjvuMO+aF/OwYOaUKLt30JgJ/N7vu+Q hqyKqHqcaR9p3LQs4pgRUkS1PxyIW2+nAlTOmGyvIFkm8vW6izBkoX85+HgbTx7CTYST 3NAamXstmPMIpEq0iABYV7o8fM2f+im4v9fc8OYKPuvSe8ottb9zgR3zV5lQtwLJnXJS AA3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KCx3UlJ4; 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 x91-20020a17090a6c6400b00229d64c32dfsi1660970pjj.15.2023.02.08.01.33.03; Wed, 08 Feb 2023 01:33:15 -0800 (PST) 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=KCx3UlJ4; 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 S229745AbjBHJbn (ORCPT + 99 others); Wed, 8 Feb 2023 04:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbjBHJbP (ORCPT ); Wed, 8 Feb 2023 04:31:15 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD7A63B3CF; Wed, 8 Feb 2023 01:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848634; x=1707384634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q1oBWKuYYomRqNoQkEbpKAD3e1aQEGBUh4JgrqrFNLo=; b=KCx3UlJ45MkfqbEisr/BYe02wtyF9HQ7dZ1uMOvQ2wqALLsagaSRvNYy +UfPh3mxv3Af3SQYHKj+XYlkN8KtdRMN2cDrjJsk+qr28dB99rVV3fQKD eXAXJE8MfQmnW5gS6H5R16kMCAv2Pwu85XvX3hLTUNL3h/8rWCy8urVNx TEt20ZsF++bFzfUUPmiv/SAz9bBzCvgv2TROiB4XHqoI9snl658hMle6k xKmRs2VMfdy6Y2dqolYm2sQREX1vW+18OXZJqIKb0D83HX1gJDh9XoTgr Z0+Z2d86OGokbcmIfLPYJu1uRvTl7AXqonyUnKXpDcnBJHmDQupIv0qhs Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974516" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974516" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613892" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613892" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:31 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 2/4] selftests/resctrl: Move ->setup() call outside of test specific branches Date: Wed, 8 Feb 2023 11:30:14 +0200 Message-Id: <20230208093016.20670-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-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,SPF_HELO_NONE, SPF_NONE 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?1757254826956758173?= X-GMAIL-MSGID: =?utf-8?q?1757254826956758173?= resctrl_val() function is called only by mbm, mba, and cmt tests which means the else branch is never used and can be removed. Presently, both of the the test branches call param->setup(). Thus, the call can be placed outside of the test specific branches reducing code duplication. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index b32b96356ec7..787546a52849 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -734,29 +734,22 @@ 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); + if (ret) { + ret = 0; + break; + } + if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = param->setup(1, param); - if (ret) { - ret = 0; - break; - } - ret = measure_vals(param, &bw_resc_start); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { - ret = param->setup(1, param); - if (ret) { - ret = 0; - break; - } sleep(1); ret = measure_cache_vals(param, bm_pid); if (ret) break; - } else { - break; } } From patchwork Wed Feb 8 09:30:15 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: 54310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355954wrn; Wed, 8 Feb 2023 01:33:54 -0800 (PST) X-Google-Smtp-Source: AK7set+tmtPDZvU26Fsl3r/F5wfSq8vLdfwUgKxbnWpUDrcllZGr3KYbe8gYEBMpv6Ju1CrA6M0F X-Received: by 2002:a05:6a20:8408:b0:bc:c663:41bd with SMTP id c8-20020a056a20840800b000bcc66341bdmr9108572pzd.4.1675848833736; Wed, 08 Feb 2023 01:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848833; cv=none; d=google.com; s=arc-20160816; b=0S8cvdSpDUxZb73r5G3HA9e7NDO57K4J08dd6P2oQp6gRWBOF6TJwNwBwd+0UKTeuF IJ2aEtjg7rSWn8ncZ0RH2T+lkkyasioi6eez1eXmCcXB6UGOLFFK1RmUVrMfWwVc2Fez lgAgr40YIgdtRYgtvMIw8ajYPPULcuGiruo/94LG7RFZP6GibeEdqaL2E+rIR0OSk+WP XSur7ZhFT80+/tkGH0ps6fWYMyjqId029QFD58QaMGoKli7dekKob9qokR9BGYAfxFMG TSSvnVE6h09NIm8NKh6cQu05TbqHntJxA9EcUFfZL8VUG8467KcJ9H+tN/uEFQcUPi5P cStA== 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=QgOS9hbI+bLV1z9cMUxET4AGBgB7eMQrPYZUdxBJNn0=; b=G8y5m70D8FNvlgOwlarNll1D3Xfl7ZjbtZFGMyTp4wuS3g0P7wpBDpgX5ONe/lA6dp /EnIdElTxYIFYqjP7alIzNC0Yo6B5HvBL01HLGTfBScT7Ra7xVl6U84u5f2yGOhB5v8B JpolgGCLQeeAkNi4JfDvNoeDhC4lrCz11TvQXUFxpKnU769rzlmldM3EcvXaXYwTknT6 8oLkIm0xiu/DACfFmSCUdyo9kgjQbYopfkHcolSL8J1/1F6NOatDUfSBDJNMvTy8eV5a VjMs2BXbpQyysuwIdGQyNOYR5rVlawMJw2ekujFaz2WzoAEftZyu+W+Sgo2Kq8c8xxyh /nVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lO4gPbSf; 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 j64-20020a638043000000b004b45fca9020si18990757pgd.397.2023.02.08.01.33.40; Wed, 08 Feb 2023 01:33:53 -0800 (PST) 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=lO4gPbSf; 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 S229942AbjBHJbq (ORCPT + 99 others); Wed, 8 Feb 2023 04:31:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbjBHJbQ (ORCPT ); Wed, 8 Feb 2023 04:31:16 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6D804608B; Wed, 8 Feb 2023 01:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848638; x=1707384638; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GSxLLsk3gISJ3/oHPl1UpUk/MN38+zv/LARL2weDoeU=; b=lO4gPbSf8daPffF/0S/XmLMvuMwYOBxdDkrc+/x6uGxZCrFQAEIt0poN 4B4m41JKtnk739EeV68F5coB+PfilwHZjMY7KFAXk27prnSWLrzPvRReJ bNKnYBnsVZHLTxNFYISNvwVI6XT3Zf9o7bE/Jx4/bghu7jHNjCc86J8+/ /iYoaurH0htpfTdgKjiVcjx9kWGoclH1rpDRuTRL5FCjiKnXaMnyM4M8+ nTXK0VYIMjgjpi+vDHhbfxMxLV8ufWum5PRKPadLfxrSQkmqPkHCAXLxz Rgxo9pS2qd6SoJclatxQw/y23mFjvxJZsQy77pZrWnt6lYNwUYgq+rdGr Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974545" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974545" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613935" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613935" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:34 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Babu Moger , Sai Praneeth Prakhya Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 3/4] selftests/resctrl: Allow ->setup() to return errors Date: Wed, 8 Feb 2023 11:30:15 +0200 Message-Id: <20230208093016.20670-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-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,SPF_HELO_NONE, SPF_NONE 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?1757254866553445101?= X-GMAIL-MSGID: =?utf-8?q?1757254866553445101?= Currently resctrl_val() assumes ->setup() always returns either 0 to continue tests or < 0 in case of the normal termination of tests after x runs. The latter overlaps with normal error returns. Define END_OF_TESTS (=1) to differentiate the normal termination of tests and return errors as negative values. Alter callers of ->setup() to handle errors properly. Fixes: 790bf585b0ee ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest") Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 4 +++- tools/testing/selftests/resctrl/cat_test.c | 2 +- tools/testing/selftests/resctrl/cmt_test.c | 2 +- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- tools/testing/selftests/resctrl/resctrl.h | 2 ++ tools/testing/selftests/resctrl/resctrl_val.c | 4 +++- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 68ff856d36f0..0485863a169f 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -244,10 +244,12 @@ int cat_val(struct resctrl_val_param *param) while (1) { if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { ret = param->setup(1, param); - if (ret) { + 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; diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 1c5e90c63254..2d3c7c77ab6c 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -40,7 +40,7 @@ static int cat_setup(int num, ...) /* Run NUM_OF_RUNS times */ if (p->num_of_runs >= NUM_OF_RUNS) - return -1; + return END_OF_TESTS; if (p->num_of_runs == 0) { sprintf(schemata, "%lx", p->mask); diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 8968e36db99d..3b0454e7fc82 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -32,7 +32,7 @@ static int cmt_setup(int num, ...) /* Run NUM_OF_RUNS times */ if (p->num_of_runs >= NUM_OF_RUNS) - return -1; + return END_OF_TESTS; p->num_of_runs++; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 1a1bdb6180cf..f32289ae17ae 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -41,7 +41,7 @@ static int mba_setup(int num, ...) return 0; if (allocation < ALLOCATION_MIN || allocation > ALLOCATION_MAX) - return -1; + return END_OF_TESTS; sprintf(allocation_str, "%d", allocation); diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 8392e5c55ed0..280187628054 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -95,7 +95,7 @@ static int mbm_setup(int num, ...) /* Run NUM_OF_RUNS times */ if (num_of_runs++ >= NUM_OF_RUNS) - return -1; + return END_OF_TESTS; va_start(param, num); p = va_arg(param, struct resctrl_val_param *); diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index f0ded31fb3c7..f44fa2de4d98 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -37,6 +37,8 @@ #define ARCH_INTEL 1 #define ARCH_AMD 2 +#define END_OF_TESTS 1 + #define PARENT_EXIT(err_msg) \ do { \ perror(err_msg); \ diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 787546a52849..00864242d76c 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -735,10 +735,12 @@ 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); - if (ret) { + if (ret == END_OF_TESTS) { ret = 0; break; } + if (ret < 0) + break; if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { From patchwork Wed Feb 8 09:30:16 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: 54309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355889wrn; Wed, 8 Feb 2023 01:33:42 -0800 (PST) X-Google-Smtp-Source: AK7set/ZdYUsbzyTbvQs11WBbZxGrQvzaFy9NnfnuM6vJeXkOikEjX9xtxXckbFsIr2V5IBrvmS3 X-Received: by 2002:a05:6a20:e416:b0:bc:ce49:79a7 with SMTP id nh22-20020a056a20e41600b000bcce4979a7mr5027565pzb.18.1675848822023; Wed, 08 Feb 2023 01:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848822; cv=none; d=google.com; s=arc-20160816; b=bDxuF4SrqE180W25VUZ6uv+gX9XrMqBIuGtJW/ldrPJkxaMDPvkJJhZzFFcfRDXO07 akePl1nV2P+QhfsTCyjf8YjvLr/8iZ2FY3lba6tPdmWETRv00VE90H/z4iGD6g49wr60 fPkA6me1ro/otEsd56f65XOL1GZujFspocMEQLn8W2nAjTrZhFHaC/v9m14k9FaMzv9V QjMJwoPodCFsPIBhuXBRtuwPP95/FxehuhbMIZUrmCO4eGJAkTafqrqicH/8YyGjy8XV 3I3dGlRVcJ/EcCaPbniwiD2DO5qMf4Si+QRV50KO3LkCHpbuA7J3BrloPQWmHG276tIY HWlg== 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=WWziEUBiv2cNxkI7jhj0LDfn+uGaNzZzDKFUuFVFm68=; b=kAGU5R0biDc57UPQV+8spsQ/PDhqlx0+93m6ETFssd+9/uWsuJWSSY0tZEMPRXkRBZ nd7JB+eO4rcUsRwLBtpgvxqMKbhUegWBkoimD5rveUXzo+UvKOt/b1bUl5ZzgfgSRgwd /gu0xZwTgG0zyshwS0bgTv+IH+sT9UYuRpeR+e3lv4KGWuqUQH44w9pTviTSUfSlKcwt RwwhtXRtifUw5Qm9rKk+9cC/f0kFX1ISEXWlXXOVdjPQG1qpW8WhCV/KKiMEO72JK2+0 VhbT0woNCF1e7b0h+7emilyqVvpdZR4s2GL86Spk6S26siMadsDPlhaQnS8qQMwjD8HL gEeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b3tHZEIn; 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 m25-20020a638c19000000b004fabbf79150si14243716pgd.307.2023.02.08.01.33.29; Wed, 08 Feb 2023 01:33:42 -0800 (PST) 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=b3tHZEIn; 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 S230252AbjBHJcB (ORCPT + 99 others); Wed, 8 Feb 2023 04:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjBHJba (ORCPT ); Wed, 8 Feb 2023 04:31:30 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5973110D0; Wed, 8 Feb 2023 01:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848668; x=1707384668; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+bOX5BBL2eeaqq9jlV7GStORno+/xHgQmrDAzhBVJp8=; b=b3tHZEInbL1Y/IOeHZFaj6WNemZWaGaQYcLWplGAR9lHGpvYT9XH7bYC YL9ERzUOBGt5FrJnH9K3iAJwtVHmH7hlMQvPjLQOXTho2amSqtHL0rnO7 QJPrcWfzebx59+Emp+5GmXUdo/xLCvtCu6lZ5T0w8hJeAPODoFYz0LnLU RduwV99vStVg3lE0VAhlD6iAGvtXJPg7z98xcN/8iNU57cwRDCX/xYqA+ 71W6itIFKfS5GCVZ/VX3OQ0pQp1E+8zCTLInGZr0leQdk7kK5xjRlv61f EZZbZLu8n4lpIz7bN0Me6i8AyTE+girQwxeQwJtrwZ7tE5j0jxav9gYQK Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974570" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974570" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:41 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613971" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613971" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:38 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Babu Moger , Sai Praneeth Prakhya Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 4/4] selftests/resctrl: Check for return value after write_schemata() Date: Wed, 8 Feb 2023 11:30:16 +0200 Message-Id: <20230208093016.20670-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-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,SPF_HELO_NONE, SPF_NONE 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?1757254854510464989?= X-GMAIL-MSGID: =?utf-8?q?1757254854510464989?= MBA test case writes schemata but it forgets to check if the write is successful or not. Hence, add the check and return error properly. Fixes: 01fee6b4d1f9 ("selftests/resctrl: Add MBA test") Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mba_test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index f32289ae17ae..97dc98c0c949 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -28,6 +28,7 @@ static int mba_setup(int num, ...) 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 *); @@ -45,7 +46,11 @@ static int mba_setup(int num, ...) sprintf(allocation_str, "%d", allocation); - write_schemata(p->ctrlgrp, allocation_str, p->cpu_no, p->resctrl_val); + ret = write_schemata(p->ctrlgrp, allocation_str, p->cpu_no, + p->resctrl_val); + if (ret < 0) + return ret; + allocation -= ALLOCATION_STEP; return 0;