From patchwork Mon Feb 13 06:24:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 56052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2200852wrn; Sun, 12 Feb 2023 22:32:08 -0800 (PST) X-Google-Smtp-Source: AK7set+/GffskZeX5Z3vJTqqN3Zh7QeOKt1ksOEVocAI2aDAkRVNeiI/881IVtTHuw6K2vHUi69p X-Received: by 2002:a17:902:da8b:b0:199:bd4:9fbb with SMTP id j11-20020a170902da8b00b001990bd49fbbmr29031161plx.43.1676269928607; Sun, 12 Feb 2023 22:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676269928; cv=none; d=google.com; s=arc-20160816; b=FYpusVonSvExMzPdibi87BUj4z7fll5r/5yZN336gWfcQ5/jdO+i5/x4JJ/01tJsXf vNE+fXsFd53yRNbMIaGI5RrazI1vZQxxVmDdkDI6Rx06Y0HTrCLCqYzKVqqI4YE0wczw JNHMVlz3TBwxCXcPXJjHzzGeZm2pdpTv04E1HAhcwNS0bzfHJ7eqAQTdTarIZnEbi/MS NfkcuMHSQDhlDkGqTB1YiiuUPjReNRDLUGwdmbbHvjJL8/1vT1y4NJZPZJcyCjyjpIGq dlVWTr5BItNB+U63/bglNQbNr6RVyuLnl92G/wAJhXJXDbN6CJf2OmaEmx7QUFqznYNS TPMQ== 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; bh=RjAUSPDbrjqL+ZLCB8tfzB84CWFLe7V4Zlb51S559KY=; b=hYdp0QwEyctI1mNru8g4LBTJV5wYds/ocQ9hYftSOZYHw9t5hIPUzOGi+42RTrAK7Z Y8oLe2xEnSPsyz5fSPdyrNKJb7lDrmxKG7ogWfMJULMdyWbfaA1oKJfpsxXnYa4UyJsv nHGmQl/B3wTFHVtb6YoURr2jFbPhh+xKj+3hKWwL6ulwlgFN/e0Th/Zb2hAOPY/83fHb vUMu54RpzS/85edGW3FUKtGtsDdhv3ScWyEt0QhBnxs7seFJF7fUeq+PMqMLGELv+j+1 2+h9hmt//hNYe1McRkZFcV4dondxIPYUgCvEYqV3UUI/iB5OR5PctzKO4BlKERJ6Vz93 yNvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a170902db0b00b00199213a3c67si12200500plx.606.2023.02.12.22.31.56; Sun, 12 Feb 2023 22:32:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjBMG2w (ORCPT + 99 others); Mon, 13 Feb 2023 01:28:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjBMG2o (ORCPT ); Mon, 13 Feb 2023 01:28:44 -0500 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD29C1117D; Sun, 12 Feb 2023 22:28:33 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="94675138" X-IronPort-AV: E=Sophos;i="5.97,293,1669042800"; d="scan'208";a="94675138" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 15:28:31 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id D2C55E4459; Mon, 13 Feb 2023 15:28:28 +0900 (JST) Received: from yto-om1.fujitsu.com (yto-om1.o.css.fujitsu.com [10.128.89.162]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 393EDD3F06; Mon, 13 Feb 2023 15:28:28 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om1.fujitsu.com (Postfix) with ESMTP id 0B0D7404AF893; Mon, 13 Feb 2023 15:28:28 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com, Shuah Khan Subject: [PATCH v7 3/6] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Mon, 13 Feb 2023 15:24:25 +0900 Message-Id: <20230213062428.1721572-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230213062428.1721572-1-tan.shaopeng@jp.fujitsu.com> References: <20230213062428.1721572-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757696416571711360?= X-GMAIL-MSGID: =?utf-8?q?1757696416571711360?= When a process has buffered output, a child process created by fork() will also copy buffered output. When using kselftest framework, the output (resctrl test result message) will be printed multiple times. Add fflush() to flush out the buffered output before executing fork(). Reviewed-by: Shuah Khan Reviewed-by: Reinette Chatre Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 1 + tools/testing/selftests/resctrl/resctrl_val.c | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 1 + 3 files changed, 3 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 1c5e90c63254..6a8306b0a109 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -167,6 +167,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) return errno; } + fflush(stdout); bm_pid = fork(); /* Set param values for child thread which will be allocated bitmask diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index b32b96356ec7..6948843bf995 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -629,6 +629,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) * Fork to start benchmark, save child's pid so that it can be killed * when needed */ + fflush(stdout); bm_pid = fork(); if (bm_pid == -1) { perror("# Unable to fork"); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 8546bc9f1786..d95688298469 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -678,6 +678,7 @@ int filter_dmesg(void) perror("pipe"); return ret; } + fflush(stdout); pid = fork(); if (pid == 0) { close(pipefds[0]);