From nobody Thu Jan 1 10:40:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EB0DC00A8F for ; Tue, 24 Oct 2023 09:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234158AbjJXJ1g (ORCPT ); Tue, 24 Oct 2023 05:27:36 -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 ); 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=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Fenghua Yu Signed-off-by: Ilpo J=C3=A4rvinen --- 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/sel= ftests/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; } =20 -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; =20 buf =3D malloc_and_init_memory(buf_size); if (!buf) - return -1; + return NULL; =20 /* Flush the memory before using to avoid "cache hot pages" effect */ if (memflush) mem_flush(buf, buf_size); =20 + return buf; +} + +static int fill_cache(size_t buf_size, int memflush, int op, bool once) +{ + unsigned char *buf; + int ret; + + buf =3D alloc_buffer(buf_size, memflush); + if (buf =3D=3D NULL) + return -1; + if (op =3D=3D 0) ret =3D fill_cache_read(buf, buf_size, once); else ret =3D fill_cache_write(buf, buf_size, once); - free(buf); =20 - if (ret) { - printf("\n Error in fill cache read/write...\n"); - return -1; - } - - - return 0; + return ret; } =20 int run_fill_buf(size_t span, int memflush, int op, bool once) --=20 2.30.2