Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2835004rdh; Wed, 27 Sep 2023 14:24:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtJaud3kc6cui/qMX/ChT4gXGCnL8hX0AkwQIAYDUv05jY86OMRQhNCVoNjJ6izbq/6EsV X-Received: by 2002:a05:6a21:a5aa:b0:14b:7d8b:cbaf with SMTP id gd42-20020a056a21a5aa00b0014b7d8bcbafmr3805348pzc.57.1695849867654; Wed, 27 Sep 2023 14:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695849867; cv=none; d=google.com; s=arc-20160816; b=MKT2XsVY0uBB4MQynIPYwdCFW8PBraR80Y7KkLJDUWXlztUzzwfGTUpUDEH0fdF7DB 7y61RhV0Geduopq1VwJOvSW+vs0N0Y6MGM+K7qSQzb5QxRe5i+XBbzvnXyztomyZYmPL NbIQp+s1U2jyT8nXR6c3CUmzqxyE51t45U8u5liXe8pvQWBtOzAoJomlHoPH/Yf+CAAm UOdQ/1aUsiCIbUsirYvZFk/BTUx2ev4BGmz6tE57Q1GpQc9RDenVQy4QevrBg7V68SbN tutpxHWS8mpBJiXRkySq749n8xOktL8uxWSRdKPOVAb8SP0pmaiaAgbbNnDZrwPW+ftn YzKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=NewR8mz3IDKSzbhyhEdNVdjJ713zwUsUtm4gHKiLJro=; fh=m0X/oytArEKD7xVRclrxSIpAMz4vi1vBL7kL27q+HkI=; b=LjTvUfkMB1YgYpXaXl/KGSV9VmKqEqTZydCvXruua6hbM1vy+M/5XUZKDJrPadFgMh itimf7mRzQ6wr05FUapEgRAMsMkvuhpzzsKQnCKe56bIAYfQvRLTRy1Rvetz9iF0fQuF FYiY8xDDWiqQhyBtfvrL3FsJ10OwHjOD4PmNO2Se+qIlTwx9T81iKa8IAo0z1MDtgJnx nGAcLEk973RM5/GnQM14jUQwDzX5c4GR8/rwugVnouH/3D56CWPUOsm2zk+pw8ocltLp scv0ydcJy2Y/mob+/1EVm87obbPJ2+R2qhfMiTiL8dlnLKewmhdX5mjjg38fL6UlZ8cH xHng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oimuB8Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d11-20020a170903230b00b001c1f373ea07si18023564plh.351.2023.09.27.14.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oimuB8Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 900A8805000F; Wed, 27 Sep 2023 08:00:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbjI0PA2 (ORCPT + 99 others); Wed, 27 Sep 2023 11:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjI0PAZ (ORCPT ); Wed, 27 Sep 2023 11:00:25 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F92D180 for ; Wed, 27 Sep 2023 08:00:24 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4064876e8b8so9390755e9.0 for ; Wed, 27 Sep 2023 08:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695826823; x=1696431623; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=NewR8mz3IDKSzbhyhEdNVdjJ713zwUsUtm4gHKiLJro=; b=oimuB8CgT98N8oKbqJao/E4cuj5pR1VCQXqSdVjbugHUbApUvSCJFbR2BKOOW5jR1v uNOfLNIfxx/t9gLU3u6WrctHo9/KxbJ2+sCMWLYgoyG9cFkeHkhFDvarbOHDkddokYBi q7rCfdg5G34/NDlJ8IZyy1mx3bxQv+0HQzbXatQS5hcPku8S+6jGWFR+iny/ZxfjCwD5 tt99vIspuB2/bWrjPwXtM7qP/tU5hrMibMf1YKtio7tN15kTxUVy8tuUzz9OlDM2w2iF zWm+NCeijAkl0mT2WJlnwSOx6XlRcQU4DLE+oo5oYHSMD/GynBQRteZ3dvpozBzCzDU7 t/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695826823; x=1696431623; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NewR8mz3IDKSzbhyhEdNVdjJ713zwUsUtm4gHKiLJro=; b=BN00mKOAVN2zzSIH1tnkEF6Yhv43NJDcXb6YPPYIHa88jBypEeERlMTzdDsfgOPyhJ JJBhkhW7w/SCQMCBLUIbDja84q09ML5HgJF2ddKtzaYsN1vuuuwgc8c+RZpzpMjo9WIm s0x5YYHTCmxVYdZ9VT6ZMjpyY5p6sFbHgmGdq1v+gYcNTqi7cWedUu2P1VkvzlKzk3t3 UN8poqkWLtt+bWnv82bHb38xYg8Qd9sIY3b5idC9Ts64+4y+yIwmKds9cDxMf7HDH2J7 n+oDFWUwr+eAGq4TjJCN8Rcj1OwpFmgb4xw9+wds+0NjhbxJGbuUuiphXSSe/rD2BYUs C2rg== X-Gm-Message-State: AOJu0Yyp78Jdw44cQmQHIdxHPbXdHH1JbCNEZayD1+4OzL9IHMehMbFR Fig2EfSHZqo3VCUUYHzMdlUStw== X-Received: by 2002:a7b:c409:0:b0:3ff:ca80:eda3 with SMTP id k9-20020a7bc409000000b003ffca80eda3mr2253169wmi.10.1695826822830; Wed, 27 Sep 2023 08:00:22 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:c49e:e1a5:3210:b8c0? ([2a05:6e02:1041:c10:c49e:e1a5:3210:b8c0]) by smtp.googlemail.com with ESMTPSA id j13-20020adfd20d000000b003232c2109cbsm7453676wrh.7.2023.09.27.08.00.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Sep 2023 08:00:20 -0700 (PDT) Message-ID: <3c9f7b7d-a9ca-79ae-4e64-367a82f953bc@linaro.org> Date: Wed, 27 Sep 2023 17:00:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v1 06/13] thermal: gov_fair_share: Rearrange get_trip_level() Content-Language: en-US To: "Rafael J. Wysocki" , Linux PM Cc: LKML , Linux ACPI , Srinivas Pandruvada , Zhang Rui , Lukasz Luba , "Rafael J. Wysocki" References: <1957441.PYKUYFuaPT@kreacher> <1882755.CQOukoFCf9@kreacher> From: Daniel Lezcano In-Reply-To: <1882755.CQOukoFCf9@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:00:43 -0700 (PDT) On 21/09/2023 19:54, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Make get_trip_level() access the thermal zone's trip table directly > instead of using __thermal_zone_get_trip() which adds overhead related > to the unnecessary bounds checking and copying the trip point data. > > Also rearrange the code in it to make it somewhat easier to follow. > > The general functionality is not expected to be changed. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/gov_fair_share.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > Index: linux-pm/drivers/thermal/gov_fair_share.c > =================================================================== > --- linux-pm.orig/drivers/thermal/gov_fair_share.c > +++ linux-pm/drivers/thermal/gov_fair_share.c > @@ -21,23 +21,21 @@ > */ > static int get_trip_level(struct thermal_zone_device *tz) > { > - struct thermal_trip trip; > - int count; > + const struct thermal_trip *trip = tz->trips; > + int i; > > - for (count = 0; count < tz->num_trips; count++) { > - __thermal_zone_get_trip(tz, count, &trip); > - if (tz->temperature < trip.temperature) > + if (tz->temperature < trip->temperature) > + return 0; > + > + for (i = 0; i < tz->num_trips - 1; i++) { > + trip++; > + if (tz->temperature < trip->temperature) > break; > } Is it possible to use for_each_thermal_trip() instead ? That would make the code more self-encapsulate > - /* > - * count > 0 only if temperature is greater than first trip > - * point, in which case, trip_point = count - 1 > - */ > - if (count > 0) > - trace_thermal_zone_trip(tz, count - 1, trip.type); > + trace_thermal_zone_trip(tz, i, tz->trips[i].type); > > - return count; > + return i; > } > > static long get_target_state(struct thermal_zone_device *tz, > > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog