Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp276898ybg; Mon, 1 Jun 2020 00:41:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+dVFZAmjfJZL/a9hsrHRhRzpJrfsqQorTcC4a+J+aC5//QAFrIVa1wrLLbPvQhtcElWJN X-Received: by 2002:a17:906:d043:: with SMTP id bo3mr17670896ejb.409.1590997319714; Mon, 01 Jun 2020 00:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590997319; cv=none; d=google.com; s=arc-20160816; b=QSZ/QGTGc2iybYNuLr/Y+KGjQxwSibOMAWCSsUYwyKynzSerDjxkBCiYxDq9n4yaPD 8qK3rmMRlOBBThQRcpMaTi5VOhlgqrWwpp1bmyEUtJV9dqMQ4u1USU7BcN9KCjfPfCBA dke1zil5ZI9PDjKemw0lpMVxZ9CGYV6GARXBsYPtavfKvsQ4NjatyPydUKmQdnO7yop4 0yFqiDbKe5EL4mq/ylgHWmtSRbHr5trBD5li39jw2vU+7FrC57O1JAlNj3RMJLUgsC0w PAdfVbjb5t/Lnp3uqvKBpSmEpf/IgveJwFE0Wb6cjOJ2NpG7ej4YeS2Yv5py9H2zaprd xEWA== 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=DiJ7IApmmCo6b0o8BOC2dUyr4TvvQckhvf9WydPJ9R4=; b=khAA360TDffYXR2ZTmQU/X+W7wB1kcO7h+aI2VLdi31D1aNNyMWOoY73DjbyR6azpO 0eErd1yl/rqxK6dE6z8qV3JYlga5zyp1BHa27rlrHMdbtmxpV291H1UuXS2+Z3Mr2S6Q t21KjIge+/SjECsyqWob+0KqdSPxmiWmGLHuBdzfrY4/gMELXTpqimLTiEFiUCC1/+E3 KCcmjK5dR6KrVpRpHv+4C0CdNauoHROWp206Jnf2v9Ua80RMcd9UxfEZL34gKGW3J/f1 z4hRmZiTfrL1icsDbhpgI+EHjrdTcZxQetJ0bIOd/4/DrU/muQWkIrvxxm5sD5Jiz9jy pWmA== 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 z9si1845450ejm.47.2020.06.01.00.41.36; Mon, 01 Jun 2020 00:41:59 -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 S1727814AbgFAHiy (ORCPT + 99 others); Mon, 1 Jun 2020 03:38:54 -0400 Received: from mga11.intel.com ([192.55.52.93]:18830 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbgFAHix (ORCPT ); Mon, 1 Jun 2020 03:38:53 -0400 IronPort-SDR: RO+u2b1ILQCR87Orlc5/P0Ml/wyyGwWOiNGw9w5XRMvSU70T6PG05NmYTdNaJy0KPOSjcCbCOz dYn4zQpFYxwg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 00:38:53 -0700 IronPort-SDR: oTr7efKpF1LBjHvugbQV1jWKZFQHAaTL2jTKz+wm3tcKNJ7aiGxoJfVQzn6M6RA9Ecb/xFUEFt WRaVUcnQIfiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,460,1583222400"; d="scan'208";a="271912796" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 01 Jun 2020 00:38:53 -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 45D39580522; Mon, 1 Jun 2020 00:38:50 -0700 (PDT) Subject: Re: [PATCH v4 04/10] perf stat: factor out event handling loop into a function To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> <5f42c6c5-c301-accd-928e-4304fb1c15d0@linux.intel.com> <20200531181905.GB881900@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <63f1e2dd-ca1d-125a-cb83-d89f40433edc@linux.intel.com> Date: Mon, 1 Jun 2020 10:38:49 +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: <20200531181905.GB881900@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 31.05.2020 21:19, Jiri Olsa wrote: > On Mon, May 25, 2020 at 05:19:45PM +0300, Alexey Budankov wrote: > > SNIP > >> @@ -544,12 +598,10 @@ static enum counter_recovery stat_handle_error(struct evsel *counter) >> static int __run_perf_stat(int argc, const char **argv, int run_idx) >> { >> int interval = stat_config.interval; >> - int times = stat_config.times; >> int timeout = stat_config.timeout; >> char msg[BUFSIZ]; >> unsigned long long t0, t1; >> struct evsel *counter; >> - struct timespec ts; >> size_t l; >> int status = 0; >> const bool forks = (argc > 0); >> @@ -558,17 +610,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) >> int i, cpu; >> bool second_pass = false; >> >> - 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) { >> @@ -725,16 +766,9 @@ 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 (interval || timeout) >> + dispatch_events(child_pid, &stat_config); >> + >> if (child_pid != -1) { >> if (timeout) >> kill(child_pid, SIGTERM); >> @@ -751,18 +785,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; >> - } >> - } >> + dispatch_events(-1, &stat_config); > > hum, from the discussion we had on v3 I expected more smaller patches > with easy changes, so the change is more transparent and easy to review > > as I said before this part really makes me worried and needs to be as clear > as possible.. please introdce the new function first and replace the factored > places separately, also more verbose changelog would help ;-) Ok. Will try to reshape the patch that way. ~Alexey