Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1522277ybt; Thu, 25 Jun 2020 08:00:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvKM3lV8BKNRr6pSZTWaRxzkEutBJyS0fPQ6FLGP00mQjDt1gzmsmKDr0pEYO5ngAUxEuw X-Received: by 2002:a05:6402:21c2:: with SMTP id bi2mr32126148edb.296.1593097216370; Thu, 25 Jun 2020 08:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593097216; cv=none; d=google.com; s=arc-20160816; b=b6tATlQow5z2q50B9F+ALslKrKh+Rrr/neRni/Y/CkUhw+GAo6HKjkBLT/EmWk2rdu zc4+s6xt/ibvXYKjRev3mDMq7Naar5+hBJFgIZhu2FUDUVEcXVKCAJfJ4/n+ifIaElq0 aS/OhHjXioAdB1gIxm6O7wdfyyJO+TkUsBzHllluzQK0dQGI+BfnLH8TlsO8UpZQlDzw QnwDFE8IQ9LyNHtOFdvus2vLk6T4QEpywJX5j8MclCiWNKHN/TC+tkUogwljPMCFo8Yh D14h+SIiQYlg+bp06S6CnRWRW+aPXyLMku+R5fM0u670gqpoEtXt7ItaKUDJxDvbKvUm lmbQ== 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=kFr0SCq/ktZee5b5gIDm+lJOXZM2g2PuuBUHMmqhJ5I=; b=PYmab1MK/QSojXzFdn6oghTDZNwF2uoC11YVnPGRHS1UALI1hd22xxYfd7DYa+p6O3 wq95S/8K0xtxdllF6NUO2ClXlq5ecdnzsXnK2hgnbknTraM0DqDJ4uSNMaiLXiczIEKF ZDwmyU28mJaCIeZjdfwzo1Ew/yaLj4IV2hvUHWhUCRH7In/vWOHh8pBjrG5bsBtXwtfP d82SlTsCTa2GXaEMK7WOR8YX2017fz2o0o/ro0SdRUqseTVPP4N6j+Ya4FL+CaAphFLR lPSu4Mx/xOnjdPJOhdF/f1YkKbB0sRYN3v3GxL8ZalnWWzetFgNiJynpLAljgFu9lD36 IYQA== 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 r14si335469eds.270.2020.06.25.07.59.52; Thu, 25 Jun 2020 08:00:16 -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 S2405669AbgFYO6K (ORCPT + 99 others); Thu, 25 Jun 2020 10:58:10 -0400 Received: from mga05.intel.com ([192.55.52.43]:20061 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405444AbgFYO6K (ORCPT ); Thu, 25 Jun 2020 10:58:10 -0400 IronPort-SDR: KPcOeI/8DTmo3bVrbUv8lk3IHC54bAofWyAVz8R6YVNZRvw6GgSDNuVe+ysQ11Z8N3UgivZKmi dQ6tiUkg7rsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="229624652" X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="229624652" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 07:58:09 -0700 IronPort-SDR: LM8O3ScfvF0Dfi6sQXb7LRZTKXcIDsQhk3psk3/8vJIsQjuKUd/hy2mG+Bu0+MpMPjyQTggR8J e8Q5lvy8I0NA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,279,1589266800"; d="scan'208";a="311120705" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP; 25 Jun 2020 07:58:09 -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 2F2BB5804B4; Thu, 25 Jun 2020 07:58:06 -0700 (PDT) Subject: Re: [PATCH v8 09/13] perf stat: implement control commands handling 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> <5ed69a1e-052a-9790-7642-cb9c9a53d786@linux.intel.com> <20200623145442.GE2619137@krava> <5d6bab4b-d743-609e-e08c-8eabcb9adfef@linux.intel.com> <20200625121453.GH2719003@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Thu, 25 Jun 2020 17:58:06 +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: <20200625121453.GH2719003@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:14, Jiri Olsa wrote: > On Wed, Jun 24, 2020 at 05:10:10PM +0300, Alexey Budankov wrote: >> >> On 23.06.2020 17:54, Jiri Olsa wrote: >>> On Wed, Jun 17, 2020 at 11:41:30AM +0300, Alexey Budankov wrote: >>> >>> SNIP >>> >>>> >>>> while (1) { >>>> if (forks) >>>> @@ -581,8 +617,17 @@ static int dispatch_events(bool forks, int timeout, int interval, int *times, st >>>> if (done || stop || child) >>>> break; >>>> >>>> - nanosleep(ts, NULL); >>>> - stop = process_timeout(timeout, interval, times); >>>> + clock_gettime(CLOCK_MONOTONIC, &time_start); >>>> + if (!(evlist__poll(evsel_list, time_to_sleep) > 0)) { /* poll timeout or EINTR */ >>>> + stop = process_timeout(timeout, 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; >>> >>> should we check time_to_sleep > time_diff first? >> >> Probably and if time_diff > time_to_sleep then time_to_sleep = 0 ? > > or extra call to process_timeout? if we dont want to call evlist_poll > with 0 timeout poll() man page says it is ok to call poll with 0 timeout so process_timeout() and initialization of time_to_sleep will be done in common flow. ~Alexey