Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp122774ybt; Mon, 6 Jul 2020 05:38:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0sjJEpclAZ43v6ZBMoFEccP+u7RCMFGXuJpdkm8sXaQDGc/G26jNj5jQ4ZYvgo8VZ8Gez X-Received: by 2002:a17:906:3945:: with SMTP id g5mr45772056eje.549.1594039124571; Mon, 06 Jul 2020 05:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594039124; cv=none; d=google.com; s=arc-20160816; b=UVqtx8SqnTvJexJdVUV3q8yXut56neZtd7gW8UNHoS3nV5ApYNgSRj9knyNHymCCrj 1CSA7mdoQRZixUiFo5ZpubryKZizYkgfsjaQapiPU1ygftoqwtQLNY3WcejA3Z0PLwbk aM+K/o60W2pBDbs/qyqpAUaIz10ZpA9EvbpmlRq61LoOeE2B2HTtI4e90nNNocDwjTF+ ewweCHjnz5PtRct2F1d+w78QjAyEvsDcFr4E5ACKcy4SwJa7mr/GONDlqJtiD98Nb0/f ec0K7judUPn0tihk93gS6fFpygMh7E+H4iMNg/htc5NLDzSUsU7jCQw0wi00z0UORBKs lkcQ== 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=9ZWpvA/NXX8o3Jj9VGVfbg95tVrVpERu9QVTRsBIkCA=; b=Kykiu4HychT7jGHEU0UMjWR/3STM/nyAqnbKlRDqrx1wn3MTiOkdzxYv3/llDHOHUj 98k9o2MsE8tb45siRtVidaA3RZgx4Z5FwhG0MUtVesfVNMyNtYhw9Wvc9IBBPbeBIVe8 Rx3nANB9rsCutKaZG9htQjVqProPOqagHRRcnm6uEu2hGI2yYNWFPUdcJOJEJRikuP/3 vnncHBt5SSrTFnAlitH2LIu+CEp6fsYgBG20HY67rkMKarVvgiFE0Njvg6aO+D2CxWvk kijT8R/m+H1AVU8Lk0A2X9tkuXXsu6XV+nF4lyZEAPTiMIW6by0HJctbjMuQvzgcDK5S w4Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BxqX+oWx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si12792072ejb.456.2020.07.06.05.38.20; Mon, 06 Jul 2020 05:38:44 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BxqX+oWx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbgGFMhv (ORCPT + 99 others); Mon, 6 Jul 2020 08:37:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40126 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728414AbgGFMhu (ORCPT ); Mon, 6 Jul 2020 08:37:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594039069; 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=9ZWpvA/NXX8o3Jj9VGVfbg95tVrVpERu9QVTRsBIkCA=; b=BxqX+oWxOoKxZUSU5NxirbHFX2qu7HDOO8x3X0dPyOPdkvsjt0UHfJYBCY38HimK2cGA73 HNFO2PAYQ2eCetVw7u9ZnEtUQYwctprO7RXeN46Mem1xFRPq1TAS62AFaRaDYOYwk9zbZf YYEqaj3Zvau47/CadMannf9h3uhnCMk= 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-193-PaXIQJN5NWqfW1xocUYseQ-1; Mon, 06 Jul 2020 08:37:47 -0400 X-MC-Unique: PaXIQJN5NWqfW1xocUYseQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87AC018FF660; Mon, 6 Jul 2020 12:37:46 +0000 (UTC) Received: from krava (unknown [10.40.193.8]) by smtp.corp.redhat.com (Postfix) with SMTP id BEF11100238E; Mon, 6 Jul 2020 12:37:44 +0000 (UTC) Date: Mon, 6 Jul 2020 14:37:43 +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 v9 11/15] perf stat: implement control commands handling Message-ID: <20200706123743.GE3401866@krava> References: <21669f5a-6220-df0a-09f1-b73b32487f23@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21669f5a-6220-df0a-09f1-b73b32487f23@linux.intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 03, 2020 at 10:47:22AM +0300, Alexey Budankov wrote: SNIP > > while (1) { > if (forks) > @@ -574,11 +610,22 @@ static int dispatch_events(bool forks, int timeout, int interval, int *times, st > if (done || stop || child_exited) > break; > > - nanosleep(ts, NULL); > - if (timeout) > - stop = true; > - else > - stop = handle_interval(interval, times); > + clock_gettime(CLOCK_MONOTONIC, &time_start); > + if (!(evlist__poll(evsel_list, time_to_sleep) > 0)) { /* poll timeout or EINTR */ > + if (timeout) > + stop = true; > + else > + stop = handle_interval(interval, times); > + time_to_sleep = sleep_time; > + } else { /* fd revent */ > + stop = process_evlist(evsel_list, interval, times); > + clock_gettime(CLOCK_MONOTONIC, &time_stop); > + diff_timespec(&time_diff, &time_stop, &time_start); > + time_to_sleep -= time_diff.tv_sec * MSEC_PER_SEC + > + time_diff.tv_nsec / NSEC_PER_MSEC; > + if (time_to_sleep < 0) > + time_to_sleep = 0; could this computation go to a separate function? something like: time_to_sleep = compute_tts(time_start, time_stop); thanks, jirka