From patchwork Mon Nov 20 11:13: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: 167058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2124374vqn; Mon, 20 Nov 2023 03:14:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFR5uIGPRCkpBcOBGlXSuMhdA434B19IhO9DvmcGeB/AGAAooe2cXSENXC+uA+49TTMwbla X-Received: by 2002:a17:902:e84c:b0:1cc:4e9f:d27 with SMTP id t12-20020a170902e84c00b001cc4e9f0d27mr5983704plg.1.1700478886092; Mon, 20 Nov 2023 03:14:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700478886; cv=none; d=google.com; s=arc-20160816; b=LKzKIq+GYDKI3sw9BFYaMUEWOwmu+8g4hMEa4oeatDQva0yQxuDFve5s6S5T3lbx+k BJqgKPwro96XOVr9TDO65utcZNmTk/3AYnTVMCU+K3aUQ2Qqt08pZGfP5bAAjeozK1zi XMdKv8DDv2i9dnmTmramZj6NP1W1ZuSoUgvcwcu0AFME67xEl/qD9mhRZM5mKyk6Mk6H wLjUIYi8jUOSyKKlEEc8j/9lXGJkgG91lymJDmuT7Wpdkchvjer34amgH/lp2nAgFbcv qHxGUyn/YTHR+jq4wb3DnLeagyEoIoSRmoKsVNY2reeDA6r+qGq2mmvdtFya38ZbnL4i 0JNQ== 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=rnVWenDYgCgMmOQNiMn4g2o3JGZ0RngdRgemgjvhmHU=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=mx4caqej89NgJc128X3AtI3onCKKF5qV4lQChgfkzdcCr5K2DU3chQ8NhCQ6urmeYi 3oon0Lg73cHBsTrwT9ODEvCOnoGAvrSWz+oE8klS+weD/dmfuomv+PVTHoVYagc4qqjd iiG/flCad4fSUajzDotncm417I3bdKkifcgpqLC8IMLipK4SxNU9zbTBkMtW4qTpPcIH EaveQ9oifQ8YeqteGewFfRFwY4Ppe6Q2qQtZHWI7bdXZSsSJcWgVwmff0EljKPWG7OT+ mThSj++XFwYO0ZIKHMgSBviDN875Eik0HOEM0tlkqFsOiEI49u1H0Qgs65CcSh52l0xA 4P3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=la5ILu7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s5-20020a170902ea0500b001ce16042690si8148826plg.323.2023.11.20.03.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:14:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=la5ILu7z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id A4AAF8045C57; Mon, 20 Nov 2023 03:14:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232753AbjKTLOR (ORCPT + 27 others); Mon, 20 Nov 2023 06:14:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbjKTLOO (ORCPT ); Mon, 20 Nov 2023 06:14:14 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F88C5; Mon, 20 Nov 2023 03:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700478850; x=1732014850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3w5YPzsrJAtu6IwpvvctKCS09dxA4ulRia909xdQq0U=; b=la5ILu7z2kI+O0YnwUFjV367xdIWwGBKkFAvBJK1vtUm2gfsJchhlv0Q TOV+14I5QGLQQ4B0xvMRZPC657r1o0q+4RVMVvb3TbidSL9a/N3ogj9WG n7UwVAjH0r5EcCrafjRFFT3oH1czVC/9CHizhwhb8hzSl2bJQ4Plk922+ 8sAtY7/9o+0KAqjz9yJgAsnRNvafcRw9AI90FrNNWFRVfxMKtR7rzM3zU yYShPPY/qxEhiC02/I3k9hxURFmYeNchad3dypR7UC05ub4sMpkJ+ROqo 21SInO7uk6UlWpqFntQWptOQbsJazDAruNIj+R+jGG4eDmVj3HPHBvhgt A==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="458095860" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="458095860" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:14:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="716179264" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="716179264" Received: from sc9itsct4906.amr.corp.intel.com (HELO localhost) ([10.249.46.107]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:14:07 -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 v2 02/26] selftests/resctrl: Split fill_buf to allow tests finer-grained control Date: Mon, 20 Nov 2023 13:13:16 +0200 Message-Id: <20231120111340.7805-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> References: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:14:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783081348710552090 X-GMAIL-MSGID: 1783081348710552090 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 --- 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..6f32f44128e1 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) + 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)