Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1669297ybt; Thu, 25 Jun 2020 11:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywJeIGsqrqeeRdn32SqTZCMO3gtqEGOUO7dfOBSAUYwqFmiXT4csvdBFA16H5nDh8ayqwJ X-Received: by 2002:a17:906:748:: with SMTP id z8mr2053037ejb.257.1593108858384; Thu, 25 Jun 2020 11:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593108858; cv=none; d=google.com; s=arc-20160816; b=CmxqDB1OJcGaMXIPthhGMBk6m7XmQAIpYp6XIhuMm1jbiS41UGwy+ivabbI6LlOOjD yyPv/AFucPF0hNsEG/cMQ9YKPm+QYpo8/IAbY5f0Jvvq5p804wqbZsxGZjqHIofp9aVm A6+Y0DatCVKpAXFIXgPlZ1xoz05KBti3YDrZXCxm71qeKtUypMjjRZBBbH0ouwPJjznn 3fOs1Nbzwp+oIZ7BvS7qG6Elf1JT5o4gRJfeRRF2PrqB8Lz68LyaLTUhOj/em4+7qtR3 511Rk2wJUqOLA3y/qZQFggV01XwwQ9+PCGE+g0gZPr2W4fwMbMQgDHugqDY4scCYZqDQ Ms3w== 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=LIZ50pSGwd2twgJ/CdLpwlncNFbUZWUFeRKFGVT7Jes=; b=h4o1tWKQQk1uz9928tcNbiLAHGm9FNzMazLksG6MgIbSBhIPOoG1DZEzHxfjIXDOKE PvSLleMFjsZjfWWYXBPqkw8j+d9VH9eC5F5oofwhBSIUSKbo3uY2WKwrcFZL/RS5r/mN 6z3lfBqyBGxKCzyZFC4/6rGafohIJOEg7WxaJEGPd5FlB2edujiZ9Av6+gWJ9y7HbiSf CsadkjO8wrva7YDu3ODvu2DlHH70X1se157TufbyWp63PIyhvbOguGAXLEDPzwR06xS5 MuRgzNd0fH4IKDMNVMKZWy29h5g8M6ddh86Fvtop4rjoHk1rbb3GXRv0fJdvou0cpKBT T6eQ== 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 h25si8068331edv.231.2020.06.25.11.13.54; Thu, 25 Jun 2020 11:14:18 -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 S2390697AbgFYQBX (ORCPT + 99 others); Thu, 25 Jun 2020 12:01:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:8994 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389860AbgFYQBX (ORCPT ); Thu, 25 Jun 2020 12:01:23 -0400 IronPort-SDR: wvsPCB3kDduSRBI331zVH+XSJnddDkk8j6qg9DMLt63ATMFG4KCgjRD5i+Xiob9ZqCI41F9yn7 LkkhiJi7ILZA== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="210045459" X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="210045459" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 09:01:12 -0700 IronPort-SDR: CsQygifcDk8DFAey5CQ6LeHuWnnplDbIaS7GGyUPOy5hXwKJNkUbqOCkMF+MZf9XogK5icvkpg 3IbgctGxI+Cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="297634961" Received: from linux.intel.com ([10.54.29.200]) by orsmga007.jf.intel.com with ESMTP; 25 Jun 2020 09:01:11 -0700 Received: from [10.249.229.54] (abudanko-mobl.ccr.corp.intel.com [10.249.229.54]) by linux.intel.com (Postfix) with ESMTP id 0EFE45804D6; Thu, 25 Jun 2020 09:01:09 -0700 (PDT) Subject: Re: [PATCH v8 04/13] perf stat: factor out body of event handling loop for system wide 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> <20200623145630.GK2619137@krava> <51d5511a-e9a7-2865-c81b-57488e820f8d@linux.intel.com> <20200625121719.GI2719003@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Thu, 25 Jun 2020 19:01:08 +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: <20200625121719.GI2719003@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 25.06.2020 15:17, Jiri Olsa wrote: > On Wed, Jun 24, 2020 at 05:27:41PM +0300, Alexey Budankov wrote: >> >> On 23.06.2020 17:56, Jiri Olsa wrote: >>> On Wed, Jun 17, 2020 at 11:37:43AM +0300, Alexey Budankov wrote: >>>> >>>> Introduce process_timeout() and process_interval() functions that >>>> factor out body of event handling loop for attach and system wide >>>> monitoring use cases. >>>> >>>> Signed-off-by: Alexey Budankov >>>> --- >>>> tools/perf/builtin-stat.c | 28 ++++++++++++++++++++-------- >>>> 1 file changed, 20 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c >>>> index 9be020e0098a..31f7ccf9537b 100644 >>>> --- a/tools/perf/builtin-stat.c >>>> +++ b/tools/perf/builtin-stat.c >>>> @@ -475,6 +475,23 @@ static void process_interval(void) >>>> print_counters(&rs, 0, NULL); >>>> } >>>> >>>> +static bool print_interval(unsigned int interval, int *times) >>>> +{ >>>> + if (interval) { >>>> + process_interval(); >>>> + if (interval_count && !(--(*times))) >>>> + return true; >>>> + } >>>> + return false; >>>> +} >>>> + >>>> +static bool process_timeout(int timeout, unsigned int interval, int *times) >>>> +{ >>>> + if (timeout) >>>> + return true; >>>> + return print_interval(interval, times); >>>> +} >>> >>> I think it's confusing to keep this together, that >>> process_timeout triggers also interval processing >>> >>> I think you can keep the timeout separated from interval >>> processing and rename the print_interval to process_interval >>> and process_interval to __process_interval >> >> Well, ok. >> >> I will rename process_interval() to __process_interval() and >> then print_interval() to process_interval(). >> >> Regarding timeout let's have it like this: >> >> static bool process_timeout(int timeout) >> { >> return timeout ? true : false; >> } > > can't this just stay as value check after finished poll? > > if (timeout) > break; > > and then separate call to process_interval(interval, times)? Like this? Still makes sense to have it in a single function. static bool process_timing_settings(int timeout, unsigned int interval, int *times) { bool res = timeout ? true : false; if (!res) res = process_interval(interval, times); return res; } ~Alexey