From patchwork Tue Aug 22 11:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 136522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3562591vqi; Tue, 22 Aug 2023 04:39:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXQGgR0XUSX0XPaXUSXh6HtUluvyoH74qV75jBbrU5XDxl6uPbSp2bPPmLtapxgp0QV4Aa X-Received: by 2002:a17:906:31c1:b0:99e:6cc:79b with SMTP id f1-20020a17090631c100b0099e06cc079bmr7484828ejf.47.1692704389616; Tue, 22 Aug 2023 04:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692704389; cv=none; d=google.com; s=arc-20160816; b=ApTFjjUjhkUuiBX+bcEwFbLQmHjBBk8TpVhR0GflK6g5nakBoeTVlvr1Vi7YVzdmM9 jx+47MqgPsM2cuICTDSRGorT89UkMnK0YTCAmeKWZxj/Ow7zVwKeXsIkOTBq+GqcE9FV HdFit2drQhEjmSr57W+5GREuvnAJ71VnjguCwTlQfn2/fkKb/HhyBzU2TstolrJiKF2r ZxqiWwtf/lUab8wwx3/iWQtheqyAWy5vzmJ1kAd/y8YR4ByfWvIxll1FVzMCLcqm8AzG ChWB8ZYvUyuMfPvXyKD7Of8Bs3RQTbCxcWk1TTdPspokIlqBROR2HI4TUMXOaX3LY0OG MkIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ZzDfmpIA6AfA+NCv+cg8OGsulAj+Hs8RD9oYOqY/s7Y=; fh=PxKDACKVZ5lOAwVgficzs1YBPSNkt4iHX3BI7H9gPng=; b=HDH8uJIm2I+yP+nP3t/E3LlN85WneGLGquWekULG2B0CNsNWRlA5ZMaLD6vpqMgMjZ /7PHGoPrbB3X7kKSvJFNFkqoQ0OF05/iS4J+A7SCxcaj2AruBIjlNpEDqyVxoP+OPnZ5 ilv0u98aTEiIZoOwxL3XkaADAHKKFClcdihm+YPmk0DREaEMMLJiD/g7zD2Eyh7b70xi C+KXftKlq3tCFPhvrAV7H/2W+WbpZgWvoFCFAgMoZy5zhfuNBdbfmlr3vf6g9fU8M7rA NL7N/Tk50Rcu4yz2Ti+/qkT2oH8nR0ffHPYX+ua/vqBdBhvtlyGFSsRBbu9x6gpFcfsL 3d4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 me17-20020a170906aed100b0099327749bddsi6656049ejb.125.2023.08.22.04.39.25; Tue, 22 Aug 2023 04:39:49 -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; 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 S234049AbjHVL2L (ORCPT + 99 others); Tue, 22 Aug 2023 07:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbjHVL2L (ORCPT ); Tue, 22 Aug 2023 07:28:11 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15778CCA; Tue, 22 Aug 2023 04:28:08 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 297a6333ba3eafe4; Tue, 22 Aug 2023 13:28:06 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 63DE9662D1E; Tue, 22 Aug 2023 13:28:06 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Anna-Maria Behnsen , Doug Smythies , Kajetan Puchalski , Peter Zijlstra Subject: [PATCH v1] cpuidle: teo: Avoid unnecessary variable assignments Date: Tue, 22 Aug 2023 13:28:02 +0200 Message-ID: <12275754.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedruddvuddggedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepffffffekgfehheffleetieevfeefvefhleetjedvvdeijeejledvieehueevueffnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhhnrgdqmhgrrhhirgeslhhinhhuthhrohhnihigrdguvgdprhgtphhtthhopegushhmhihthhhivghssehtvghluhhsrdhnvghtpdhrtghpthhtohepkhgrjhgvthgr nhdrphhutghhrghlshhkihesrghrmhdrtghomhdprhgtphhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774929197600096497 X-GMAIL-MSGID: 1774929197600096497 From: Rafael J. Wysocki Notice that it is not necessary to assign tick_intercept_sum in every iteration of the first loop over idle states in teo_select(), because the intercept_sum value does not change after the assignment in a given iteration of the loop, so its value after the last iteration of the loop can be used for computing the tick_intercept_sum value directly. Modify the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- This is based on the pm-cpuidle-gov branch in linux-pm.git (which is included into linux-next too). --- drivers/cpuidle/governors/teo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) Index: linux-pm/drivers/cpuidle/governors/teo.c =================================================================== --- linux-pm.orig/drivers/cpuidle/governors/teo.c +++ linux-pm/drivers/cpuidle/governors/teo.c @@ -450,8 +450,6 @@ static int teo_select(struct cpuidle_dri hit_sum += prev_bin->hits; recent_sum += prev_bin->recent; - tick_intercept_sum = intercept_sum; - if (dev->states_usage[i].disable) continue; @@ -484,7 +482,8 @@ static int teo_select(struct cpuidle_dri goto end; } - tick_intercept_sum += cpu_data->state_bins[drv->state_count-1].intercepts; + tick_intercept_sum = intercept_sum + + cpu_data->state_bins[drv->state_count-1].intercepts; /* * If the sum of the intercepts metric for all of the idle states