Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1769279ybh; Fri, 17 Jul 2020 00:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh4pCfu8r96MNBxsn99xN30WP/VNEoGCVkdH2VEIbiDyT2jYKuCwuOBnbK9M4FKIplkj1h X-Received: by 2002:a17:906:76d7:: with SMTP id q23mr7498757ejn.95.1594969365144; Fri, 17 Jul 2020 00:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594969365; cv=none; d=google.com; s=arc-20160816; b=E8+lnEmXzfR2pGDcNDihvJnxCRNE2UsZ5Jj/TiDQJ3mIHr9CjOgeQN1bDifafy+JeC jf/5bzbBxZlfDny6sb/hK9CYQtoGKwYO89hShir/Wue2c8iZIrMzUPvCcPkBrt4PVDfA rc+NtEb0WNbbKSTI1jOlpBqjoOC7UvqN2KRbcgDlErIRH3SASi0UhESMXIYFbt/0MXBq PuEgd3QmAn1KR9mGGGcr0lgxzwlUCtuiJUqd8iMGvmzGC2+c2ob2lteK070iG9gjnaOa JWKZisP6YGrUSCbTT8zVDqHR56HCcGQ9EAYu3XwaRHfbRe0th+Jb02jKz9PqOQwsIZnf NoMA== 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=XeCyjg/EnFyEDEPoim2ab7AMy65WjUF7//GgTzyCveA=; b=OpC4XmbDVMfbhtsoqn1CnQQUqKNSctx/eIjkbhCD0DlI7ojXjSsokP/X3eyMKNL/e+ GYuqwvxBgOB3/7qZrUMnWb2yEDH82En/F74SPld6nbRrRZFUbVqVi0t9lbrlbQOYnip6 lE/epcpthsENYkDfZhSiuR3tnX6w0Gif2zmjcoT4A/6e5XyLrMNiVnrSVyQeuPKSC3pd 1KZHH7lltQksRbfWGW/q0WDI+YEmWl2Eplo3/retWtrjMBuyb5kwnFJGmRFXR0syFkhn RAHDh3hb8Iw2zTpqA5awBSG0XlH9bNri9RAPR+NHC74otQrKuHHinWV6tIFtSaxlch0V goDQ== 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 n6si4668548ejc.328.2020.07.17.00.02.22; Fri, 17 Jul 2020 00:02:45 -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 S1727078AbgGQHCM (ORCPT + 99 others); Fri, 17 Jul 2020 03:02:12 -0400 Received: from mga17.intel.com ([192.55.52.151]:17589 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgGQHCM (ORCPT ); Fri, 17 Jul 2020 03:02:12 -0400 IronPort-SDR: bPPq03mh9PND35tMumBKn8csw/Kg93ilYhW4d4vOVFhHsW2uOpIjJwJ1NwRLZ1yntVfPWWdri5 aHeMsCUbIvbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129631072" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129631072" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:02:12 -0700 IronPort-SDR: H2GaCJLamA0dnZFeVCvH96M0u8UgIy8RSEHHdLUqIvySGZ5iVnjDNJzSk4MgWfaIsAoQ+3V8A2 dG6CM+1Kce/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361267444" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:02:11 -0700 Received: from [10.249.224.34] (abudanko-mobl.ccr.corp.intel.com [10.249.224.34]) by linux.intel.com (Postfix) with ESMTP id 5B54F580100; Fri, 17 Jul 2020 00:02:09 -0700 (PDT) Subject: [PATCH v12 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: <8d91c3a0-3db4-0a7a-ae13-299adb444bd6@linux.intel.com> Organization: Intel Corp. Message-ID: <73130f9e-0d0f-7391-da50-41b4bf4bf54d@linux.intel.com> Date: Fri, 17 Jul 2020 10:02:08 +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: <8d91c3a0-3db4-0a7a-ae13-299adb444bd6@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 Acked-by: Jiri Olsa Acked-by: Namhyung Kim --- 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