Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1786162ybb; Thu, 2 Apr 2020 07:21:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJs2kRMabG7Dnwos+KseJJOKT6JY0rvaGu2adZTu9WMN9XvdGm6CuJrKc/LUf9cRZbDDnsG X-Received: by 2002:aca:4046:: with SMTP id n67mr2454541oia.156.1585837310261; Thu, 02 Apr 2020 07:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585837310; cv=none; d=google.com; s=arc-20160816; b=NiB8R+4PX4Hl+15FjxtbTJVYwmG1I5rmyKi/H5fTFUcl3BVZDkscMDlkIa9XjuJDwQ i0woRSTuc3KxQPhMPctetDS3CWmFS3wKfve1cnqE1p0X5mnRBzakMy9UuCZT6OIPzKVw wIv24bnTkB88uAa82WHmnAmoR2BDz3fWHXV+X3Z4FXzSK6pjWkkGxPZTv5vK+2A5K6zM ukAyg2TRnuXa7wzEkSa+Dki51sUOlTttPeeE7h83yV8wMnEROYbGyhW8/9vBkhj5MbBZ koyHVtV6xr1IuDc0VDlfdtoKEJra6Z466Eae2YPPJcOJbb1tXBrmnJx9f18Wo/m26afB sUVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=BGk/XdTx2AmaoUi8dVZJyPw/8pIQ5+8d5IHVPpIgBvk=; b=Ybv4LdlL2eeiKF8lCIPXohTjbaKVSNo8ruHXr0uef73NM6W688zeu/42oqQMxzIfH9 rTfqZdaKbfraFMjZtShp0Y72/9jVabCAjsfdIW+UWES0aRX5/8dvfWuGTbiIIO019n48 nLh63TeYFVbqiBGKfj13477oqa5SDxc5mQZRHp9+1xBVT1wf1pQ8RndTh0vvl0lWEHYL cuzhctNR0xSG1DpbC2HeQGfn9yGywkxAwH2tnRKEirti5CqbcDq38oPMCmSP2dLRHoUp MKRDyV0jwbNw6sI59ISdSLEJR1xkCQmv8V3M88MmxXVaspGZjdQOi/ngoMIcM7iLf27i nITg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dFoewix3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r70si2426782oor.49.2020.04.02.07.21.37; Thu, 02 Apr 2020 07:21:50 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dFoewix3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733014AbgDBOSC (ORCPT + 99 others); Thu, 2 Apr 2020 10:18:02 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:38260 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729213AbgDBOSC (ORCPT ); Thu, 2 Apr 2020 10:18:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585837080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BGk/XdTx2AmaoUi8dVZJyPw/8pIQ5+8d5IHVPpIgBvk=; b=dFoewix3GVlhLi/47Sj8tyeUuiIYj7tg5x8LXA6f/g0rV1AJPVy+S42QcInjzXlOoq/sBH a5CtbjhVIbvZlnrNff02jhd6KAa1wcOcpp+9sGIq9delQxSO4Oel+vvZIo+YPqT7m9TZ6x /6SL0IpQpxdu2Okylu5YitU10G8+i4o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-EuI1sNs8MkOs_7zZZeWt6Q-1; Thu, 02 Apr 2020 10:17:58 -0400 X-MC-Unique: EuI1sNs8MkOs_7zZZeWt6Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71861801A22; Thu, 2 Apr 2020 14:17:44 +0000 (UTC) Received: from krava (unknown [10.40.194.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A18B999E08; Thu, 2 Apr 2020 14:17:42 +0000 (UTC) Date: Thu, 2 Apr 2020 16:17:40 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v1 4/8] perf stat: implement resume and pause control commands handling Message-ID: <20200402141740.GO2518490@krava> References: <825a5132-b58d-c0b6-b050-5a6040386ec7@linux.intel.com> <20afb83b-efc4-6cba-6512-eebbb4e0707a@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20afb83b-efc4-6cba-6512-eebbb4e0707a@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 thanks, jirka > + handle_events(-1, &stat_config); > } > > disable_counters(); > -- > 2.24.1 > >