Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3741100rwi; Wed, 2 Nov 2022 02:31:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM783JfJ2guw7UhrdShODficev6OH5jDkXBJWvdIaNwQHBsUkOINMkYloUbV3qC43ZmhiWa5 X-Received: by 2002:a05:6402:2c1:b0:463:bddf:a77d with SMTP id b1-20020a05640202c100b00463bddfa77dmr6541697edx.277.1667381519136; Wed, 02 Nov 2022 02:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667381519; cv=none; d=google.com; s=arc-20160816; b=UP8xqRVU+nhxgorzWCJS/BjxI3IqwPist0b1U6jqID61ToW7jF4L00bAMhB64saIhV UmZktIsetvia5isVL9xPSaIVrY2TVUkGpUYQ2sImwRUaQORqxitb9V7j+pvJIeaamNbX FsbJoZ0xbo35ixC24KeZ6JQUMzYZK4vJXzNaNSV1UcCAEmw3+cEYEvRX4na6axChkekR 1AkKr6GYiXpz20Rk03qKlA9+9maEbyXfWeHFfTWvFYZ4bXQc7nvEA5a7Q6dFDcmPpbKY A7q7q9ncdgLLy2qgxk0WFkJQyLcek1dONhRJ6OI+CUQ0RfjF2ddgvEYzeqRGN0QHyWBU XHXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=e/LpNA2XkrZd/P1C5jUW2C9ri+5Ug2DmDuhYFjerMn4=; b=Q/WIUdinvX6fLjEG7Xvfa3aRUOas1qIZOUQehOTiWAIiV/rH9b7UsiRbjlAMPQaDpU 76SnHohyRQe49+wR16YfcaAVOFdxMvBkK6GJycU57+/vel19OY0GNyg9EBXT4/vUodh6 Jm+uCv6Ujs8B5hqIti9qQKcXCzB7pS2bdEtEuI65FL1KvzsRUylChSB5M4MUlM1sZy+k NiqYDjr4ipApun2Qyfkkm1G8b7PiUQ1R+XjghIPAmKavTMaWpYiObO6lYI4OKNZMzjPi ArtrA5S0qgdh9RdLrAqPr0oPnp9O0ZjIydza9nSXmW+c02UdM7H6d0frctHmiiFAf0RA ibKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=QCD1TPOZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg9-20020a170907970900b007addbdb9fbbsi10411748ejc.558.2022.11.02.02.31.34; Wed, 02 Nov 2022 02:31: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; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=QCD1TPOZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbiKBJ3Q (ORCPT + 98 others); Wed, 2 Nov 2022 05:29:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbiKBJ3O (ORCPT ); Wed, 2 Nov 2022 05:29:14 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3734235 for ; Wed, 2 Nov 2022 02:29:13 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id 130so15895958pfu.8 for ; Wed, 02 Nov 2022 02:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=e/LpNA2XkrZd/P1C5jUW2C9ri+5Ug2DmDuhYFjerMn4=; b=QCD1TPOZZn+fBI7T153LS5r9TxHVKJnuBcW5Q686Cpn2TQbGzJ55JXxu9yxstl5WR0 0e0RIx+9d0T5X/VNFuTPsW4zpaIrIEUMuTHelfwuzsmXGkmioSV7w5/3e6QZlrApB3H3 D4LDShuwnAtn6Ap3Rx9OPZGilS01eB78pX96g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e/LpNA2XkrZd/P1C5jUW2C9ri+5Ug2DmDuhYFjerMn4=; b=RFC33tokQ+30QtgI6k9MByUnm2tIutSPOKc0caQ6wnPDbVkZHzy4GivprjcBuCyV/9 r2WJRgv5UqCzAmdRk0u3JGT5Xd80qCsU5KVPFqABsMD2MhfJQXVuv4IKCCAHC+mAqAZO NbhiR0Alo9bYdnP5LhjzQFbtOvdYnw5wJuIO2J2KmvxBSH3aq6IjZT3/S6GAlB44wxUo mUh8dg2gvLK9wfn5wNp1YwPW6aGeHsc+wZz6Hq2UVmF58ydal5EBTkVCHUvjTjKcLCiF jbk+Sx6KWjZNMTJRfZPBlUwwvybF+Kv199w/wYtNGyeJG5YivebCvV3MaE9DLAtFQ/VK GddA== X-Gm-Message-State: ACrzQf3yhrrXKLkvzFdDPHm/ozD3NBCDwRJ/I48Kf/XyJh5SON85jSVf y3gWze2dZyg4eY1imZXF01zxgA== X-Received: by 2002:a05:6a00:24c3:b0:56c:dd9c:dab4 with SMTP id d3-20020a056a0024c300b0056cdd9cdab4mr24274738pfv.36.1667381353253; Wed, 02 Nov 2022 02:29:13 -0700 (PDT) Received: from [192.168.0.168] ([103.99.10.63]) by smtp.gmail.com with ESMTPSA id c12-20020a056a00008c00b00565b259a52asm8042791pfj.1.2022.11.02.02.29.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Nov 2022 02:29:12 -0700 (PDT) Message-ID: <52154117-ee1c-9ea9-bce6-04e02124ea1b@linuxfoundation.org> Date: Wed, 2 Nov 2022 03:29:09 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v3 3/5] selftests/resctrl: Flush stdout file buffer before executing fork() Content-Language: en-US To: Shaopeng Tan , Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan References: <20221101094341.3383073-1-tan.shaopeng@jp.fujitsu.com> <20221101094341.3383073-4-tan.shaopeng@jp.fujitsu.com> From: Shuah Khan In-Reply-To: <20221101094341.3383073-4-tan.shaopeng@jp.fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On 11/1/22 03:43, Shaopeng Tan wrote: > 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]); Good find. Looks good to me. Reviewed-by: Shuah Khan thanks, -- Shuah