Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0078CEB64DC for ; Mon, 17 Jul 2023 08:36:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E62F6B0072; Mon, 17 Jul 2023 04:36:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 696B76B0074; Mon, 17 Jul 2023 04:36:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AD168D0001; Mon, 17 Jul 2023 04:36:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4C7836B0072 for ; Mon, 17 Jul 2023 04:36:54 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1CAC4160441 for ; Mon, 17 Jul 2023 08:36:54 +0000 (UTC) X-FDA: 81020448348.15.3EDC0A3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 5001116000A for ; Mon, 17 Jul 2023 08:36:52 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689583012; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/L6/NurSu387Ihb7fj6qUYG4uzPQCD4LHwXYXe0GyQ=; b=pIXINyEz4oD6q4NucsxJzmfbb5PBVhZH1OyqtTEPuG8S9qS25Gg/o9oFCtYLrWQASvbrjp Tp89XiQmzVnVx/cr/grSRyL+XDzLnpkEs2NYOadPRVGqfHShd+yGzEacA9sR/ZvuYepI3O p+WOTQl32NjYnhtSdvgeeAIrPc9lLwk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689583012; a=rsa-sha256; cv=none; b=vKuFPili3dY9uMW+3PmIdjtbXvF4HT6XlGbmbZctaW4hH3antWbT08fwd5WdS60PCMdV47 YYN82ThLAFvaLkGBTRXpYQOLLDwtJQPKSzXt5SGJ9do4pLGR6Vy/2kECohESbJ0JtYauD6 Wf6bhc6oVoDny0TfrXMPyFGxD1AQIRY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A1178D75; Mon, 17 Jul 2023 01:37:34 -0700 (PDT) Received: from [10.57.76.30] (unknown [10.57.76.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C00FC3F73F; Mon, 17 Jul 2023 01:36:49 -0700 (PDT) Message-ID: <50687516-987b-75ca-c6be-255ee3091b6c@arm.com> Date: Mon, 17 Jul 2023 09:36:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 1/9] selftests: Line buffer test program's stdout To: Mark Brown Cc: Andrew Morton , Shuah Khan , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , John Hubbard , Florent Revest , "Liam R. Howlett" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org References: <20230713135440.3651409-1-ryan.roberts@arm.com> <20230713135440.3651409-2-ryan.roberts@arm.com> <8a8d077c-55bd-4710-9dfd-1cbb1a9170a8@sirena.org.uk> From: Ryan Roberts In-Reply-To: <8a8d077c-55bd-4710-9dfd-1cbb1a9170a8@sirena.org.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 5001116000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: n5mnbgw6odhuuyswbgi955duyhagxz11 X-HE-Tag: 1689583012-624798 X-HE-Meta: U2FsdGVkX18ZWNsFc/eiWTNxfCM/VDCabT2CCoVXHPOBtmM0LCdojl1rvD0vBPwp3/EZzg9IVqtCvtN/uxcP9Ba8VQm6qoOJLxUcpcYMMcvcuJno+lsg/8GhrzYSfr97KDZdsz7Fr0JXML3ir5Ynn1imQFMW4Ao8mvSlggOZun5A8R2wU8myzh8fJsA7XlbH4TfU7p+3k+CfKUcUiuYdPLMUHYlP/cZpR7jYkLY3HqxzC8zwRHmAZj04e0y4JxXU3J3z2l5yvFtBDBUzPt3TFFA8/90PKFHwRtH9vrXuclDdZpVZXE214oyl2IVJ8jKlGv9RawiXocwQDFY3cqFYMN8kw5r6hnrGHHJ3M3QWAhf14bVu8XBfHK+MHjcJofOHcL4LauLk1kTTsLHCkTAs/RYXktGcg5/QcAdjY0lF2aJmqlBUG2WYOZThU1iRW91BcUa6thy3a1Lbt/BWoE5+Mvh2mDHQUlQPvT8yNSExJfoXazt1BvRhhVbE+bWhP8u+A58/ZkzqhrtEkr6Fe7FakUG4bsBJA8pAZ9NeCG2+hTRlV6OSVX7gkb7YNmP9TE+xhJ8kLYVvtUd9VwSarJUMaJgWPtUcsUp9qf4ZOcPFXAj7QyLPw481eZA2qoXde0FHVkkYwFOMSy1ykvfphiCSbFnhq5cgL8YAGEPwKmCTx8awyJOrxpA8HKYeNFVTYSo4ELeBXRdkQ4fK36VdEOZOAqk6wMSkwhnpME779PCUL0KgmaQ8jWiB8l9sYdFVU8KOPrBhN+FSe48P6bfhFemx1X61DxFXEgWUw6cujk+EFqCHs1/8006VU+WDjVyel0y9xuXyvHbn2eCGqFu3k6mAiDz1vKcZIMHZqgO+mCOsFSQFC92Lh8p8YHtrsJgWwOoDvWFwFnOtIVoQsFoiwFcBB+L/8fa5Tb7WM5uIHipTjXNQV8QybTlO/fT1a8B+z6ZvLGVJqAvA/5Myzk8jZVG 4HCQxBe7 uNblpFZ9tgt5NYxNZB7vl4F1bvC/HXaB4qU9DiEI1qxJDDBKiHSDl1rh7Xt2zhmu89yR0VY1R8M4pAgOCezTUBELZQHweBOXw8AkPnAJ/FJQbXYw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 13/07/2023 15:16, Mark Brown wrote: > On Thu, Jul 13, 2023 at 02:54:32PM +0100, Ryan Roberts wrote: >> The selftests runner pipes the test program's stdout to tap_prefix. The >> presence of the pipe means that the test program sets its stdout to be >> fully buffered (as aposed to line buffered when directly connected to >> the terminal). The block buffering means that there is often content in >> the buffer at fork() time, which causes the output to end up duplicated. >> This was causing problems for mm:cow where test results were duplicated >> 20-30x. >> >> Solve this by using `stdbuf`, when available to force the test program >> to use line buffered mode. This means previously printf'ed results are >> flushed out of the program before any fork(). > > This is going to be useful in general since not all selftests use the > kselftest helpers but it'd probably also be good to make > ksft_print_header() also make the output unbuffered so that if setbuf > isn't installed on the target system or the tests are run standalone we > don't run into issues there. Even if the test isn't corrupting data > having things unbuffered is going to be good for making sure we don't > drop any output if the test dies. > >> + if [ -x /usr/bin/stdbuf ]; then >> + stdbuf="/usr/bin/stdbuf --output=L " >> + fi > > Might be more robust to use type -p to find stdbuf in case it's in /bin > or something? Just looking at making this change; run_selftest.sh's shebang is for sh, and sh's type doesn't support the -p option. So I'm inclined to leave it as is. There are multiple other places in the script where /usr/bin is hardcoded when looking for programs too. Shout if you violently disagree.