From patchwork Wed Jan 11 07:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 41808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3187572wrt; Wed, 11 Jan 2023 00:02:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsgbIszZaOYWz4wy3E7JHacM9G+WUGP6h6G9zvZTofk4C/b3q9ZinEcr+FmD8zYL18NvDoA X-Received: by 2002:a17:906:910:b0:7ad:aed7:a5da with SMTP id i16-20020a170906091000b007adaed7a5damr74438144ejd.28.1673424173618; Wed, 11 Jan 2023 00:02:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673424173; cv=none; d=google.com; s=arc-20160816; b=ZsYO9n7MNjcQ+KO5NG+YMeFwsQ21Oj12DcWPgWol7cHVC3M2mr0peOtIsOVwck3bqn vH0+FP6ZSz9b6Tqod0IlmIy5rLUBEbF+ZpRjW4q6f3fExId0qTZv5m4ZyPOIVzuNijDn jz+ewtbMMvcSFhuHHLaKVP0VCvCJfvI4H6V6hC13Q8UYAp272x5nHUuxrLkhQXiUX5xW KMgiNgMXBDzIza2gvlkrVwWXweEN5hvT9UJZtFmBqNvNpgKDJS++cRLZFfbS4Uu5wwbk 5ijsmbyrW/zo7CnXhqFtQMahPsOdsgxzXD4pR39LQ1AOf9NVElyGYp1+Ve+YSGCKZagG HLaQ== 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=J0w4468Wi9V0DiE0lbhonwSNCbMyDDB9gf80MoDOdFLYGEkC30UBoE08UCd6LYxUgR /PnIRNwQbVuhuWCnE8bbDhng86/ORcZIJOJ408RZAEsB9JWy5jfnmz2Vn3EwgnyhXaRV IQ7ivSNtMUudbg7BT4yOGz38cXn7geMZxgdQxsd4M6ydH0tQE2IvkV502V4xUBhWKqO3 Pw4m+DCNHuIFdjq/0b2+ge63QcaE90pb8sFxvcKWiYCx+fg24CQ5Gc+1g/IYztnEdbT+ y5rLqiSI8CeVSPneeiwMlw62CRzXbr1+rfuJg9/0WieDcfvUhvfBYDXuuNYiHAJI3bAn bYkQ== 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 xe10-20020a170907318a00b007c0a7286bc3si3271109ejb.741.2023.01.11.00.02.30; Wed, 11 Jan 2023 00:02:53 -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 S232323AbjAKIAt (ORCPT + 99 others); Wed, 11 Jan 2023 03:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbjAKIAi (ORCPT ); Wed, 11 Jan 2023 03:00:38 -0500 X-Greylist: delayed 64 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 11 Jan 2023 00:00:36 PST Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9C4C312 for ; Wed, 11 Jan 2023 00:00:36 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="102257766" X-IronPort-AV: E=Sophos;i="5.96,315,1665414000"; d="scan'208";a="102257766" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP; 11 Jan 2023 16:59:30 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 5DC1CD66A0; Wed, 11 Jan 2023 16:59:29 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id BB47C16E53; Wed, 11 Jan 2023 16:59:28 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id 940854007B0E5; Wed, 11 Jan 2023 16:59: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 v5 3/5] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Wed, 11 Jan 2023 16:58:00 +0900 Message-Id: <20230111075802.3556803-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230111075802.3556803-1-tan.shaopeng@jp.fujitsu.com> References: <20230111075802.3556803-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?1754712426362189422?= X-GMAIL-MSGID: =?utf-8?q?1754712426362189422?= 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]);