Message ID | 20231024092634.7122-2-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1819532vqx; Tue, 24 Oct 2023 02:28:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHh2qvFOaP+8UnK2W7hFs/XKzW3IiphcX2Ln70mRrDs1XAA+Rs5dOxFVF/VsqliK35mDfzl X-Received: by 2002:a05:6808:910:b0:3ab:843f:76fd with SMTP id w16-20020a056808091000b003ab843f76fdmr12767825oih.19.1698139685722; Tue, 24 Oct 2023 02:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698139685; cv=none; d=google.com; s=arc-20160816; b=UABlmiXsWW+UmnFm6cGTTJorEo3EN+8aLUMzWFYDqVcBBCZ5RNz8TR4hzjq6DGt+KZ E3TZoRUPnDzkTZxOhOmxWKGodBVE8sm3WO1YeeOTI+vnfbrzBOPnetL/9dAuWWSeZ8Zh 3fB1PlPJ9HU9dKqGguC8Pjb8rmoCA8nkjoyP1Gc8tnatqrdDbzkBrDqB2dcOIz3qDWJE qumvLzj1ABx0U9rHjp4yqZpnxubCWQWpttCjiSI8wjDHmzVJljByF1xk+LXX+rRNnEKP um7syTkAYqNPp7WjJp6NyEFIdEaTbhVFEEBf0ZAUp2wee9Sw1sF9Oy7Fu+HwTGKOxY+T fYhw== 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=EeVkC7n0FTQAo2uxO4Cs256xalKJH69zSMy7OWB7hbA=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=uLU15DJorziI6G2+nljXZU7yLPOFBY3s7SWuUWIx41RsJqFj7xZ8MCNXeF68qvMkiL 6jBDfXn4gWjCM+p0qMFf6U/XOclCk9WIliP+2wSkmJgnaYcosRMqwEwJ7pT/qNnb3wbs +elytd+3GlrYXvPGyrmE9uxhdiZdtXcuex6jrvJtb0SeG5rRWc30qHsa43jim4kM6cGP HmpQsUzzxDmsRVF13PLz2egKVfCdUp5b2atUAdepoJgqBP+8LDDmwPGBL3zwcC+r7bc7 t3gRiQf/5qYx2A4vZ/vVygYpt7Lbb711F49ZadXMP+li907XvhSYGe6NRxAakb/Q7bee LQbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i6+7XX4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h69-20020a636c48000000b005648d3f2031si7591491pgc.362.2023.10.24.02.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i6+7XX4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AC4B680569AC; Tue, 24 Oct 2023 02:28:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbjJXJ1f (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Tue, 24 Oct 2023 05:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234149AbjJXJ1V (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 24 Oct 2023 05:27:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 984771FE1; Tue, 24 Oct 2023 02:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698139618; x=1729675618; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JMN9aahDdQAcKor/PtXdQYhZXLxsC0uS+tKkhuZPS0s=; b=i6+7XX4KggrwIiaXnGqRjcB0BrTvLhTJdYbWiWrNMJ0/YRtg95uWHEt2 0WydlUJFDEyGi6SudwC4h3NvbNd+9VC5qkJbrOyg2UukpT/uVjlrXtnFn cTtu11M8Cv98Qt2jiEuLaJ/Ez5qfVTHG7mPemQgN5DOZenhCaZbAEie52 ieapV7ODL5O/3PRBkovwb17BFic151e/CDB6hJr2UgctjmjklBt+lJtVr 6WCDtbMWMbZBKRUAg+3m2QXq65YMRu3ZMQUuHRfNc7GkMaogvcmEC+66V Bs+nURVqwTXYbV6nmm1FdtGWODMi6nNjcAqNQuERroM8HZ10W9ocIHBwB A==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="8570095" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="8570095" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:26:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="708223418" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="708223418" Received: from hprosing-mobl.ger.corp.intel.com (HELO localhost) ([10.249.40.219]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:26:53 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: linux-kselftest@vger.kernel.org, Reinette Chatre <reinette.chatre@intel.com>, Shuah Khan <shuah@kernel.org>, Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>, =?utf-8?q?Maciej_Wiecz=C3=B3r-R?= =?utf-8?q?etman?= <maciej.wieczor-retman@intel.com>, Fenghua Yu <fenghua.yu@intel.com> Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> Subject: [PATCH 01/24] selftests/resctrl: Split fill_buf to allow tests finer-grained control Date: Tue, 24 Oct 2023 12:26:11 +0300 Message-Id: <20231024092634.7122-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> References: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 02:28:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780628518800370013 X-GMAIL-MSGID: 1780628518800370013 |
Series |
selftests/resctrl: CAT test improvements & generalized test framework
|
|
Commit Message
Ilpo Järvinen
Oct. 24, 2023, 9:26 a.m. UTC
MBM, MBA and CMT test cases use run_fill_buf() to loop indefinitely around the buffer. CAT test case is different and doesn't want to loop around the buffer continuously. Split fill_cache() so that both the use cases are easier to control by creating separate functions for buffer allocation and looping around the buffer. Make those functions available for tests. The new interface is based on returning/passing pointers instead of the startptr global pointer variable that can now be removed. The deallocation can use free() directly. This change is part of preparation for new CAT test which allocates a buffer and does multiple passes over the same buffer (but not in an infinite loop). Co-developed-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> --- tools/testing/selftests/resctrl/fill_buf.c | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-)
Comments
On 2023-10-24 at 12:26:11 +0300, Ilpo Järvinen wrote: >MBM, MBA and CMT test cases use run_fill_buf() to loop indefinitely >around the buffer. CAT test case is different and doesn't want to loop >around the buffer continuously. > >Split fill_cache() so that both the use cases are easier to control by >creating separate functions for buffer allocation and looping around >the buffer. Make those functions available for tests. The new interface >is based on returning/passing pointers instead of the startptr global >pointer variable that can now be removed. The deallocation can use >free() directly. > >This change is part of preparation for new CAT test which allocates a >buffer and does multiple passes over the same buffer (but not in an >infinite loop). > >Co-developed-by: Fenghua Yu <fenghua.yu@intel.com> >Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> >Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >--- > tools/testing/selftests/resctrl/fill_buf.c | 26 +++++++++++++--------- > 1 file changed, 15 insertions(+), 11 deletions(-) > >diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c >index 0d425f26583a..f9893edda869 100644 >--- a/tools/testing/selftests/resctrl/fill_buf.c >+++ b/tools/testing/selftests/resctrl/fill_buf.c >@@ -135,33 +135,37 @@ static int fill_cache_write(unsigned char *buf, size_t buf_size, bool once) > return 0; > } > >-static int fill_cache(size_t buf_size, int memflush, int op, bool once) >+static unsigned char *alloc_buffer(size_t buf_size, int memflush) > { > unsigned char *buf; >- int ret; > > buf = malloc_and_init_memory(buf_size); > if (!buf) >- return -1; >+ return NULL; > > /* Flush the memory before using to avoid "cache hot pages" effect */ > if (memflush) > mem_flush(buf, buf_size); > >+ return buf; >+} >+ >+static int fill_cache(size_t buf_size, int memflush, int op, bool once) >+{ >+ unsigned char *buf; >+ int ret; >+ >+ buf = alloc_buffer(buf_size, memflush); >+ if (buf == NULL) Maybe just do: if (!buf)? Checkpatch also seems to suggest this approach: CHECK: Comparison to NULL could be written "!buf" #65: FILE: tools/testing/selftests/resctrl/fill_buf.c:159: + if (buf == NULL) >+ return -1; >+
Hi Ilpo, On 10/24/2023 2:26 AM, Ilpo Järvinen wrote: > MBM, MBA and CMT test cases use run_fill_buf() to loop indefinitely > around the buffer. CAT test case is different and doesn't want to loop > around the buffer continuously. Please do not that the changelog starts by describing issue with run_fill_buf() (that does not appear in patch) and then switches to describe solution for fill_cache() below. > > Split fill_cache() so that both the use cases are easier to control by > creating separate functions for buffer allocation and looping around > the buffer. Make those functions available for tests. The new interface > is based on returning/passing pointers instead of the startptr global > pointer variable that can now be removed. The deallocation can use > free() directly. Seems like startptr removal has been done already: 5e3e4f1a03f0 ("selftests/resctrl: Remove unnecessary startptr global from fill_buf") Reinette
diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 0d425f26583a..f9893edda869 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -135,33 +135,37 @@ static int fill_cache_write(unsigned char *buf, size_t buf_size, bool once) return 0; } -static int fill_cache(size_t buf_size, int memflush, int op, bool once) +static unsigned char *alloc_buffer(size_t buf_size, int memflush) { unsigned char *buf; - int ret; buf = malloc_and_init_memory(buf_size); if (!buf) - return -1; + return NULL; /* Flush the memory before using to avoid "cache hot pages" effect */ if (memflush) mem_flush(buf, buf_size); + return buf; +} + +static int fill_cache(size_t buf_size, int memflush, int op, bool once) +{ + unsigned char *buf; + int ret; + + buf = alloc_buffer(buf_size, memflush); + if (buf == NULL) + return -1; + if (op == 0) ret = fill_cache_read(buf, buf_size, once); else ret = fill_cache_write(buf, buf_size, once); - free(buf); - if (ret) { - printf("\n Error in fill cache read/write...\n"); - return -1; - } - - - return 0; + return ret; } int run_fill_buf(size_t span, int memflush, int op, bool once)