From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8E6AC5CFFE for ; Mon, 10 Dec 2018 12:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A070820870 for ; Mon, 10 Dec 2018 12:21:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="iadHGu1Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A070820870 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727638AbeLJMVV (ORCPT ); Mon, 10 Dec 2018 07:21:21 -0500 Received: from merlin.infradead.org ([205.233.59.134]:57804 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbeLJMVV (ORCPT ); Mon, 10 Dec 2018 07:21:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ii5jUu8KY65cqCBnTcU9GjsMbZKc+9mVTzcav5zXm2c=; b=iadHGu1YhZ/f3s/Kk15LRIkEj MnMAkW55cmsBTf/AwrDbMTbK0ClsU2B3Fim7RpAQ0I7X6Oz+e9QKWw+OtYJUzMcxh21TDFIGuPuBv GTyck664C4XavZHadHKevIwA12gwhp8O4QvPZz+kpKgFgw40Kf4Brwwmnlp8TR+LE7xSuefueyrVP IuYnj5oPaEEiyGFWZXvNp0n3LIoMgotk3+vZOtiJJcgK0o0t/DmE9jOaHU58Ryz5P8O6Xf0KsVatt dawj/gV8WJb5XclciqQCFCm5bitHh/8XaoJiXAxu9JAKUhTC8B4IuKuSt+Kh1EzXZqYpn84C/Hcyo VUcP0Nwzw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWKYd-0003n3-MD; Mon, 10 Dec 2018 12:21:08 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9416A207261A4; Mon, 10 Dec 2018 13:21:04 +0100 (CET) Date: Mon, 10 Dec 2018 13:21:04 +0100 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: Linux PM , Doug Smythies , LKML , Linux Documentation , Daniel Lezcano , Giovanni Gherdovich , Lorenzo Pieralisi Subject: Re: [PATCH v2] cpuidle: Add 'above' and 'below' idle state metrics Message-ID: <20181210122104.GL5289@hirez.programming.kicks-ass.net> References: <3514439.dzOWKx1Cjx@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3514439.dzOWKx1Cjx@aspire.rjw.lan> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 10, 2018 at 12:30:23PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Add two new metrics for CPU idle states, "above" and "below", to count > the number of times the given state had been asked for (or entered > from the kernel's perspective), but the observed idle duration turned > out to be too short or too long for it (respectively). > > These metrics help to estimate the quality of the CPU idle governor > in use. > > Signed-off-by: Rafael J. Wysocki > @@ -260,6 +262,33 @@ int cpuidle_enter_state(struct cpuidle_d > dev->last_residency = (int)diff; > dev->states_usage[entered_state].time += dev->last_residency; > dev->states_usage[entered_state].usage++; > + > + if (diff < drv->states[entered_state].target_residency) { > + for (i = entered_state - 1; i >= 0; i--) { > + if (drv->states[i].disabled || > + dev->states_usage[i].disable) > + continue; > + > + /* Shallower states are enabled, so update. */ > + dev->states_usage[entered_state].above++; > + break; > + } > + } else if (diff > delay) { > + for (i = entered_state + 1; i < drv->state_count; i++) { > + if (drv->states[i].disabled || > + dev->states_usage[i].disable) > + continue; > + > + /* > + * Update if a deeper state would have been a > + * better match for the observed idle duration. > + */ > + if (diff - delay >= drv->states[i].target_residency) > + dev->states_usage[entered_state].below++; > + > + break; > + } > + } One question on this; why is this tracked unconditionally? Would not a tracepoint be better?; then there is no overhead in the normal case where nobody gives a crap about these here numbers.