Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2111460ybt; Fri, 3 Jul 2020 00:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqA+X7DvU+90cvx/JGN+guJjB2KcJNqHSPqHOSqZBhyu7Pl/xLOhITPnVyxwZ009woFub6 X-Received: by 2002:a17:906:924d:: with SMTP id c13mr24576018ejx.518.1593762422107; Fri, 03 Jul 2020 00:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593762422; cv=none; d=google.com; s=arc-20160816; b=nbGfesyHgv60rI3/IPRhduXh7OT0CBIF92R0iKezAXpvKZKxUf/85jnwwnU2WoNN7r mTULV+cVVgZSTwPsK4IFuMnOlQvpeC8zlExZ6/AiP2x3VI9UdZxEMbx0ip0yNQvwK0SN NGCH76KxSOll2MGsUf7pY90ylxOIGTSJ1SjvXrp5qC09gi9JwKMLG4Q1J77jfgrtyfsg M7U+Tc19q6ND6L2gkA/aUXlEnsufx39OsBFN1wfYluvdUxac4eY9PZ9KMNV6gvPviGBF rU6nxzkRFe/U3W7h/lBrMFjKkVOAE1whFb4zj0EltuKm9wPxYI6zH/indAJZ0F7LABcW 5+XQ== 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=C1u6t4qmXvkc7d5Yjzlt9wlcIVlEoMmgmbfKZNzyLBA=; b=KJUw30SmcXMRAAKC4atk9f2K/iGziYAmzmr3RvfT4NQEL4zHPUhsfgMt4v9yw47vst klkAuwZswylzWL3hqkkrsBJ2vPtJO67B2LopU8M0wb0RLoWVEKweQBclOsY0CCVjxifS HQXUmlSkemyzTNcWUn/biGHK23jn5Ei6wWZEo3A1cuXHlbhofVyeSY0EBCNgnaeEibs3 CiCtm2RCC0PbS7HJMW2U9f8yaNJY15eEMLNd7C5OAswC3wWgQbhFI+0AbeWzqxj+86ii 1jdFb5xRdgOwcCATF/N2SoL3kRmYMS9o5kgKUyGzYAb/zN7BUMAwRNMzxDiXQSuPJmvd 1biw== 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 h27si3224044ejd.184.2020.07.03.00.46.38; Fri, 03 Jul 2020 00:47:02 -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 S1726410AbgGCHpp (ORCPT + 99 others); Fri, 3 Jul 2020 03:45:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:14539 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbgGCHpp (ORCPT ); Fri, 3 Jul 2020 03:45:45 -0400 IronPort-SDR: mfAQtgYEY13MRch4h8y4Jj5w/6FbxWk5ZlqnDY29LBc3hwsQGwBlbIY03ymfKqfnEogYFDWRA2 n3MWusytf5Iw== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="145244732" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="145244732" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2020 00:45:45 -0700 IronPort-SDR: zo8jsVYigvUWUoEjQPL2sr+72OavrqJuWB3OLHybPlKdnlyD2luQ7h6lOl0e+agY3EpHAou2aw P45d9t24C9JA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="482291294" Received: from linux.intel.com ([10.54.29.200]) by fmsmga005.fm.intel.com with ESMTP; 03 Jul 2020 00:45:45 -0700 Received: from [10.249.231.67] (abudanko-mobl.ccr.corp.intel.com [10.249.231.67]) by linux.intel.com (Postfix) with ESMTP id 49444580784; Fri, 3 Jul 2020 00:45:42 -0700 (PDT) Subject: [PATCH v9 08/15] perf stat: factor out body of event handling loop for fork case From: Alexey Budankov To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: Organization: Intel Corp. Message-ID: <15df730e-d946-c7f8-5fb3-67c95596332f@linux.intel.com> Date: Fri, 3 Jul 2020 10:45:40 +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: 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 Factor out body of event handling loop for fork case reusing handle_interval() function. Signed-off-by: Alexey Budankov --- tools/perf/builtin-stat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3baf00482666..3e11f854ffc8 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -791,13 +791,11 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) enable_counters(); if (interval || timeout) { - while (!waitpid(child_pid, &status, WNOHANG)) { + while (!stop && !waitpid(child_pid, &status, WNOHANG)) { nanosleep(&ts, NULL); if (timeout) break; - process_interval(); - if (interval_count && !(--times)) - break; + stop = handle_interval(interval, ×); } } if (child_pid != -1) { -- 2.24.1