Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1601017ybh; Tue, 14 Jul 2020 02:09:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVTktzdLdweGufoLXsW5qxqJMa6zSiQNitEOzcs/g2MWid9SzAxk54GTbDVyIP/kUn+njJ X-Received: by 2002:a17:906:148a:: with SMTP id x10mr3739659ejc.497.1594717759112; Tue, 14 Jul 2020 02:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594717759; cv=none; d=google.com; s=arc-20160816; b=cOKMqWLKnk/IOHqTIAL9nuqg1jRp21PfHtDdTlXW6ofG0uT3HeBtZp3IfhZ5JJoH7Y 5a2kffhEqURsxeY1h8RRGF9w//bqz2fSDx2oiY7rMdsZty259x44GAAiqTUXlIpVOj0e QCJF2uhNzoDqzAHNzxfitDW2uj4az4ZVOye4PouKh9o5wKeyAL2M0Rpj331wxh+/XCaM Ac0FMnYzEByA/xeVPF0jj9p2KrN220MPLfWK2Mm2NKgb8R/E39C7FAWKHtGds5/cSSvj qJTu8RJT15IX7/ZHM9uZa7FBC8Fjk0o/gSrYkd1uNQeDmOXeKnnerZc+9G43/jNEapP+ w+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=w2du517D29gt1apCcmXsgizoVHlCPG9oqg2tMP99gJ8=; b=AodCd1rjHZvrMj9IGW3PinWb9HO+gCpZaz+0XVOMgKgBq3yuC/cT6eto88jfLo7k+0 y1YcfUzdf+XM4L6rsF/85KGnmKYyYN9Aybc/HODAgFM6tj/xD6Lk72s1bfaa08kN5QFP o3VqRGecfdnTiqkO0Mc85C4Yek19TuJU3VzkfNQX9vP8EvnDJf/wwEGR4eKzJarktbct 2RbCUz5ktkjDhvZDISfE9pOfNlk7UCqm7tvSUMmIVPDl/BR9IXh1bFe9EYUV4IAdcHa9 aMHq6P/DR0MV7I5V9rydhfenokS0EHocA9PGq9Y9xpPIpQIMau8ZhSziAmyo73krz/p+ wN9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx25si10661672edb.75.2020.07.14.02.08.56; Tue, 14 Jul 2020 02:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbgGNJGm (ORCPT + 99 others); Tue, 14 Jul 2020 05:06:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:46321 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgGNJGl (ORCPT ); Tue, 14 Jul 2020 05:06:41 -0400 IronPort-SDR: PO9QowSdKZhiyZnQ1MAHh1iLDPkR42Ox6nhlA+GQYGFmD66Mq6jPpvcgL9DG0EmGHMCtFjN6HS M+da5zcjYuMw== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="128411761" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="128411761" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 02:06:41 -0700 IronPort-SDR: 3G7R7mjxSKkZkHmdCx+ToLLKDxdJ8j2gPZwIH5oTy0P6dBSGSTXbcsrOeRz2jNhCdWzAKQEfRl 20u/+futFPLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="285691552" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 14 Jul 2020 02:06:40 -0700 Received: from [10.249.230.149] (abudanko-mobl.ccr.corp.intel.com [10.249.230.149]) by linux.intel.com (Postfix) with ESMTP id 04A03580810; Tue, 14 Jul 2020 02:06:38 -0700 (PDT) Subject: [PATCH v11 06/15] perf stat: factor out body of event handling loop for system wide From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <037d737f-0ada-a9f0-9686-f7521ca6fbc3@linux.intel.com> Organization: Intel Corp. Message-ID: <98f582d0-4855-e7a5-a0f8-be15f700c23a@linux.intel.com> Date: Tue, 14 Jul 2020 12:06:38 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <037d737f-0ada-a9f0-9686-f7521ca6fbc3@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce handle_interval() function that factors out body of event handling loop for attach and system wide monitoring use cases. Signed-off-by: Alexey Budankov --- tools/perf/builtin-stat.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 922d9961ba98..80aea49e4dac 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -475,6 +475,16 @@ static void process_interval(void) print_counters(&rs, 0, NULL); } +static bool handle_interval(unsigned int interval, int *times) +{ + if (interval) { + process_interval(); + if (interval_count && !(--(*times))) + return true; + } + return false; +} + static void enable_counters(void) { if (stat_config.initial_delay) @@ -809,13 +819,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) nanosleep(&ts, NULL); if (!is_target_alive(&target, evsel_list->core.threads)) break; - if (timeout) + if (timeout || handle_interval(interval, ×)) break; - if (interval) { - process_interval(); - if (interval_count && !(--times)) - break; - } } } -- 2.24.1