Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1763095rda; Tue, 24 Oct 2023 02:27:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnd4ntWGI0eKaofuY41GR1yRDbhcCLgciAeBvZEYR0iWuHG/DpvWaSYBt4kKwk44L179ry X-Received: by 2002:a17:902:c941:b0:1ca:dec8:c58d with SMTP id i1-20020a170902c94100b001cadec8c58dmr6127811pla.63.1698139668817; Tue, 24 Oct 2023 02:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698139668; cv=none; d=google.com; s=arc-20160816; b=hSzi1ZYFKLEI6AWoIwqmwTJ2UPFZgP1frSlpHotyROC09xwsTYXQRTrw3t26ByCYTx 3sNCBv1Elul2xRRI5A+WbZaIa0I106fQR63cp16OrcdvcD85qRS3s9dMxwiaKicQgOA7 kwC4cjmeg4irOsI+03dIF4kyupdhNteIFlX6U4jh8TpbChqze/ljQZ0q7AeyU0AQfhWa lr1EAa5q3XFpOBZhA5YzzyZLSgHWCheb0jRcfq+b47Tv278AIWB0mQGmOoNpQb7ox8E9 poW9p3F5Qx4+smWw6SXnWw6l596ZQQvSJsfCuJaD5S2ck84nPcooVS/K3A4qNHR6sqrl dLww== 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 Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j16-20020a170902759000b001c6189eaaebsi7748420pll.186.2023.10.24.02.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:27:48 -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 BAB3E8056995; Tue, 24 Oct 2023 02:27:45 -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 S234208AbjJXJ1e (ORCPT + 99 others); Tue, 24 Oct 2023 05:27:34 -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: 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: 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:27:46 -0700 (PDT) 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ärvinen --- 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) + 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) -- 2.30.2