Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2059035rwi; Tue, 1 Nov 2022 03:24:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5fC2v6awzXf62qn10VeFy1j3JmgaxPay6dhLlZhMgbavuWbOQX6VXJBL+VRqDvKS/2Ne18 X-Received: by 2002:aa7:9687:0:b0:56d:a2e0:ea1e with SMTP id f7-20020aa79687000000b0056da2e0ea1emr6157459pfk.33.1667298245335; Tue, 01 Nov 2022 03:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667298245; cv=none; d=google.com; s=arc-20160816; b=wlWPOW9yF54BaY7zszCZaoXybSjcEqw1ae29LPjaxXMmiZGhainFYIK5vdNDTSrYB/ tYr3sRaK0GO61MYLj/9cmaJhWkmPboVefY9/xrsGPO3TKZ2TSbF/uLgOAvaCFXPAS0FY i5qJlLHie0xG84EeB9zr5RqgijaUv4B/9BxG9QLH1Dce3fizr07D5aVSoRPzdgkVUJnW kjDtuGDaDXba8G26HjNT0+YhAdVH95Hkl2uV/88lnriFNgGo6Ys4HXK4IaCMFUNffAO1 3YpcTGM1xggvtgebt89Mv4JSCaKUfZH1aogWsK94NyasWse7G+rDpJnKD5WAAhTK41Vc hOtA== 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=RyWPmAojykGQt+IzVEqpYO7N4CPZzUsUeEYXIHcNqHA=; b=RrskBaZg1xif/k03RtOP4xTWvkuKpr7WS6XfU3sLMfrUY+UPkVtPdNFSEKa7fa4bl3 8yA32Wf9YHXDAqi6qdZDXxxpJa8pxx9lRPplQ2WbjjMr+NodTIGZw9LjPFqpulZC1i6A 9u065gc7fTHBW+WCv5n1mWCRAaqfyRWbO47vhzv7OPZo9DqRCXaL8yY1gdT827AJ9amn fKf6O6+X+2/WX3ZLUl652vqm7NvdQThFBWFQePR0p9+V3LY8Wwjd/Ne58DfhQ7PRMnQX ORMjh29+rT6EdIW8pbsDbwE0EtauRaU70ISidJKizvgQPn8jXP4WqnrCRKeo1bBjcjQR 307g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk14-20020a17090b4a0e00b00212b9a2d735si13392651pjb.121.2022.11.01.03.23.51; Tue, 01 Nov 2022 03:24:05 -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 S230457AbiKAJt0 (ORCPT + 97 others); Tue, 1 Nov 2022 05:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiKAJsx (ORCPT ); Tue, 1 Nov 2022 05:48:53 -0400 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 073EF2EA; Tue, 1 Nov 2022 02:48:51 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="94348495" X-IronPort-AV: E=Sophos;i="5.95,230,1661785200"; d="scan'208";a="94348495" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP; 01 Nov 2022 18:48:50 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 689A810E8C; Tue, 1 Nov 2022 18:48:48 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 7F1C3D55EB; Tue, 1 Nov 2022 18:48:47 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id 6B43940164011; Tue, 1 Nov 2022 18:48:47 +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 Subject: [PATCH v3 3/5] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Tue, 1 Nov 2022 18:43:39 +0900 Message-Id: <20221101094341.3383073-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221101094341.3383073-1-tan.shaopeng@jp.fujitsu.com> References: <20221101094341.3383073-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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: 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]); -- 2.27.0