Message ID | 20230728145808.970594909@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp517155vqg; Fri, 28 Jul 2023 08:35:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcobb2eMI3G3FYlvl5En1DdFyriqs4luQNty/MGAZGg6RHaOueU+eGnoX6M17uOEp+CiVd X-Received: by 2002:a17:902:c40f:b0:1bb:a4e4:54b6 with SMTP id k15-20020a170902c40f00b001bba4e454b6mr2609034plk.62.1690558503968; Fri, 28 Jul 2023 08:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690558503; cv=none; d=google.com; s=arc-20160816; b=y/YBvtIDmtkrm2mI4hJuYg7ysvTFYze9rj2uiH9zUXTqfWTM30bYZL1dwQ0iZkTqIc WRvbYQhibSMQk10UPARPMj9CgOsqDzsEkmfIN4zmUNCSbgtAwxqlW+TaaB92QMCa8vro NsCluNYjec2q7DGjQ+uB92gq952u2pVZ2idPPPHBcYhfdttIXIeDNP+Dp7zXYN0maMeJ CIGlAJQEv4pXq9bPdMdKqyPnESCi4T3s1jR1ZboYTp+vHxTyL9Ctk7rGRXzGses8ISrk cNtJBAc2SE/7T/nbNy966hAzj/FVA23hA24PBkorAh96WbAFlcGwRmdhJQj08aP3NMDP LJoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=gRhD2DL6Ofjvx8HyJGzSmAjib8RktDFYPANPb4xvXOo=; fh=0hiOkE06jcy/VqUxYDS6cCN+IjKlOJ21bEwL6x6WXH4=; b=g4+Z2l+ukt86GcV8w1mDLnVZNIkiAvcde0cYBl/78dYrqEeK9DqrA+ypXQMZZ302Dr jOtP+T+ZEobq8vfIUrXMAPdJqdx4u3/6f+S5MSAt9zz78VReqZOOlFyX/+za9VAWFVBi WBjSrc8FJ2/NcaTx9FSuHfA9UlG4fSOxenBw5wuvR5XsvwoxxS1aASqFTIHnofgS1jS7 HyKKAEPmP29glhxdoIlc1L6abFE6JrIICW0pfr5KamzFozlsAm8Dnio/CtSu3X26/+9L 5Apu3FuWGoeK4av9gKiDxq0YtqTBLdxod2+BtE9E4TmDt7ke4Be3ZTsTOsK2Yt2fZPB3 ZsbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=mCkhvZeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a170902f10b00b001b231cb6f22si3142024plb.111.2023.07.28.08.34.45; Fri, 28 Jul 2023 08:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=mCkhvZeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237212AbjG1PBS (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Fri, 28 Jul 2023 11:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235681AbjG1PBM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Jul 2023 11:01:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E95261FFF; Fri, 28 Jul 2023 08:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=gRhD2DL6Ofjvx8HyJGzSmAjib8RktDFYPANPb4xvXOo=; b=mCkhvZeGlFt1058W/ij5hj0eV+ M9v9w7L774A6WoeeEWBGOXJwQqrSueynX/n1HidtSv7gWRvfkI/Kpf+GXmezXtMDbmth9XWL2SfuW bS3z0zgKDvV7ZoKuECyshz4tz5Wymm5FR8N9VNr9X8uXqogWa9muXJnyVjP3pTyOHfVhdo4MVExRf PinHa2JNB5LMpgHL66saoJJJ+T8mGpdL2BSFT3URra9FUP5SFVSxC269MYwutCX39pZoWemUPgnQC qaDvaxY4a/+iYyLGC81J3JzipnyqE0EI/UrEohzXmO5HZkT4kCGgLUSgWWYJrv0LgVymR8gf8BCcE +fOunw9Q==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qPOxY-008ar2-Pr; Fri, 28 Jul 2023 15:00:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 60DAE308CCC; Fri, 28 Jul 2023 17:00:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 2788E2C8FCA98; Fri, 28 Jul 2023 17:00:51 +0200 (CEST) Message-ID: <20230728145808.970594909@infradead.org> User-Agent: quilt/0.66 Date: Fri, 28 Jul 2023 16:55:18 +0200 From: Peter Zijlstra <peterz@infradead.org> To: anna-maria@linutronix.de, rafael@kernel.org, tglx@linutronix.de, frederic@kernel.org, gautham.shenoy@amd.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Subject: [RFC][PATCH 3/3] cpuidle,teo: Improve state selection References: <20230728145515.990749537@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772679074244040118 X-GMAIL-MSGID: 1772679074244040118 |
Series |
cpuidle,teo: Improve TEO tick decisions
|
|
Commit Message
Peter Zijlstra
July 28, 2023, 2:55 p.m. UTC
When selecting a state, stop when history tells us 66% of recent idles
were at or below our current state.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
drivers/cpuidle/governors/teo.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Fri, Jul 28, 2023 at 5:01 PM Peter Zijlstra <peterz@infradead.org> wrote: > > When selecting a state, stop when history tells us 66% of recent idles > were at or below our current state. This is not really about "recent idles" AFAICS. It stops the selection when 66% of the total sum of the "hits" and "intercepts" signals comes from the current state and the states below it. This covers the entire history, while the "recent" ones are counted separately. > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > drivers/cpuidle/governors/teo.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > --- a/drivers/cpuidle/governors/teo.c > +++ b/drivers/cpuidle/governors/teo.c > @@ -363,6 +363,7 @@ static int teo_select(struct cpuidle_dri > unsigned int idx_hit_sum = 0; > unsigned int hit_sum = 0; > unsigned int tick_sum = 0; > + unsigned int thresh_sum = 0; > int constraint_idx = 0; > int idx0 = 0, idx = -1; > bool alt_intercepts, alt_recent; > @@ -397,6 +398,8 @@ static int teo_select(struct cpuidle_dri > duration_ns = tick_nohz_get_sleep_length(&delta_tick); > cpu_data->sleep_length_ns = duration_ns; > > + thresh_sum = 2 * cpu_data->total / 3; /* 66% */ > + > /* > * Find the deepest idle state whose target residency does not exceed > * the current sleep length and the deepest idle state not deeper than > @@ -427,6 +430,9 @@ static int teo_select(struct cpuidle_dri > if (s->target_residency_ns > duration_ns) > break; > > + if (intercept_sum + hit_sum > thresh_sum) > + break; > + > idx = i; > > if (s->exit_latency_ns <= latency_req) > >
On Fri, Jul 28, 2023 at 07:07:02PM +0200, Rafael J. Wysocki wrote: > On Fri, Jul 28, 2023 at 5:01 PM Peter Zijlstra <peterz@infradead.org> wrote: > > > > When selecting a state, stop when history tells us 66% of recent idles > > were at or below our current state. > > This is not really about "recent idles" AFAICS. It stops the > selection when 66% of the total sum of the "hits" and "intercepts" > signals comes from the current state and the states below it. This > covers the entire history, while the "recent" ones are counted > separately. Ah, bad wording perhaps. I found that 'recent' list teo has very hard to use, also the regular state isn't that long lived as per the reply on the previous patch.
--- a/drivers/cpuidle/governors/teo.c +++ b/drivers/cpuidle/governors/teo.c @@ -363,6 +363,7 @@ static int teo_select(struct cpuidle_dri unsigned int idx_hit_sum = 0; unsigned int hit_sum = 0; unsigned int tick_sum = 0; + unsigned int thresh_sum = 0; int constraint_idx = 0; int idx0 = 0, idx = -1; bool alt_intercepts, alt_recent; @@ -397,6 +398,8 @@ static int teo_select(struct cpuidle_dri duration_ns = tick_nohz_get_sleep_length(&delta_tick); cpu_data->sleep_length_ns = duration_ns; + thresh_sum = 2 * cpu_data->total / 3; /* 66% */ + /* * Find the deepest idle state whose target residency does not exceed * the current sleep length and the deepest idle state not deeper than @@ -427,6 +430,9 @@ static int teo_select(struct cpuidle_dri if (s->target_residency_ns > duration_ns) break; + if (intercept_sum + hit_sum > thresh_sum) + break; + idx = i; if (s->exit_latency_ns <= latency_req)