Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1285606rwb; Tue, 4 Oct 2022 19:15:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM657nooWXUABt//K5Y5plN4mKhSxn11mLbkCxupxIhjXNwm42UhVddzgnUXlsOHKVIhpAdT X-Received: by 2002:a63:f556:0:b0:44e:12bf:2dd8 with SMTP id e22-20020a63f556000000b0044e12bf2dd8mr11932770pgk.400.1664936116659; Tue, 04 Oct 2022 19:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664936116; cv=none; d=google.com; s=arc-20160816; b=woCzk5/hdDBEj3nBq83VMYrv+8la/ibu4vuOje1EO6GH6sy6w7SUSAj41mzLrR3Ire cli//+TTeUEckyoMIo6pdqdlm1VjIC9+OI3sU5jxHzdPS9qH6J7FCX9uI2JvIWJrs0oV tKZH1J2iQZf18noE3YBsKGQVlehjXqYbGjNUaudwW9Mytn+hoBRoNMSBrIf/FnS6q0lB BqF5TkhzKZfsa5lFu9EU1/maL5NmsY/m+NUeOwzCTMOUU00TAGm7kh+BKN6axT3XEfTl IkDTfEROQz/ouWKBosf/SA49ty/2XWyDXgKSlVmDGWZEQNVRElOjzcemQ3CFXTyA2sp9 gKsQ== 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=QblKEwgNwNBjaotHn3o+Jj3MMpBSTh57YvC6HsP22Kc=; b=apnXeoL0wTVEcx+xnAvSxanAc8hTbSuioCmtiThtMGGZeLO0J45dQvKCfN86ESV9ss IZdLhHu2v27hgyu/vVjgiiEQFjdu1VU48dIylYi2H7tPOWls4y3sXVChxl4UHPJgwFFk trPfv8c4KQjbg6p8Owg3F6zHPzJlAhgUTz9j96+B84RhMe4zTs0aUy7jpQVOoNm9SN4b RVg8pwKtdDv9yJJH5QBQjYMFykPvSBAEf2rBpkA/83KfL/uwC5AHrjJUjAF18T2Z5+kT u1AUKUxDxDKbVcR0fPnpl9FUD8lMFCG1BzD0bAmJ6BQM0iZZDCFOCx33p8iLNP9GI21W 62Gw== 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 t20-20020a170902dcd400b0017a0a2e40e6si9857811pll.159.2022.10.04.19.15.04; Tue, 04 Oct 2022 19:15:16 -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 S229770AbiJEBo5 (ORCPT + 99 others); Tue, 4 Oct 2022 21:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiJEBox (ORCPT ); Tue, 4 Oct 2022 21:44:53 -0400 Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C859912D14; Tue, 4 Oct 2022 18:44:49 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10490"; a="70500946" X-IronPort-AV: E=Sophos;i="5.95,159,1661785200"; d="scan'208";a="70500946" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP; 05 Oct 2022 10:43:43 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 128CADA68A; Wed, 5 Oct 2022 10:43:42 +0900 (JST) Received: from yto-om1.fujitsu.com (yto-om1.o.css.fujitsu.com [10.128.89.162]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 4F806D9940; Wed, 5 Oct 2022 10:43:41 +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 1C0F0405D4705; Wed, 5 Oct 2022 10:43:41 +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 v2 4/4] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Wed, 5 Oct 2022 10:39:33 +0900 Message-Id: <20221005013933.1486054-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221005013933.1486054-1-tan.shaopeng@jp.fujitsu.com> References: <20221005013933.1486054-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 6f543e470ad4..c7447cd2a25f 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -676,6 +676,7 @@ int filter_dmesg(void) perror("pipe"); return ret; } + fflush(stdout); pid = fork(); if (pid == 0) { close(pipefds[0]); -- 2.27.0