Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1150357rdb; Fri, 20 Oct 2023 09:42:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+blCQhP/lInwiAZhZmIJRwzaoRSsrXxhqruR0xpX7W7sakOMhPjI/no/e46niFEM7u0IO X-Received: by 2002:a17:90a:f312:b0:27d:2cc3:c805 with SMTP id ca18-20020a17090af31200b0027d2cc3c805mr2486827pjb.46.1697820126440; Fri, 20 Oct 2023 09:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697820126; cv=none; d=google.com; s=arc-20160816; b=djcJa1BrYAvQdd/7WNEkzQgglecIQc6fyR4wF++q8scwxqDUGqTPK3WDChWEGtAsn0 tFjIf6JsMAhqC733J7h2mCSRUgOgnEsN2yhK1nzPqbLEC6J3V7qq4TiNsASdQpTKTRGb rDelD47x2BQyvv8sIZBa2ZjPs9N/5kcxZkc6IspjfuNGjaVmjH9CDH9bU4GoxZMgX+Hi A2rJiw/JAB9HYefq3cW3qtqCkhXIIyR1IxRw4zUPUYkzX77TohVNp7Q1Zeh+vwurx4VG I1xxubhpAPy+2nOPHD7Ifu8CoKNMlN99iWBiPQd+rLKpZg9wMHkAtSs6nDKOXtkYWnh+ H6/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=v8afk9lxEulzYD9hJejzv2lMhpACGwWydxjWpKU2jME=; fh=20fA3cEuDBxbslv14gWipyG5F83lFaDkqoaQ/ENXW7U=; b=0WSHT55CCTimm9HfE3QGcX1rE2Bsr2/1Kj/r/nuJT1WRvqPM9M4E0eqrz6tZJHcGZI mRTgnlR67q8AgX8U7QgIR89MNouRWIz63g4ZE9it7v/n1Tr7j55Q3pmaR58wnUH19R8P BSIREDtbYdmr+YFSTpqTMenWg6RXipL0OBHfSFrjSWK5eH63uyA2H823HkXCWnEjJtlE c8keA+kBUMvIYLF6ls3pPoUT0ohIhUU9F9ESNuWYLF+GVaQnXBK8vVPP8Qzpd+92mJqp TTgj3B1n78b+dcExpLkOWnaA2BQk2zRqnI1iEo92ndlH8vELLgdU2J6kpealipctltc6 Robg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b1-20020a17090a9bc100b0027491203b43si4509911pjw.189.2023.10.20.09.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:42:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1B93583D51CD; Fri, 20 Oct 2023 09:42:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377862AbjJTQlv convert rfc822-to-8bit (ORCPT + 99 others); Fri, 20 Oct 2023 12:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjJTQlu (ORCPT ); Fri, 20 Oct 2023 12:41:50 -0400 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FFF1CA; Fri, 20 Oct 2023 09:41:47 -0700 (PDT) Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-582a82e6d10so178616eaf.0; Fri, 20 Oct 2023 09:41:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697820107; x=1698424907; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oi9p6sdu5fjBTtQ1cm+vKJjuXhBdwf6LqIRrwx97EmQ=; b=bd8vakvO70wuzD0R41RDf6oN+l+rpP9PVMUe7zX3GCPu8OIja9iroldcXDMOLLlYi/ XtBs0ybC0YKnBFQ0CdXknEJr5EmxtpOkyHV6l+2hH79yBlC3H0T8k9jTpTQ63o17SU4q 9bAWfglmrsytW4fMOgFxOVYSlLzvuSC0S+8rFbriB7xyLHEPyKsjDT/d9szY6kYDBkhf 7EKn+sk8oNZtkZB0INRjqMyRyhL7T6fMgKXmfS/Tc0BoClza3jTfJb9YpBK1WxqsSrj2 uH329tvp/qER+6TWSeVFxu0jQMU0zcLXtpSc2wT66iO/kgEfcCaAk40+SXlqnPLrVxQm 1Fsw== X-Gm-Message-State: AOJu0YwbECknA1lJToD7LHxQKmmPW/2niocgKLJOFRLPVCaEwqR1UICl pXol33jsuXpGnOhAkv7eh2jkYCcvo7mZkskiVdI= X-Received: by 2002:a4a:bb0f:0:b0:583:fc94:c3fd with SMTP id f15-20020a4abb0f000000b00583fc94c3fdmr2818335oop.0.1697820106891; Fri, 20 Oct 2023 09:41:46 -0700 (PDT) MIME-Version: 1.0 References: <13365827.uLZWGnKmhe@kreacher> <3768557.kQq0lBPeGt@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 20 Oct 2023 18:41:35 +0200 Message-ID: Subject: Re: [PATCH v1 4/6] thermal: gov_power_allocator: Use trip pointers instead of trip indices To: Lukasz Luba Cc: "Rafael J. Wysocki" , LKML , Daniel Lezcano , Linux PM , Srinivas Pandruvada , Zhang Rui Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, 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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 20 Oct 2023 09:42:03 -0700 (PDT) On Fri, Oct 20, 2023 at 6:36 PM Lukasz Luba wrote: > > > > On 10/6/23 18:47, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Modify the power allocator thermal governor to use trip pointers instead > > of trip indices everywhere except for the power_allocator_throttle() > > second argument that will be changed subsequently along with the > > definition of the .throttle() governor callback. > > > > The general functionality is not expected to be changed. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > drivers/thermal/gov_power_allocator.c | 123 +++++++++++++--------------------- > > 1 file changed, 49 insertions(+), 74 deletions(-) > > > > [snip] > > > @@ -636,7 +619,6 @@ static int power_allocator_bind(struct t > > { > > int ret; > > struct power_allocator_params *params; > > - struct thermal_trip trip; > > > > ret = check_power_actors(tz); > > if (ret) > > @@ -662,12 +644,13 @@ static int power_allocator_bind(struct t > > get_governor_trips(tz, params); > > > > if (tz->num_trips > 0) { > > - ret = __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, > > - &trip); > > - if (!ret) > > + const struct thermal_trip *trip; > > + > > + trip = params->trip_max_desired_temperature; > > + if (trip) > > estimate_pid_constants(tz, tz->tzp->sustainable_power, > > params->trip_switch_on, > > - trip.temperature); > > + trip->temperature); > > } > > The code check for the populated pointer (by earlier new > get_governor_trips(tz, params)) : > > if (params->trip_max_desired_temperature) { > int temp = params->trip_max_desired_temperature->temperature; > > estimate_pid_constants(...) > } > > looks better (what you have figured out already). > > Other than that the patch LGTM: > > Reviewed-by: Lukasz Luba > Tested-by: Lukasz Luba Thanks! > I have also tested this is a few ways and it still works as expected: > 1. Power allocation in different conditions > 2. Trip points properly recognized with this nice get_governor_trips(), > here is the test output, with many tricky trip point setups: Much appreciated! > use case A: > 5 trip points: > - 2 passive for 50, 60 degC > - 1 active 70degC > - 2 passive 70, 85 degC > - 1 critical 120 degC > > expected IPA trip points: 50, 85 deg => 35 degC IPA operating range > > [ 24.578806] Power allocator: IPA: trip->temperature=50000 > [ 24.578824] Power allocator: IPA: passive trip->temperature=50000 > [ 24.578838] Power allocator: IPA: fist passive trip->temperature=50000 > [ 24.578851] Power allocator: IPA: trip->temperature=60000 > [ 24.578863] Power allocator: IPA: passive trip->temperature=60000 > [ 24.578875] Power allocator: IPA: trip->temperature=70000 > [ 24.578888] Power allocator: IPA: active trip->temperature=70000 > [ 24.578900] Power allocator: IPA: trip->temperature=120000 > [ 24.578912] Power allocator: IPA: trip->temperature=70000 > [ 24.578925] Power allocator: IPA: passive trip->temperature=70000 > [ 24.578937] Power allocator: IPA: trip->temperature=85000 > [ 24.578950] Power allocator: IPA: passive trip->temperature=85000 > [ 24.578964] Power allocator: IPA: trip_switch_on->temperature=50000 > control_temp=85000 > [ 24.578978] Power allocator: IPA: temperature_threshold=35000 > > ------------------------------------------------------------- > use case B: > 5 trip points: > - 2 active for 50, 60 degC > - 1 active 70degC > - 2 passive 70, 85 degC > - 1 critical 120 degC > > expected IPA trip points: 70, 85 deg => 15 degC IPA operating range > > [ 27.402474] Power allocator: IPA: trip->temperature=50000 > [ 27.402492] Power allocator: IPA: active trip->temperature=50000 > [ 27.402505] Power allocator: IPA: trip->temperature=60000 > [ 27.402518] Power allocator: IPA: active trip->temperature=60000 > [ 27.402531] Power allocator: IPA: trip->temperature=70000 > [ 27.402544] Power allocator: IPA: active trip->temperature=70000 > [ 27.402557] Power allocator: IPA: trip->temperature=120000 > [ 27.402570] Power allocator: IPA: trip->temperature=70000 > [ 27.402582] Power allocator: IPA: passive trip->temperature=70000 > [ 27.402596] Power allocator: IPA: fist passive trip->temperature=70000 > [ 27.402608] Power allocator: IPA: trip->temperature=85000 > [ 27.402622] Power allocator: IPA: passive trip->temperature=85000 > [ 27.402635] Power allocator: IPA: trip_switch_on->temperature=70000 > control_temp=85000 > [ 27.402649] Power allocator: IPA: temperature_threshold=15000 > > -------------------------------------------------------- > use case C: > 6 trip points: > - 2 active for 50, 60 degC > - 1 active 70degC > - 3 passive 70, 85, 90 degC > - 1 critical 120 degC > > expected IPA trip points: 50, 85 deg => 20 degC IPA operating range > > [ 36.998907] Power allocator: IPA: trip->temperature=50000 > [ 36.998921] Power allocator: IPA: active trip->temperature=50000 > [ 36.998935] Power allocator: IPA: trip->temperature=60000 > [ 36.998948] Power allocator: IPA: active trip->temperature=60000 > [ 36.998960] Power allocator: IPA: trip->temperature=70000 > [ 36.998973] Power allocator: IPA: active trip->temperature=70000 > [ 36.998985] Power allocator: IPA: trip->temperature=120000 > [ 36.998999] Power allocator: IPA: trip->temperature=70000 > [ 36.999011] Power allocator: IPA: passive trip->temperature=70000 > [ 36.999024] Power allocator: IPA: fist passive trip->temperature=70000 > [ 36.999037] Power allocator: IPA: trip->temperature=85000 > [ 36.999049] Power allocator: IPA: passive trip->temperature=85000 > [ 36.999062] Power allocator: IPA: trip->temperature=90000 > [ 36.999074] Power allocator: IPA: passive trip->temperature=90000 > [ 36.999087] Power allocator: IPA: trip_switch_on->temperature=70000 > control_temp=90000 > [ 36.999101] Power allocator: IPA: temperature_threshold=20000 >