From patchwork Mon Dec 11 12:18:02 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: 176655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7002009vqy; Mon, 11 Dec 2023 04:20:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdMvHnd349oldO3paQ0rolzs339L3HTqnTFbDgRBMSiHCiXEWfdOrxi+hK1QKgGIoX5t89 X-Received: by 2002:a17:902:e789:b0:1d0:6ffd:8353 with SMTP id cp9-20020a170902e78900b001d06ffd8353mr1762132plb.94.1702297199829; Mon, 11 Dec 2023 04:19:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702297199; cv=none; d=google.com; s=arc-20160816; b=J+Jrk8lgm+o+obUGooQwQhNTVZu2Vpp7R4qAR/RYyLhhEGe+JN/yHuMoB7oZXysfQE 6A52ldpGa79z5Jcoj1sW2ZpHYbjqC2NCjF/pft8z1nTKx83LmCtNSmUEW5YFrByFwoUV ulsMTAoeN4DU+KgmZBBDTD/XsC+ELbBA9kHSDAQ6udANy/HQz9vZcQiVoNElYozmX5ca TukKczAFdaxZB4+4SIhv+9qdrChUfctebjx2ocBmhFGDwobWTXDt37tBcmKs+hJWDAtL rRJmKt0LZD/QU7nod6ZyHLlKe+9VA1IsOjqMCn/a0dcjU0HkB9zW4h20gnaz+m4U6YEY jtaQ== 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=yV+ZVKE7F6kMJbWPl0915db9sup5Cuo8zRPe9EQKbi0=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=RWLWG/iIJXd2MWP7kHgpcngcTgdei4FWxE0GE57wnzu7h0L6jU2q8s/msc7hXjxT1q ywo3JH6r/i9bP3x0+SpmNortbjRAI0sMwn9fioRbJWR2MfiLy7znX+w6zEhwHfx36Sc6 OtZ0nRRgqdZad0UaOrlcYulLQ1sqDIneUNtKRC4jozFeL/iVAStKYGxxMVWwp35SN/ba m27EbTYLeHAZxY2NWvozWHWtBqVlE+L4oIEJ39cuYcETvpQuATSIlVnCu7bqfvAEefdT A/AKuL45i4d0Qnub70Y4nMk/NSz9gwwtdkBg7IUoaQZObn1jTypMsH+lNvf8O1jBRxTM 0ykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MWGofS3J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id w15-20020a170902a70f00b001cfabbeeda5si1930999plq.291.2023.12.11.04.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:19:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MWGofS3J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 8040B805FBA6; Mon, 11 Dec 2023 04:19:56 -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 S1343523AbjLKMTb (ORCPT + 99 others); Mon, 11 Dec 2023 07:19:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234979AbjLKMTY (ORCPT ); Mon, 11 Dec 2023 07:19:24 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02A96121; Mon, 11 Dec 2023 04:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702297168; x=1733833168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vPpeVxwgKgA10NtRD0qnRLNR26RhoObWkXlHgTY7uYc=; b=MWGofS3JfsyAERaFVvnzMLRW36GS2qs8ENuC+PtNn6oFzjwNYwNR8fhb hPnpXJimUI+HvXRalsSVA4n9ZKCDJ4rswytL+zFmQs9J7LILbM3F4P/nf BQMnsUwvpUE1BSMbRlszMxaRYmu6GB06JaRekX6JHO5Eil2td2MMJOMXu FQF1dpZb+BcBtAzZ+c/AjVn3ISQAnyi8f72siCIjoUudE3jfJJzEVKZY/ fLMlP74ZnSqGEC5TkCAH4/VAbvh8iMrPoNEYsmm7mvSk0AI7xwigPK1+E NjNgY74VoRekpkPzxUT0cIkHJ5XfUGzmUuHVUyP2ZwWyJWFKC6YXYbjWg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="1757878" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="1757878" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 04:19:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="1104461108" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="1104461108" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.50.188]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 04:19:22 -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 v3 05/29] selftests/resctrl: Split fill_buf to allow tests finer-grained control Date: Mon, 11 Dec 2023 14:18:02 +0200 Message-Id: <20231211121826.14392-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231211121826.14392-1-ilpo.jarvinen@linux.intel.com> References: <20231211121826.14392-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, 11 Dec 2023 04:19:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784987988484440432 X-GMAIL-MSGID: 1784987988484440432 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)