From patchwork Tue Nov 1 09:43:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 13604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2857566wru; Tue, 1 Nov 2022 03:03:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wiPMpLMUQ7FfmKwHn+AMUmM2K6+VZwQwRPj/dJwN9A7kcU5d4lygeLl8WiASI95XxpPXv X-Received: by 2002:a17:902:d4c1:b0:186:e426:ff12 with SMTP id o1-20020a170902d4c100b00186e426ff12mr18551303plg.132.1667297005896; Tue, 01 Nov 2022 03:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667297005; cv=none; d=google.com; s=arc-20160816; b=uv+/LL3er8mY+pxgx5xVQfr4e1HlDhWaRSi2e45Pyck0JaZ1gzXQtumEogcMIIF22t 8hle0ezQvJtJ7CHSHXkoF+y6oR+Fe66ePSHKLrpWCI/cR/cxHutnQhvgEQjAGXRRY0aD fnWZrfJSBgSl+kVkRbd5flWB4KjL3Dy5bVEI1ofrQGTCqHb7poYEq22CWe3jWS2vMOaC xHKFg9sCg/wdHggLdlYDj3egn6neuMSGAoIXkoGHjcZa1llBwiU4w1X9J8M699eD6+xY Xu5Pk759EjG+RlBJTWyJRyLB1+ubiSon6u6Fbn9/yg57giJ/yZYMJojhmS8ldn0non9z oGRQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a056a00170600b0056c8da80bfcsi13798344pfc.351.2022.11.01.03.03.12; Tue, 01 Nov 2022 03:03:25 -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 + 99 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 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?1748287624989902875?= X-GMAIL-MSGID: =?utf-8?q?1748287624989902875?= 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 Reviewed-by: Shuah Khan --- 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]);