Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1952488imu; Tue, 6 Nov 2018 06:55:34 -0800 (PST) X-Google-Smtp-Source: AJdET5d/eGJbnX1x2X/G1N+OjT+KIKTPNjKgB/QLepmttoaDtbo0UdfAjMJB1cYjalhWzJ9g4rVw X-Received: by 2002:a17:902:bb89:: with SMTP id m9-v6mr23918279pls.66.1541516134150; Tue, 06 Nov 2018 06:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541516134; cv=none; d=google.com; s=arc-20160816; b=icL5NxiazkAFytQ60auPD+FOFks04VbzndaHyb0R61DZs2eZ0d5bSop9xcmNrAIjKO asMmvWg8WwORG28u9MEbyF5AHpIBCB/L7+V8r/aSl5EDETs/jweulStZzllgDMvo9yCM lDFAIXqz1zmuw7JahcPPYDcNHlgHbiHVLL+ee3c0pWLctvvfIm5ExrmLFzagpfVwLGa1 GNHytCW6M1gekXWpI9RnufadFGw/z8NxLHQu3KARb9a3Qc/2cIfNRw7gMyK5cDtfWszx h8d9STu8SihO2qgc/F00JIN561JIDhDL1RsEyjmkgTmjZmSqBX143shXfwVZsWJ07+cg z76w== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=161lWxM17fE4AirmTLLCwe4wcwkSQpjLiCkqPVsHQXc=; b=hd8903pHENUX1i13Tt2cx9+GYHWGtybc6UeFzcWJFa5K4gYOymJSEyZ8hmeiLjD3ID L3pVOvKrLAzguz9Wriij9DJD5texnhua8Oyg7Il8w2r09aFUYcc+EmoSXM6WUvlnsDsR aEr2Wq3yOfv53RbNWA8kx7WVvMvwKRtTYTrm+SUT+iJ2l49E6UhcCrR2TywBkymnwkJK dAf8+J6c1QA9TXlyppvrJY2MRWki4eSLgNEBr7gFAC8ABWEwGbGCScoZZZ6JeHizwIsQ E9Y8RXvZuNsBapuCLVFY5gGdMHrcIvc4beFHYd2KyI79iyjVkqYMqmtztyiQ6uXqkb7s LcGQ== 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 o10-v6si45901077plk.295.2018.11.06.06.55.18; Tue, 06 Nov 2018 06:55:34 -0800 (PST) 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 S2389073AbeKGAU0 (ORCPT + 99 others); Tue, 6 Nov 2018 19:20:26 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:60519 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388908AbeKGAU0 (ORCPT ); Tue, 6 Nov 2018 19:20:26 -0500 Received: from 79.184.254.59.ipv4.supernova.orange.pl (79.184.254.59) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.148) id 4976b71bd06d0710; Tue, 6 Nov 2018 15:54:49 +0100 From: "Rafael J. Wysocki" To: Giovanni Gherdovich Cc: Linux PM , Doug Smythies , Srinivas Pandruvada , Peter Zijlstra , LKML , Frederic Weisbecker , Mel Gorman , Daniel Lezcano Subject: Re: [RFC/RFT][PATCH v3] cpuidle: New timer events oriented governor for tickless systems Date: Tue, 06 Nov 2018 15:55:06 +0100 Message-ID: <6592350.ldnZvJegIa@aspire.rjw.lan> In-Reply-To: <1541446371.3441.9.camel@suse.cz> References: <1556808.yKVbhZSazi@aspire.rjw.lan> <1541446371.3441.9.camel@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, November 5, 2018 8:32:51 PM CET Giovanni Gherdovich wrote: > On Sun, 2018-11-04 at 17:31 +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > [cut] > > + > > +/** > > + * teo_update - Update CPU data after wakeup. > > + * @drv: cpuidle driver containing state data. > > + * @dev: Target CPU. > > + */ > > +static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) > > +{ > > + struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu); > > + unsigned int sleep_length_us = ktime_to_us(cpu_data->sleep_length_ns); > > + int i, idx_hit = -1, idx_timer = -1; > > + unsigned int measured_us; > > + > > + if (cpu_data->time_span_ns == cpu_data->sleep_length_ns) { > > + /* One of the safety nets has triggered (most likely). */ > > + measured_us = sleep_length_us; > > + } else { > > + measured_us = dev->last_residency; > > + i = cpu_data->last_state; > > + if (measured_us >= 2 * drv->states[i].exit_latency) > > + measured_us -= drv->states[i].exit_latency; > > + else > > + measured_us /= 2; > > + } > > + > > I haven't read this v3 yet, The pattern detection code in it has a minor issue that needs addressing, so I'm going to send a v4 later today (after testing it somewhat). > so just a little comment on the bit above (which > is there since v1). To be precise, this piece is there in the menu governor too and I thought that it made sense, so I copied it from there. :-) > When you check for measured_us >= 2 * exit_latency, is that because > dev->last_residency is composed by an "entry" latency, then the actual > residency, and finally the exit_latency? I'm asking about the 2x factor > there. If measured_us is less than twice the state's exit latency, the difference between it and the exit latency may be very small, so it is better to take a half of it then as an upper bound estimate of it in case there are some inaccuracies in the measurement. > If that succeeds, you proceed to remove the exit_latency from > measured_us... just once. Given how the condition is formulated, I expected > measured_us -= 2 * exit_latency there. The exit latency is subtracted once, because we are interested in the time between asking the hardware to enter the idle state and the wakeup event. The exit latency is the time between the wakeup event and the first instruction, so it shouldn't be counted, roughly speaking. > More: you acknowledge, in that snippet of code, that there can be > dev->last_residency's smaller than twice the exit_latency, i.e. not even the > time to entry/exit the state. Am I reading this right? Is that because both > exit_latency and dev->last_residency are only approximations? Yes, they are just approximations. > I actually see quite a few of those extra-short residencies in my traces, even > with dev->last_residency < exit_latency. Well, they are expected to occur at least occasionally. Cheers, Rafael