Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp583327ybt; Wed, 24 Jun 2020 06:31:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn/Kg1L6mcyZeIOPpLmYM1p1vA3cF/BCspw4ou3E/3YtdhKtt2Em2jPM6BKJjc58/umy2C X-Received: by 2002:a17:906:958f:: with SMTP id r15mr11719935ejx.77.1593005467042; Wed, 24 Jun 2020 06:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593005467; cv=none; d=google.com; s=arc-20160816; b=C+3nsxDqbI8E/qU8eGLa7/JUz3TDU7VaSdwyXx7SzVQzCBZpln7U24D21IAGnGFYtq Kdrnyfa9yglqp8DyoKfyk3Mytprugu7u3BFQyGq5x+pmWBttULrW31io+5lMEA4WziEc H22oPFhn5ubxyj7Qa9rFHXtJJ71bOzpLlVLQ1sc3drGxAR0fMmzHN6nwO2cBRgPqgqRs b2uXGJ/6bqjBfcPErV2LTNGrjbO0N7dR8B/vItsIUmGYssxG6mK61yOuu7+OMpliPdoq LFE2a7hXy1OKM4jZSe918lrzd4HLlLdUQloFbg8TPHUJr6jZBqLonljhmSkBUAFA0OAN cYQg== 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:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=ghOQBYTptNzX3+qWvE9EVVBV0OQOdS9VosZp7ohjBCw=; b=ufOewBQ7H5wU8G8UjmZ4e8DeDg5jf1J4819HtGb8qPYYRxOpWAHGMRazmG5F3UETe/ 9rXzEidoh0FH9OGKCEiZ/yNfs24BUz3RzMIH0HgeDZdAmEJW8M9mKDSW4TLtBi71nUPr CPEu0tj6ta917FNsHWW+SjVTDe1oeB7PApwLxitLFo2n54PwrsUMfOAMOf7ZAH5Fyt8B vFAz7Wux9o9zdO7EAjI8Mcn9CVTZ/HM9XbX8ggy20tH6JjyRGsteM6u2S4MrY6N2i2Wp goevxIMZ54cSKKSO8a8e9ciips4+7L/hCuVUbhS2caiPFf/9EeHi85MTy7ke9ahgfKG3 exuA== 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 ar18si8134669ejc.515.2020.06.24.06.30.43; Wed, 24 Jun 2020 06:31:07 -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 S2390957AbgFXN1f (ORCPT + 99 others); Wed, 24 Jun 2020 09:27:35 -0400 Received: from mga04.intel.com ([192.55.52.120]:9530 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388365AbgFXN1e (ORCPT ); Wed, 24 Jun 2020 09:27:34 -0400 IronPort-SDR: iJoK++frYMTOh4efWO2QOAjZ1sbV5DX7KAK/aE980u73ZvwTUiCjHo16Fyq+ona96pqNjIYLAp 0YD3f818uceg== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="141937117" X-IronPort-AV: E=Sophos;i="5.75,275,1589266800"; d="scan'208";a="141937117" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2020 06:27:33 -0700 IronPort-SDR: cThq9LSaBv5fKEdVFLn7tFTuH25KgEDKBA5g3Xz7GgkH8h7JFIZkBPmbgXQukHKloiaIngpn7U +2TdYLvrk33A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,275,1589266800"; d="scan'208";a="265073909" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 24 Jun 2020 06:27:33 -0700 Received: from [10.249.228.248] (abudanko-mobl.ccr.corp.intel.com [10.249.228.248]) by linux.intel.com (Postfix) with ESMTP id 4DB685805B5; Wed, 24 Jun 2020 06:27:28 -0700 (PDT) Subject: Re: [PATCH v8 07/13] perf stat: factor out event handling loop into dispatch_events() To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> <4d90938c-429a-586c-0cc7-767f804c6bce@linux.intel.com> <20200623145622.GJ2619137@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <4aa8c212-7bc7-3689-03ad-5ce6fd0e6356@linux.intel.com> Date: Wed, 24 Jun 2020 16:27:26 +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: <20200623145622.GJ2619137@krava> 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 On 23.06.2020 17:56, Jiri Olsa wrote: > On Wed, Jun 17, 2020 at 11:40:03AM +0300, Alexey Budankov wrote: >> >> Consolidate event dispatching loops for fork, attach and system >> wide monitoring use cases into common dispatch_events() function. >> >> Signed-off-by: Alexey Budankov >> --- >> tools/perf/builtin-stat.c | 35 ++++++++++++++++++++++++----------- >> 1 file changed, 24 insertions(+), 11 deletions(-) >> >> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c >> index 3bc538576607..39749c290508 100644 >> --- a/tools/perf/builtin-stat.c >> +++ b/tools/perf/builtin-stat.c >> @@ -557,6 +557,27 @@ static bool is_target_alive(struct target *_target, >> return false; >> } >> >> +static int dispatch_events(bool forks, int timeout, int interval, int *times, struct timespec *ts) >> +{ >> + bool stop = false; >> + int child = 0, status = 0; >> + >> + while (1) { >> + if (forks) >> + child = waitpid(child_pid, &status, WNOHANG); >> + else >> + child = !is_target_alive(&target, evsel_list->core.threads) ? 1 : 0; > > please renme child to something more accurate, so the condition > below makes more sense, like child_stoped or such Well, let's have it named like child_stopped. ~Alexey > > jirka > >> + >> + if (done || stop || child) >> + break; >> + >> + nanosleep(ts, NULL); >> + stop = process_timeout(timeout, interval, times); >> + } >> + >> + return status; >> +} >> + > > SNIP >