Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3830468rdh; Fri, 29 Sep 2023 03:50:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQmpV47jYEmQ2AZS/Et8xgK1ERTL/EDQa9hgs9BP9xxoC+JtBPcOACWRYAexYA5uCQEDtX X-Received: by 2002:a05:6a20:13c6:b0:14b:ee48:85b4 with SMTP id ho6-20020a056a2013c600b0014bee4885b4mr3487908pzc.60.1695984634382; Fri, 29 Sep 2023 03:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695984634; cv=none; d=google.com; s=arc-20160816; b=oXC2MuEpej5btoWLbMzaIzis3EPU6KgCGcm5C4j/92Xkq+D10MT8iHaz3gvu5a6dK/ X+DgM9mXcKOhZJz2el+gCXASq0++wk+np/D6XiwljqtYhahccjYU5O5G9ZMxNQfkyGou 2HMsjE9aQx+o5dz2+aNFvtMitzy++pLPyfE2CNZ3zy/ukp2Ptzj2b7g03JekXoAG2uXU 37rGRKeqE+9f5Gd5KwJM3e0foCUzHRKbhGAAByZ05rJPs/tJXPLbZ+oYAEyvZTvrkxtP GgM57W0EsmVetMlyF0BmesDVPB+mEJh7bPuaLyCvjVz0fJnMtGJUgkh3wTlja0gnjvoJ zeSw== 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=8WFFQ9KoxZ7z086mHw6Qwh/7vWFap+rBuNzxDF6d/oY=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=m2s9HHD2TOEhygiaB22mfxYMpSu+BLljAXTqbRZ0ltREO6U24EcSK1tJELzM3Opy/0 Cta+/XQIfcfxQ+Tz0GxPdpkV/PoaUHo9jv96ByM0FVRaLI3BCdcxILhpN5fGYbsh1arQ B0J+cnhrJvCPBW/rvjQvJFV8y0yMVTMYACrvqf5JbqNZLQpTz8BSkH8h0HjcS+ljzNUI HDxqdOxpZQg3UaQI37/CxqGpplleqaha3KX3J28faZhmhYqWIrYBgUyzRIBBRNW8lz/A qXSn+JZuEMiMKMpa8qD+su2xaYpX1VTXrIoR2+5o+VzMsuCr68Eyso+MneAWrelJ4OXG 2alQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GeOnHA1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id eb17-20020a056a004c9100b00690158afc78si21071194pfb.284.2023.09.29.03.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 03:50:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GeOnHA1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 3B11C82B4DC8; Fri, 29 Sep 2023 01:32:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232851AbjI2Ibd (ORCPT + 99 others); Fri, 29 Sep 2023 04:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjI2Iba (ORCPT ); Fri, 29 Sep 2023 04:31:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1261AE; Fri, 29 Sep 2023 01:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695976288; x=1727512288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PpM3zZkxJD1zLq2YlRs46MrA+Nb1yQ8pa7Hs4HrAios=; b=GeOnHA1FE35gvTp4GGmsjdzz99oJbnXAU23GDLAE+7g44cKSmgsBe2zx CK2k7rYlNQvJOnxN82E+QaspMtiAAsLYSaiahy+Cf+bqysoRk3cgqUTOY qcUu+hExeX5/tuPnZnBXeHGjONCB1LFBf8TN10ie3sPBa8nhA5g4hrKyg Dti6JGu8bPOOWUKQKN6g5RQO5TsHAitz2Lj8idJwUfDWlGrBiFL1iFkyh 50P4Gt8VCjViXq9e8AXmMc1vpJ47Z8qdYKAFl6/Ty92F+qvWftCStSfh5 VcC8Xr8yWklF+14NORYp+jgDKTgaj1hr4lGMBZYC0FrrxnVq++tl4pQ1X Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="381144408" X-IronPort-AV: E=Sophos;i="6.03,186,1694761200"; d="scan'208";a="381144408" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 01:22:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="865622705" X-IronPort-AV: E=Sophos;i="6.03,186,1694761200"; d="scan'208";a="865622705" Received: from tzebrows-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.26.85]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 01:22:20 -0700 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v5 2/2] selftests/resctrl: Move run_benchmark() to a more fitting file Date: Fri, 29 Sep 2023 10:21:42 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 29 Sep 2023 01:32:01 -0700 (PDT) resctrlfs.c contains mostly functions that interact in some way with resctrl FS entries while functions inside resctrl_val.c deal with measurements and benchmarking. run_benchmark() is located in resctrlfs.c even though it's purpose is not interacting with the resctrl FS but to execute cache checking logic. Move run_benchmark() to resctrl_val.c just before resctrl_val() that makes use of run_benchmark(). Make run_benchmark() static since it's not used between multiple files anymore. Remove return comment from kernel-doc since the function is type void. Reviewed-by: Ilpo Järvinen Reviewed-by: Reinette Chatre Signed-off-by: Maciej Wieczor-Retman --- Changelog v4: - Reword patch message very slightly. (Reinette) Changelog v3: - Make run_benchmark() static and remove it from the header. (Reinette) - Remove return void kernel-doc comment. (Ilpo) - Added Ilpo's reviewed-by tag. tools/testing/selftests/resctrl/resctrl.h | 1 - tools/testing/selftests/resctrl/resctrl_val.c | 50 ++++++++++++++++++ tools/testing/selftests/resctrl/resctrlfs.c | 52 ------------------- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 8578a8b4e145..a33f414f6019 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -86,7 +86,6 @@ int validate_bw_report_request(char *bw_report); bool validate_resctrl_feature_request(const char *resource, const char *feature); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no); -void run_benchmark(int signum, siginfo_t *info, void *ucontext); int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val); int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index a9fe61133119..0577e983067a 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -625,6 +625,56 @@ measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start) return 0; } +/* + * run_benchmark - Run a specified benchmark or fill_buf (default benchmark) + * in specified signal. Direct benchmark stdio to /dev/null. + * @signum: signal number + * @info: signal info + * @ucontext: user context in signal handling + */ +static void run_benchmark(int signum, siginfo_t *info, void *ucontext) +{ + int operation, ret, memflush; + char **benchmark_cmd; + size_t span; + bool once; + FILE *fp; + + benchmark_cmd = info->si_ptr; + + /* + * Direct stdio of child to /dev/null, so that only parent writes to + * stdio (console) + */ + fp = freopen("/dev/null", "w", stdout); + if (!fp) + PARENT_EXIT("Unable to direct benchmark status to /dev/null"); + + if (strcmp(benchmark_cmd[0], "fill_buf") == 0) { + /* Execute default fill_buf benchmark */ + span = strtoul(benchmark_cmd[1], NULL, 10); + memflush = atoi(benchmark_cmd[2]); + operation = atoi(benchmark_cmd[3]); + if (!strcmp(benchmark_cmd[4], "true")) + once = true; + else if (!strcmp(benchmark_cmd[4], "false")) + once = false; + else + PARENT_EXIT("Invalid once parameter"); + + if (run_fill_buf(span, memflush, operation, once)) + fprintf(stderr, "Error in running fill buffer\n"); + } else { + /* Execute specified benchmark */ + ret = execvp(benchmark_cmd[0], benchmark_cmd); + if (ret) + perror("wrong\n"); + } + + fclose(stdout); + PARENT_EXIT("Unable to run specified benchmark"); +} + /* * resctrl_val: execute benchmark and measure memory bandwidth on * the benchmark diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 342a3dbcdbb6..385983b5c9ce 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -294,58 +294,6 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no) return 0; } -/* - * run_benchmark - Run a specified benchmark or fill_buf (default benchmark) - * in specified signal. Direct benchmark stdio to /dev/null. - * @signum: signal number - * @info: signal info - * @ucontext: user context in signal handling - * - * Return: void - */ -void run_benchmark(int signum, siginfo_t *info, void *ucontext) -{ - int operation, ret, memflush; - char **benchmark_cmd; - size_t span; - bool once; - FILE *fp; - - benchmark_cmd = info->si_ptr; - - /* - * Direct stdio of child to /dev/null, so that only parent writes to - * stdio (console) - */ - fp = freopen("/dev/null", "w", stdout); - if (!fp) - PARENT_EXIT("Unable to direct benchmark status to /dev/null"); - - if (strcmp(benchmark_cmd[0], "fill_buf") == 0) { - /* Execute default fill_buf benchmark */ - span = strtoul(benchmark_cmd[1], NULL, 10); - memflush = atoi(benchmark_cmd[2]); - operation = atoi(benchmark_cmd[3]); - if (!strcmp(benchmark_cmd[4], "true")) - once = true; - else if (!strcmp(benchmark_cmd[4], "false")) - once = false; - else - PARENT_EXIT("Invalid once parameter"); - - if (run_fill_buf(span, memflush, operation, once)) - fprintf(stderr, "Error in running fill buffer\n"); - } else { - /* Execute specified benchmark */ - ret = execvp(benchmark_cmd[0], benchmark_cmd); - if (ret) - perror("wrong\n"); - } - - fclose(stdout); - PARENT_EXIT("Unable to run specified benchmark"); -} - /* * create_grp - Create a group only if one doesn't exist * @grp_name: Name of the group -- 2.42.0