Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp145414ybt; Mon, 6 Jul 2020 06:11:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwexmoO5bo975qARTbvwkZPbfG4i9jMFp4QuX87i30udNo35cYapOnZ0uqSLuqpS8P7u/S/ X-Received: by 2002:a05:6402:796:: with SMTP id d22mr58582803edy.78.1594041069347; Mon, 06 Jul 2020 06:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594041069; cv=none; d=google.com; s=arc-20160816; b=DBGBUTcMZ+fR8zfJRfiXWsodUSP6Xm+p9zMiuZjc49Kiu4Q8/X+Uia0JZ1/hkhbM8n QplVcV+9G7xmUVmvD8VbJTHYM0n7yDh0CfLKDZIRk4RLdtu9uPP13ratAUYSSv+gNFQs OQp+9ANp9nSqf8rcUnPXg5G+j7SFwm1TYcYoOFGeU24yGCP7LFiuBQhICPav+pARd5yr wDhbrZg7az075zEkjIk1Ks+VcTn2bssF4W+QiXQyUxo8BI9GE48LA3S9ypFg/6//LAv5 HP8VRlrtU8G/0qKEvnviGtGwSb0izzD8Ai/yeMMsBBN4KFqPIO5aodxJ+12GsQJ7oIoQ uYfw== 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=SNNONEcfl+s52qkKndnj9HFAxbH0zOFxfHXvdlFX0kw=; b=QI8Nf/ENitjrEiOggZhnmPuzuFAPP7SK03Gtxe3moSUm/lf8nAUTecfX+V/jZ8iNxR T3xr3xdoTVtok45TIR40Sb/NiOHLumnT/2gVWmmR2eQCEZkgzIvL5x6Hv0kCi6raHPqL P+3h6FVu3cQwgUch3LNnx3z56jpPuBP91KnFZz7V1tWAEnIGMOUUdSCQRtnQTmCslAxA uOdSggjzggtIxsAkHGk6Ovcvf6Qw5pIksAGAc9zkdqwQA0Yp4SaNRBVZ+HBWeosaMIXn x3RHjts17I2a1UDbzqfOXlnK5cFrIJLcml8k+wjJyQNRGMyZJ0NLc47gOD+yupI2tm19 Dr7A== 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 k27si12820203ejs.676.2020.07.06.06.10.44; Mon, 06 Jul 2020 06:11:09 -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 S1729139AbgGFNKU (ORCPT + 99 others); Mon, 6 Jul 2020 09:10:20 -0400 Received: from mga17.intel.com ([192.55.52.151]:60068 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729048AbgGFNKT (ORCPT ); Mon, 6 Jul 2020 09:10:19 -0400 IronPort-SDR: SLj7Mnz2XTPTQ89mJXCQORtU4KMghDkUbVd7xlUL+V2K/3A/1v2k3H5kAX0RJutDGE3SZzyvu6 bE6QIbkEHYUA== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="127484103" X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="127484103" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 06:10:18 -0700 IronPort-SDR: 4QI7l/L3S1SdwuCmFTFMu+6dnMHcnOhbm1mqvg4y60IowS0rGap0WYIdcQeIgFNQwqWEizbRxY 6fBTzu9qh77Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="283033062" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 06 Jul 2020 06:10:17 -0700 Received: from [10.249.225.12] (abudanko-mobl.ccr.corp.intel.com [10.249.225.12]) by linux.intel.com (Postfix) with ESMTP id C9C6B580378; Mon, 6 Jul 2020 06:10:15 -0700 (PDT) Subject: Re: [PATCH v9 11/15] 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: <21669f5a-6220-df0a-09f1-b73b32487f23@linux.intel.com> <20200706123743.GE3401866@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Mon, 6 Jul 2020 16:10:14 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200706123743.GE3401866@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 06.07.2020 15:37, Jiri Olsa wrote: > 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); Accepted. In v10. Alexey