From patchwork Thu Apr 13 07:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 82836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp847750vqo; Thu, 13 Apr 2023 00:25:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bpcquD65x83X/RILDCxm016kLNoNRr0ahBodtcJnHU5REhs8SmxPJIpwKn1xvqJUbEQmU3 X-Received: by 2002:a17:906:7f98:b0:87b:6bbb:11ac with SMTP id f24-20020a1709067f9800b0087b6bbb11acmr1510759ejr.60.1681370759168; Thu, 13 Apr 2023 00:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681370759; cv=none; d=google.com; s=arc-20160816; b=O/81rDGjAi5zt3qYyhbZNoZNv+m4zrjbElx3JXaePpcScDtJ7f5vWPTNcfqSznG+00 K4mpgIhSJ3GqL4QWU99TfxE92BGO6flNKTJtUkA4orAoINA54EMvnVP5c9XYhxzcuNRB 60edXiH8wdkdnBv34HHF/LuLUaxstNLM3MM760MAmlc77iWd8h53n7IqD1y/EYGbts5N bQmcPBO8n72TsfWiNGi9ZkrigvsggpbGPVcau+XcFJXEq++Tm2AzT7LLCpo7q919NthV iwjVji7KD0sGni8532fnJb53uvVQ/rMukPJhqShsTucVrJNflWce8DkpZyh7jrWpJP8A id0g== 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=z9EN6EGd1MyzSHaTq+/3nqK06YP72xXEZjHitcANOYU=; b=Kz5j/HJw+U2sHiHuhV26cVw8nLHtZg5/6wSsX6A54D8XUJn6Rys/RY/lJ5nJHi4yxx iZ2Kx3UnT8MUo/e1vJXFTSoPFzN779P3GI7QkYAKLB4CZyVOKxYOH8CQvPp3i4GEA867 0cNPJQg25M8nwRJdVD0aeoDosXTC5r86Li0BRTfzcIQsaGUlf3g4h2rHF/4ZU40n8pee 2j77KnmeGpvvhThxchvpX7cPRM0h4ExzNlK2N9kI26M1yGWcEcVyo+cQh391XyZMDtNY 5s2fNK0DE0zXfhMKhDgKjNa2lhbjExf+rLbCHpWszgQepjY8RgbTrFEGEspBAEWBSKDH j68A== 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 o11-20020a1709062e8b00b0094e89de648asi1065150eji.778.2023.04.13.00.25.34; Thu, 13 Apr 2023 00:25:59 -0700 (PDT) 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 S229866AbjDMHXK (ORCPT + 99 others); Thu, 13 Apr 2023 03:23:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjDMHXH (ORCPT ); Thu, 13 Apr 2023 03:23:07 -0400 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8262A4C3C; Thu, 13 Apr 2023 00:23:06 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="91996438" X-IronPort-AV: E=Sophos;i="5.98,339,1673881200"; d="scan'208";a="91996438" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 16:23:03 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 7DCBCD66A1; Thu, 13 Apr 2023 16:23:01 +0900 (JST) Received: from yto-om3.fujitsu.com (yto-om3.o.css.fujitsu.com [10.128.89.164]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id C6F9FD35F7; Thu, 13 Apr 2023 16:23:00 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om3.fujitsu.com (Postfix) with ESMTP id 8BBF840007204; Thu, 13 Apr 2023 16:23:00 +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 v9 3/6] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Thu, 13 Apr 2023 16:22:56 +0900 Message-Id: <20230413072259.2089348-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230413072259.2089348-1-tan.shaopeng@jp.fujitsu.com> References: <20230413072259.2089348-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?1763045024940081333?= X-GMAIL-MSGID: =?utf-8?q?1763045024940081333?= 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 08070d4fa735..38c10a8c1814 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 00864242d76c..e632657995c7 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 b31b1d9e41d1..fb00245dee92 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]);