Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp742971ybg; Mon, 1 Jun 2020 13:14:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjge9gm/YG5Mvykvanzit3yEAWKmnJo8lt2AxbI3Ovuabh23vh4ma6YsAqZrhXOdQkAq/N X-Received: by 2002:a50:afa5:: with SMTP id h34mr23473227edd.34.1591042453456; Mon, 01 Jun 2020 13:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591042453; cv=none; d=google.com; s=arc-20160816; b=048DCWzf069cX+4nREElPngNaqf3h++tv4rtPlaB3G4R8iCzmbUo0CpzZj9TUylyqt 9I1OJLljRapyumeEi++VTm2aIws3d4LC4rJXpsdsBeKjCUfKyo0CdsZXVNn/h6fn+ZGB sZlLfEGhf/wtnOUr3+IadiCW5rJr0avWjrRsicoVD/+iG+5ZcLrvPmdOReMY8sMM/GhV 6HBWZCSHbRfglng5jgY2c/2gBscwtwaHW/FtNOqGgkbS4O7pFdirr//m1ryy0G3Ur+IS aNE+GtTLWDxPu2iZR+7OKpYPdtVSL9ht42+/TgFCHM88NMyTTJIdb3O40lI7RIM1KD/w anJA== 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=NmW/D6bH313+XeXMlKyt4QylxaxihaIsJbgFKZqW1xQ=; b=KvlzEgFqpXYBwzTpAkNZQH/5GBx5gua2ScT56cefnJYyFdrFbMaYXOPuETI5S3hqzX 8LYdauVBzrr+pk3nvOcq6i92MU6WEczqyaRYUDWaHOOHkd6Od7Ouc7coN/50O6GV/UsG whqJBJkGtvQiHRfEBBSj4REAkScvWpkWqwadjQv+TYrWOBUvOh3+JI2un7u/0DeaWhrY 89XDRfFqHFpcvoqDmEI8sd5QhZxsu4Z3edMHr9t+hcJl6fz8IDMkS+4mbUZD2UZJgRBu yq2PTAF7iTlbFn7kkX0kzrTNwOCyfuPFHiZWuYJQthNER5WC/KBcH+NiIV6XJcfzOcvE bqdA== 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 r17si275424edw.77.2020.06.01.13.13.50; Mon, 01 Jun 2020 13:14:13 -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 S1728381AbgFAUJ4 (ORCPT + 99 others); Mon, 1 Jun 2020 16:09:56 -0400 Received: from mga03.intel.com ([134.134.136.65]:29103 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbgFAUJz (ORCPT ); Mon, 1 Jun 2020 16:09:55 -0400 IronPort-SDR: LcWTbyCMXVqdCejAtMk9hNwFTqVuaW6dW6Gdb6v5W/9LvwJbyvPo1gHxwVVylPnf/ZIwpAilR5 /GwQTxlUvOJA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 13:09:55 -0700 IronPort-SDR: LQWAY50ZlgYHS3FQgivq3OHT4bLo+Ag/Xx58lI/aCQOim1cXrl1jbmZTTTWsyt9haGSn1FdCq5 i1EXLensdhQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,462,1583222400"; d="scan'208";a="444413599" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 01 Jun 2020 13:09:55 -0700 Received: from [10.249.230.65] (abudanko-mobl.ccr.corp.intel.com [10.249.230.65]) by linux.intel.com (Postfix) with ESMTP id CD2E358010E; Mon, 1 Jun 2020 13:09:52 -0700 (PDT) Subject: [PATCH v6 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: Organization: Intel Corp. Message-ID: <0e4aba1f-2032-12da-4605-6cb65ab7614e@linux.intel.com> Date: Mon, 1 Jun 2020 23:09:51 +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: 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() and process_interval() functions. 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 9c090eaae1e1..edd6fdcd1c72 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -745,13 +745,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