From patchwork Fri Dec 15 15:04:51 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: 179373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9348707dys; Fri, 15 Dec 2023 07:15:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlfNvtFejJfcAxwVLmyi9vfYQLqIaPaZuie3ImjrrMTwF0tz4eCDeR1PZ/IJSXzSBtpSOR X-Received: by 2002:a05:6e02:17c6:b0:35f:71a9:19a5 with SMTP id z6-20020a056e0217c600b0035f71a919a5mr7868673ilu.8.1702653312056; Fri, 15 Dec 2023 07:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702653312; cv=none; d=google.com; s=arc-20160816; b=uAKwN/lhD1JuS3BMpiJHAmW7MMk4YPzPdk7oviiviQVxN0x7DujzBnLSu5wkbLS5Vi rNppGaPboWwwU5xeW8l54muaJCDpdBt+nUIE/4QNEeqiXltCfRz/VtEw0Kxbcw4OlNYM lbZcC/LRBhU2ierPNNeJ+BhcPdU48lrEVsSpXGGJqSa9Hw/LJ3sK+l11TM/wnTFLfLWj 41TaJrAtTcQeDozYRIH8dyJmsqvpJcULPI49iB/N65VJOgSgOH3RnPfQ94hCHnfIL+Fl Vss/F8ylB22yTMW9uaEW9q7zqlgXch2CMnRdfZFB4tlWSd7ARAFagupKSYHokJfA3CWb Et9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yV+ZVKE7F6kMJbWPl0915db9sup5Cuo8zRPe9EQKbi0=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=RFDThb8vuDgRrUNsIGaveWys6u0+2pQg05YokUr6N0MXEU3QbnASqSyevlqdzF/b/w GmrIHhlrJfBWxnDIs2R/y5eiAglFmITLiZsFJD7FHoav6uTZSYSUp7VRkiskTA0qtgYL gKb9fGbLXEryrLLwp8dUYeT7kvViA/yja0QiFnMbP769JrNlmgRrbTZMDONlleNjgx7o pB0BsN5ngwi4RxoIaykq/kbOObtVkG/MOUB35N5PLz+r2C1meDG8fLNM2/pGYEF6DcG1 wbh3MtzxRrEYfStx461nJ0D7E6/NGWbpwvVUGj5hcw4XJEISKyBGTCmnvjdKEa3BR7Bq vi6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=isSPg6en; spf=pass (google.com: domain of linux-kernel+bounces-1160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1160-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i3-20020a635403000000b005c1b5a2be77si12656711pgb.702.2023.12.15.07.15.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 07:15:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=isSPg6en; spf=pass (google.com: domain of linux-kernel+bounces-1160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1160-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EB820288933 for ; Fri, 15 Dec 2023 15:08:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 117543BB4C; Fri, 15 Dec 2023 15:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="isSPg6en" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F6239FF1; Fri, 15 Dec 2023 15:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702652828; x=1734188828; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vPpeVxwgKgA10NtRD0qnRLNR26RhoObWkXlHgTY7uYc=; b=isSPg6enCJSeivnkZJ0fzwMttvwppCYIrRcGNQa+QHaiYHde/kGHuy6v VWifvVcfMsMDdNpZwfjVKZbeBaqI0FxckhvCaMEwAX4yH7Qdrb5F4uwXe ZoPVqW8/AFYzBOxc44a0JZrVopi+xZpLnxZAUOIURsdnzNsDWR5IvsqND W2m8ki3VJIv6Z/co8bu4UlAijyTWd4RmEbbV8UKThmB20kVR3G1gFbCYh 8cpHaU9ogU13M6ZDBW7aOITThL2w+zM10WAQnFUUZzkFx5ccjZtOUJFsM 84sdFGVNhRVcOeGmsOLUUCaIYM/QNaMtXAReBeoTSq64U/b/QSNU6EsAz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="375433046" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="375433046" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 07:06:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="1021965781" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="1021965781" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.49.116]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 07:06:09 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?utf-8?q?Maciej_Wiecz=C3=B3r-R?= =?utf-8?q?etman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 05/29] selftests/resctrl: Split fill_buf to allow tests finer-grained control Date: Fri, 15 Dec 2023 17:04:51 +0200 Message-Id: <20231215150515.36983-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231215150515.36983-1-ilpo.jarvinen@linux.intel.com> References: <20231215150515.36983-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785361399423383919 X-GMAIL-MSGID: 1785361399423383919 MBM, MBA and CMT test cases call run_fill_buf() that in turn calls fill_cache() to alloc and loop indefinitely around the buffer. This binds buffer allocation and running the benchmark into a single bundle so that a selftest cannot allocate a buffer once and reuse it. CAT test doesn't want to loop around the buffer continuously and after rewrite it needs the ability to allocate the buffer separately. Split buffer allocation out of fill_cache() into alloc_buffer(). This change is part of preparation for the new CAT test that 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 Reviewed-by: Reinette Chatre --- v3: - Moved error printout removal to other patch --- tools/testing/selftests/resctrl/fill_buf.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 0f6cca61ec94..6d1d5eed595c 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -135,24 +135,34 @@ 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) + 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) { @@ -160,8 +170,7 @@ static int fill_cache(size_t buf_size, int memflush, int op, bool once) return -1; } - - return 0; + return ret; } int run_fill_buf(size_t span, int memflush, int op, bool once)