Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp322636ybt; Wed, 17 Jun 2020 01:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA06WclhFiY8A8gwRMMyZMosgiK4+CcVnXL6PgCsfzQl5Zf0ouPblUCNzXiPyzAfZGX3C5 X-Received: by 2002:aa7:cdcb:: with SMTP id h11mr6298469edw.218.1592383288502; Wed, 17 Jun 2020 01:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592383288; cv=none; d=google.com; s=arc-20160816; b=H+50fDa9BYTD7mxspUva7aTKzg4MJ8AfkgJhGyVbg8GZxpP5DbnOKYt7Pqz+5ZO3yK W7tMgYimH9Cvlt39hu/rp4RJgxW1IIhiREiD1dzddSmyP/qsGzzj2mZRc/FAI6Rkh87H P25m+BFqnphCteLMKnPtz5qVyZ0yzpEsqcLuVyijKvlorjZfOieFEZp4wkGcxcH0yzBQ U+lUEKkUX1IX0OS56zDICpUBn81+bTlj6DzR0Czx/i+c5T2m06tjebRny1ThaH2NJUwG I+5Pqxzb3jvxiiWB7ayb6H3qeZcziLyBzZkNfNBjEYclQHMbyLZWjINCLAiouIV1W49y HlFw== 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=yBE+TYW6vX2ZkJ1BDj05LXCRN7cehDUGmWEcLPUDk7o=; b=eOD/2UyQG0K8gbo7A5P0xArQs+f3y/Y17k0Y9pztaMjYKEyEzo4XM50VN28ORO5V3T J5K2nMGycTyaP4a/5ihp4flFazRtPVxQlN2fBmZR4rg2IqIJTCuT0/2BrSXrrwKyhkpr EiazZjpUyEpvNYYaFMYetHQlx42rmzAyht3jRJDD5DRSinG7g8OdUed+RNmT+xKkz+a8 rv/TI5SERiz5x/jszyjSlgb3ma6Gn5XqhTZOLkL6LFcPBoClUAo9SvSa30xsu65iHAa0 nuOgOuiY5jiIlRvmWTVkXLkW/4fz9OM9ya3RxUOZKI8mNUg+y70ubKKbosLDsYE5wLfJ /Z8g== 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 n27si11880270eja.232.2020.06.17.01.41.06; Wed, 17 Jun 2020 01:41:28 -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 S1726881AbgFQIj1 (ORCPT + 99 others); Wed, 17 Jun 2020 04:39:27 -0400 Received: from mga17.intel.com ([192.55.52.151]:60816 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgFQIj1 (ORCPT ); Wed, 17 Jun 2020 04:39:27 -0400 IronPort-SDR: XXxhttbXYENsmX7teS5f6WbM4ojsh/i/MYAs1BdVPBsDWp3ZSTfhPlWn6SyrHblrLNXhZaoLgS CIMhU9baibVg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2020 01:39:26 -0700 IronPort-SDR: iawUpKhrQgMcJZru19FSYOcTy0xL/UxwDg7WI08V0DQchYnO95g1dtPvXP45GaW825eJXkb6xh fTBbTu1oLYWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,522,1583222400"; d="scan'208";a="383129754" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2020 01:39:26 -0700 Received: from [10.249.225.191] (abudanko-mobl.ccr.corp.intel.com [10.249.225.191]) by linux.intel.com (Postfix) with ESMTP id 680E3580223; Wed, 17 Jun 2020 01:39:24 -0700 (PDT) Subject: [PATCH v8 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: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> Organization: Intel Corp. Message-ID: <1cd9e599-67b7-ad0c-44c1-929cba08bd47@linux.intel.com> Date: Wed, 17 Jun 2020 11:39:23 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <0781a077-aa82-5b4a-273e-c17372a72b93@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() 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 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