Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1831401ybb; Thu, 2 Apr 2020 08:08:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKLU43GwEeBb4ZoZa8JHI/EP89xzmQwoiUY5jm8aEJbMOyOsy5rxZ0PmrB26FCSO8Uc43MV X-Received: by 2002:a05:6830:1e79:: with SMTP id m25mr2713808otr.36.1585840138529; Thu, 02 Apr 2020 08:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585840138; cv=none; d=google.com; s=arc-20160816; b=h5oQbx07ZGh3Y0g0n9IIS9WaTnsCDvfTUUFMzMCQM1sPbhLNmp2/WMc0YGZt6n05sa sKmyvmnshkqoCiX2yCypTyHB4AUFp3RoqAo6x0oxMxAoFY2O4cLokQ0O0f8fZm9wjw60 d29ub6zCnB1CCvQW7EGoqyAuhFkYNHDSgzCVwANChu1HcDqBjP1S7zYmZO61xpY1pPHe oOM5YqQxVRldVS21gNviiHiIifJ4n6eMYZwIhcq03txWG2Lm0KvPPjMMH96Z5jIjXn2K w6NHI+7uHN3tbWWsL6LNqbYKPdneQHk7uJfQm3W0Fv6X8pK4UaRT/DmW61kzGt5gYfPf ysXg== 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=ZN4J7hm0XQpy6xBl13tsQqj3YYH8R41vNByV2ZHagKg=; b=xTh55ib7bf/DlzH8dDNMJsptGQusnbjwZ3XAoraO6e1Sd/8Ii4X+/2u4B4tslxeIwG Egok/RWaIC04Lj0hwXySvGUGPN1ZEceNExvTI6cRaqb86k1YnS//7FE3TsFlfnWv1cgv WMGExIyC/8YSHfSEcNZQmIydiNNCphosZ0Ec7cYUgNxdcX+cppgPAjS0emJLEpmPPLnj pWwbUmJWNR5CVq05fLTc3vpOzhrznZylE714OnmIyOozAJtm9KR/FFWa2zluclXP80p0 01ReQVOFfB1R127MvajnjpuYM7ijKlAVzh86eFZGXZiRmlSD4VSKL8tqGnyUFn/HFQ2F qjkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u10si2390317oib.91.2020.04.02.08.08.39; Thu, 02 Apr 2020 08:08:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2389198AbgDBPGv (ORCPT + 99 others); Thu, 2 Apr 2020 11:06:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:37176 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388909AbgDBPGv (ORCPT ); Thu, 2 Apr 2020 11:06:51 -0400 IronPort-SDR: snwEHxhRBeF8lZ7LFcTeE409nSrPgzp7X6CDrd0EzrbqPugLA2Fxt6/DTw5rvy0tvJ77HPrOFN h1XGrhurSXXw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 08:06:50 -0700 IronPort-SDR: fNlonlI0I89sk9q/XBqo6eeO98honIyGDlA1N2Hj0K9KjBM3a27BXb+O27SLJpc9gexbriXSzV PJaQFJA4McOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,336,1580803200"; d="scan'208";a="396396983" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 02 Apr 2020 08:06:50 -0700 Received: from [10.249.226.252] (abudanko-mobl.ccr.corp.intel.com [10.249.226.252]) by linux.intel.com (Postfix) with ESMTP id B4FA85802C8; Thu, 2 Apr 2020 08:06:48 -0700 (PDT) Subject: Re: [PATCH v1 4/8] perf stat: implement resume and pause control commands handling To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <825a5132-b58d-c0b6-b050-5a6040386ec7@linux.intel.com> <20afb83b-efc4-6cba-6512-eebbb4e0707a@linux.intel.com> <20200402141740.GO2518490@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <6853c0bd-3659-12ce-dfc3-b2d8c655a0d4@linux.intel.com> Date: Thu, 2 Apr 2020 18:06:47 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200402141740.GO2518490@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 02.04.2020 17:17, Jiri Olsa wrote: > On Fri, Mar 27, 2020 at 11:48:31AM +0300, Alexey Budankov wrote: > > SNIP > >> >> - if (interval) { >> - ts.tv_sec = interval / USEC_PER_MSEC; >> - ts.tv_nsec = (interval % USEC_PER_MSEC) * NSEC_PER_MSEC; >> - } else if (timeout) { >> - ts.tv_sec = timeout / USEC_PER_MSEC; >> - ts.tv_nsec = (timeout % USEC_PER_MSEC) * NSEC_PER_MSEC; >> - } else { >> - ts.tv_sec = 1; >> - ts.tv_nsec = 0; >> - } >> - >> if (forks) { >> if (perf_evlist__prepare_workload(evsel_list, &target, argv, is_pipe, >> workload_exec_failed_signal) < 0) { >> @@ -688,18 +745,10 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) >> perf_evlist__start_workload(evsel_list); >> enable_counters(); >> >> - if (interval || timeout) { >> - while (!waitpid(child_pid, &status, WNOHANG)) { >> - nanosleep(&ts, NULL); >> - if (timeout) >> - break; >> - process_interval(); >> - if (interval_count && !(--times)) >> - break; >> - } >> - } >> - if (child_pid != -1) >> + if (stat_config.ctl_fd == -1 && !interval && !timeout) >> wait4(child_pid, &status, 0, &stat_config.ru_data); >> + else >> + status = handle_events(child_pid, &stat_config); >> >> if (workload_exec_errno) { >> const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); >> @@ -711,18 +760,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) >> psignal(WTERMSIG(status), argv[0]); >> } else { >> enable_counters(); >> - while (!done) { >> - nanosleep(&ts, NULL); >> - if (!is_target_alive(&target, evsel_list->core.threads)) >> - break; >> - if (timeout) >> - break; >> - if (interval) { >> - process_interval(); >> - if (interval_count && !(--times)) >> - break; >> - } >> - } > > could you please separate the change to have: > - factor out the above too loops to the new function > - adding control fds handling to that function > > so it's more obvious we don't break anything Accepted. ~Alexey