Received: by 10.223.164.221 with SMTP id h29csp183949wrb; Mon, 16 Oct 2017 00:45:21 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDAOCJdqzxDCsy4fZnlJGIMKUmps3NEMbY6vAMK+AJsRJQ6awEQd4FEzszJDQrw/9eRCjG3 X-Received: by 10.98.166.204 with SMTP id r73mr8107748pfl.259.1508139921731; Mon, 16 Oct 2017 00:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508139921; cv=none; d=google.com; s=arc-20160816; b=XiaLh1c+TUNFXNgw88zT1ttwUTkFSJ0jFA0bKYLGA9aEIL2jB/I0ohcfYvcPxSZwF2 PGww9paXFPRyEMOBnaO7FddXgPimT1h56YrLGMuXk4Hv9Mz+S/oBOIqobIAzgZfjr2Rq khM1VWjd8D+7FHY70sEbAQ6SOqM1QDJKPYdn6mkcdVl8581j4mnfXl7F1dkWSVhBQtj8 61gSIefxocJ/UPm8Hc24kJn+sXDxoFJmCaaJ3US04d1JqDZyzEcFnoYr0N8a1FdGg1dr 1o4ME/cDFIR54bm4KSQEg6Juj+pblYxbMZj7OIaIkTRFPXfLc8cIDlaC7ccCMy2Lr3FY yDJw== 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:from:references:cc:to:subject:arc-authentication-results; bh=fBm5NvgzCRrN9PTEmeSlGJCnoHsoFvguIHmovrvEDec=; b=BS9baJLMIO/i6S6Pz4ErQvjoQz7+NPPCbA7ZTZThG/XbhcQiahQ4xat5jb4cKJ7RV+ uFyyex2zI/78SBf6SN5QVvsO0S26o9IETNHOLYEqUWRFq1Ha3pEFWm5dY8nKp80Zurft SZhvHz5iu3Hv0YsaUwryjwsQhB2ZzmNiI7qnNkh4+OrFu+0KjSMYt9XhKJhpeV4Aqt97 cuv5hLcnDI26aLTNU2UMl/Sb99SxiCvNPcwZ4hsTrGZ+TOawc19tbNaBhL7V+KV2ofdU 3ZTgHYBuiIPunXlMf+XKf6m/PdyVGqpu/WX3lwIwp0xaPYdD89fIiu/AHKoX/mGlXEdd zcNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si3642721pld.596.2017.10.16.00.45.07; Mon, 16 Oct 2017 00:45:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbdJPHoq (ORCPT + 99 others); Mon, 16 Oct 2017 03:44:46 -0400 Received: from mga03.intel.com ([134.134.136.65]:25839 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750914AbdJPHoo (ORCPT ); Mon, 16 Oct 2017 03:44:44 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2017 00:44:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,386,1503385200"; d="scan'208";a="163067472" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.13.116]) ([10.239.13.116]) by fmsmga005.fm.intel.com with ESMTP; 16 Oct 2017 00:44:42 -0700 Subject: Re: [RFC PATCH v2 0/8] Introduct cpu idle prediction functionality To: "Rafael J. Wysocki" , Aubrey Li Cc: tglx@linutronix.de, peterz@infradead.org, len.brown@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1506756034-6340-1-git-send-email-aubrey.li@intel.com> <3026355.QRuoy6eIZM@aspire.rjw.lan> From: "Li, Aubrey" Message-ID: Date: Mon, 16 Oct 2017 15:44:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <3026355.QRuoy6eIZM@aspire.rjw.lan> 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 2017/10/14 9:14, Rafael J. Wysocki wrote: > On Saturday, September 30, 2017 9:20:26 AM CEST Aubrey Li wrote: >> We found under some latency intensive workloads, short idle periods occurs >> very common, then idle entry and exit path starts to dominate, so it's >> important to optimize them. To determine the short idle pattern, we need >> to figure out how long of the coming idle and the threshold of the short >> idle interval. >> >> A cpu idle prediction functionality is introduced in this proposal to catch >> the short idle pattern. >> >> Firstly, we check the IRQ timings subsystem, if there is an event >> coming soon. >> -- https://lwn.net/Articles/691297/ >> >> Secondly, we check the idle statistics of scheduler, if it's likely we'll >> go into a short idle. >> -- https://patchwork.kernel.org/patch/2839221/ >> >> Thirdly, we predict the next idle interval by using the prediction >> fucntionality in the idle governor if it has. >> >> For the threshold of the short idle interval, we record the timestamps of >> the idle entry, and multiply by a tunable parameter at here: >> -- /proc/sys/kernel/fast_idle_ratio >> >> We use the output of the idle prediction to skip turning tick off if a >> short idle is determined in this proposal. Reprogramming hardware timer >> twice(off and on) is expensive for a very short idle. There are some >> potential optimizations can be done according to the same indicator. >> >> I observed when system is idle, the idle predictor reports 20/s long idle >> and ZERO fast idle on one CPU. And when the workload is running, the idle >> predictor reports 72899/s fast idle and ZERO long idle on the same CPU. >> >> Aubrey Li (8): >> cpuidle: menu: extract prediction functionality >> cpuidle: record the overhead of idle entry >> cpuidle: add a new predict interface >> tick/nohz: keep tick on for a fast idle >> timers: keep sleep length updated as needed >> cpuidle: make fast idle threshold tunable >> cpuidle: introduce irq timing to make idle prediction >> cpuidle: introduce run queue average idle to make idle prediction >> >> drivers/cpuidle/Kconfig | 1 + >> drivers/cpuidle/cpuidle.c | 109 +++++++++++++++++++++++++++++++++++++++ >> drivers/cpuidle/governors/menu.c | 69 ++++++++++++++++--------- >> include/linux/cpuidle.h | 21 ++++++++ >> kernel/sched/idle.c | 14 ++++- >> kernel/sysctl.c | 12 +++++ >> kernel/time/tick-sched.c | 7 +++ >> 7 files changed, 209 insertions(+), 24 deletions(-) >> > > Overall, it looks like you could avoid stopping the tick every time the > predicted idle duration is not longer than the tick interval in the first > place. > > Why don't you do that? I didn't catch this. Are you suggesting? if(!cpu_stat.fast_idle) tick_nohz_idle_enter() Or you concern why the threshold can't simply be tick interval? For the first, can_stop_idle_tick() is a better place to skip tick-off IMHO. For the latter, if the threshold is close/equal to the tick, it's quite possible the next event is the tick and no other else event. Thanks, -Aubrey From 1581194181131083749@xxx Sat Oct 14 01:24:39 +0000 2017 X-GM-THRID: 1579948553110255952 X-Gmail-Labels: Inbox,Category Forums