Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp608824ybg; Wed, 3 Jun 2020 09:01:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbYgpARKdKlYlLrI6sjUqh/0t5Zon3XP/8OQBV6+MVdkpNzJYa50oux2spAMzmgu76hgP7 X-Received: by 2002:a50:99c9:: with SMTP id n9mr110546edb.1.1591200106570; Wed, 03 Jun 2020 09:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591200106; cv=none; d=google.com; s=arc-20160816; b=fDNN551anen1X7b5TCQp2oGM4uoeH48B/6prMAAf2nVkghRPjoF4WeE/vVutkjw7TD ABPxHMcheYyc+tABrvX4VXPAlLry1WQoGjAHxFAA0eKq6tjMa3YCC+UKzYU6XrCGEf9v Xxd6/jWj2p4w9XzhO/4ta+8RzDHZQlD/pvnjFP6s1kB6TI4yqjF8doznerxEnBYTW8H/ jAGz0WKZ00geqm+L2ffSB5q/aysOphklpvDHIl3eD2isk6+cnmffnLrS8a/cH83iRC5y 4I3XuXSEnrqGCUi7hfN/LMutM431i83namjXOCJil21AZYFp/mFByS55xFEGUaFYEW6F N+3A== 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=LH+V4s6fVj1SMbK5yKI/CYvQ2+qbrDjRqAfzn5Vi4F8=; b=xO2gPrY39/fiDrN0/zbnfAWIu+J6vEN8AqnpNYuR7KDDiSmNIk1f2cWV8l8CvFBAzz IN0J3rEE15l3D7vOy0L8C46Le2Yg37gOyfknCaFR+8FpNNgy8iEmohennLWysuz3T2It WrX1nxP/aYzzlRwwrGMEzrasC3+zdDbyEXnT0GeON4MJIBgQcjtbgcMt6EG5+6x6blxK t3/+O/bHW4vG4568uZ0lv4AlSUDGXyBZsJ66XkLmOvfGNM0BvhxmCICNu9/7A3Q0XI8f 11xS9H4iJhpa7DVPtRS+krwq8OTN0iBuolZ/yPHjUfe8GCQNh+d2AR3Nah782Dyl3YJG /uDg== 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 f25si1155562ejf.743.2020.06.03.09.01.22; Wed, 03 Jun 2020 09:01:46 -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 S1726061AbgFCP5O (ORCPT + 99 others); Wed, 3 Jun 2020 11:57:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:28312 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbgFCP5N (ORCPT ); Wed, 3 Jun 2020 11:57:13 -0400 IronPort-SDR: ZnPh+v/62dXlseJuxArDCkhlZZh4BWCgDTqTcAfDwtqoMlSQ9xPz8sQF3B/710HxYM0040k2t/ ZmOguVT6Nlmg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2020 08:57:12 -0700 IronPort-SDR: EmkfzJUSwsm2kR3JKSUSPcV5tr4ZhvFlhtp88BuHQ06N4OdiIUjD2tlBq8qMu7ilGgcfvkYMAC bZIjW94PsTMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,468,1583222400"; d="scan'208";a="416604242" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 03 Jun 2020 08:57:12 -0700 Received: from [10.249.225.188] (abudanko-mobl.ccr.corp.intel.com [10.249.225.188]) by linux.intel.com (Postfix) with ESMTP id 840BF58045A; Wed, 3 Jun 2020 08:57:10 -0700 (PDT) Subject: [PATCH v7 06/13] perf stat: factor out body of event handling loop for fork case From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <5de4b954-24f0-1e8d-5a0d-7b12783b8218@linux.intel.com> Organization: Intel Corp. Message-ID: <13c8fcb0-e97c-110a-6c10-e92145a7d374@linux.intel.com> Date: Wed, 3 Jun 2020 18:57:09 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <5de4b954-24f0-1e8d-5a0d-7b12783b8218@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 Factor out body of event handling loop for fork case reusing process_timeout() function. Signed-off-by: Alexey Budankov --- tools/perf/builtin-stat.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 62bad2df13ba..3bc538576607 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -798,13 +798,9 @@ 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 = process_timeout(timeout, interval, ×); } } if (child_pid != -1) { -- 2.24.1