From patchwork Mon Nov 14 23:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 20078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2409142wru; Mon, 14 Nov 2022 15:06:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hkxb2HsrsRnKyjmqMrok3G036j6tg/nlNSqT2KylhFObdN9A/MNXrLIcZOGheGV8i9S3u X-Received: by 2002:a50:f612:0:b0:458:caec:8f1e with SMTP id c18-20020a50f612000000b00458caec8f1emr12533507edn.280.1668467182804; Mon, 14 Nov 2022 15:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668467182; cv=none; d=google.com; s=arc-20160816; b=JSMiqTJVkfWnf9nKxR9+p4PfXOpecSbRBpmwh1+I5m8hn24ejBAKziVpj+p00/yZ81 tdbTN0d9NxZM9wsSxcoG8QDGzFZ9il0BJdGuE4ralCrrogzWVAh1Tm9qEKEGWkUfviX/ NmIZQGVn+WztVFc7BQnnkq2XNSmhDN9lv4gnbgHFN729Jg6RQomWBg2X7j2QwcRYYnpu lfKXDgbI1QHpSTWnebOsNwKG3Qv/P4RO6JSJVVLwy15QczJYBAmwG3TgUfVYrqP5yC4a 2xXJU5lWR65mTXyOYBebOigdLhLlKEEq5DKWpNAqtLy77FK/cV1vNjN3WXI7imVQAwMc TIcg== 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:sender :dkim-signature; bh=rt0OZoaxk4oNSiXVua0yf4Wn8zR1kll8hc9QqXyH+pA=; b=JGR3U9xoXTe3E10oi+6If85QnH4uX/12HlX2zEYAN9C9pyueX08B/prkQyo78Sq8JC bmXGjli97kVcpO9I1W25M4tT7WmPyfo3FIqzH6IjBk769fQ6k8WJr3uptyw6jsqgP6hj vMIkkUFTTWgSyvsY1F1jme4P9VGTfABfELYcgwQeT7PmTmkwnfttW8jWHqwwyM8MbZCx 7XjjyAqpF5Hzhcwb7AvUCWG8OQCIhbWbQiC6tWZv/kSpdMajmOmglNJl/pr8HN5I9dxi vdx+vpXpLW9PXmKAbs1Y8G+Cb1OB0lNqaNLLxVQqF6QqsEdOG4CnXlxt+axRyAXdRWYm 9kPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jcCl/Fyx"; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u24-20020a50a418000000b0045cca8f9a0asi8971089edb.580.2022.11.14.15.05.58; Mon, 14 Nov 2022 15:06:22 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="jcCl/Fyx"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237853AbiKNXC6 (ORCPT + 99 others); Mon, 14 Nov 2022 18:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237867AbiKNXCc (ORCPT ); Mon, 14 Nov 2022 18:02:32 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C0EF1B7B5; Mon, 14 Nov 2022 15:02:32 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id io19so11492230plb.8; Mon, 14 Nov 2022 15:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=rt0OZoaxk4oNSiXVua0yf4Wn8zR1kll8hc9QqXyH+pA=; b=jcCl/FyxwF3w7YMSk3Qw/Vq3k7ny8Me1VSIXUCAQy0kPHz04yRm68l9gT56RqRB7s3 gK8a7gbS0ZDoygeaAfUqQopGM/82KP1s6SScgdXGARymg+iDxMU5JtpKZOtx5IzkxFjK WfWTQnf88m4QF2Y0pRJQKDWSwwdKvML/JgXrXTz9EikSAav+lDT0ZurpRK37CCWZLzSd lG4GPJCdbdfn+3P5T+cmKS2npifOuuag0uwI4HQHxjjY8iTd0I1MeFcrmWtqDi5ipaNP gPtvdjPcx0L4/5hb6cegUBmRe/6thNB3On6+9C3T84Exn79BE4YEcFRTPyy45tRF6A8B dOHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rt0OZoaxk4oNSiXVua0yf4Wn8zR1kll8hc9QqXyH+pA=; b=AuQsUcCaWh88OGf31fpw/33a2j2dkGJcC+IyXqBnFMzGGc15Q32X3t4V084fpcCMSe ym6bazRh0CeRpyOptCL64jTsNOTcoW4MCL7u0YrXwb+SI9BLwmjAamvNVypu/kXxdCj3 UluJ4CLnYnjApYJZ5tO5nPF4k/GmldN2v/RWgkra47DT6/mUEP5mnETdowqyG70Jh8Ea X5hkHUy88VHD4u0Pm200DsR9JTZB7T6S0lq7/iVZE7gtRJajvs6AgL2Fw7W984SPIhrU M5qwkKu93ybk3GI4nIkIpkQvCwib8FN4IzAqCzgmJLRy3ULi8uIPbwJ43eYJ09sKZGM+ qTIw== X-Gm-Message-State: ANoB5pkfozXy2LZ/xdcWy/v/AUs1Y4aeeAj1e9n35BJyzRaTGHK1DgEE GyG7jdC5XTqqSNTMUk5kUQs= X-Received: by 2002:a17:902:be13:b0:186:748f:e8c5 with SMTP id r19-20020a170902be1300b00186748fe8c5mr1358372pls.73.1668466951601; Mon, 14 Nov 2022 15:02:31 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:cf9f:e038:c19b:797e]) by smtp.gmail.com with ESMTPSA id 132-20020a62148a000000b0056c814a501dsm7534724pfu.10.2022.11.14.15.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 15:02:31 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 01/19] perf stat: Clear screen only if output file is a tty Date: Mon, 14 Nov 2022 15:02:09 -0800 Message-Id: <20221114230227.1255976-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221114230227.1255976-1-namhyung@kernel.org> References: <20221114230227.1255976-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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?1749514644588138690?= X-GMAIL-MSGID: =?utf-8?q?1749514644588138690?= The --interval-clear option makes perf stat to clear the terminal at each interval. But it doesn't need to clear the screen when it saves to a file. Make it fail when it's enabled with the output options. $ perf stat -I 1 --interval-clear -o myfile true --interval-clear does not work with output Usage: perf stat [] [] -o, --output output file name --log-fd log output to fd, instead of stderr --interval-clear clear screen in between new interval Signed-off-by: Namhyung Kim --- tools/perf/builtin-stat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d5e1670bca20..1d79801f4e84 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2403,6 +2403,14 @@ int cmd_stat(int argc, const char **argv) } } + if (stat_config.interval_clear && !isatty(fileno(output))) { + fprintf(stderr, "--interval-clear does not work with output\n"); + parse_options_usage(stat_usage, stat_options, "o", 1); + parse_options_usage(NULL, stat_options, "log-fd", 0); + parse_options_usage(NULL, stat_options, "interval-clear", 0); + return -1; + } + stat_config.output = output; /*