Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14707603rwd; Sun, 25 Jun 2023 02:55:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PoVMtu5SDIJxsTqp/eBXPNq1z0iSX1kdQWedQcPC7LuL92L0UU5PKBRUs0waTipB4ced5 X-Received: by 2002:a05:6e02:149:b0:345:9269:3420 with SMTP id j9-20020a056e02014900b0034592693420mr2321483ilr.3.1687686944571; Sun, 25 Jun 2023 02:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687686944; cv=none; d=google.com; s=arc-20160816; b=FLEerLcOWexYKuEMssM4rNHKnGDQQZPGffU2Fj9KoVjkB52l0pEipqJ388KcU3/vJO sOETdD0d7aS5T9FGKb2jipszXyHZymX543cwBpdQbz8A1qqPfiwBEs/i3Q3C5PIREPVX HeMMiPzIJWiicPlSHPOAAjMLRogfll9L6I9NFkfH9ZK0VqHlohGaEWOOkmb4wyMjtZil zfLV+plb7h1qj2Sbn7GsOhqRpud9eFOiHAwyw9crqwLeb+jU3pPHT6p7QJmfsbE/DtMb H6Bjm+ge2I/SHuJngN6zVpj5efcwz0DhkhnUzD7Ou5xhZD+Jbrzn0qB2lDgcA+KtQAJ8 kxWA== 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 :dkim-signature; bh=BQinQxvp5MdiOhBT5QzM2xeQ6/LVgVdhwk/Y8pJ2LoI=; fh=ZXivUyao7Cem+Am28ek09xaU9qC2TiyImy3Z+LBaVjk=; b=Nnc8DrG5aCCsB8YCfPi+C4/Pr7Y9SM5ovWsQ+twDtpa9pTQHLpl2+QYDLBht1qj5LJ qqEASJGQgeOaoOjKYQw0AGXemzYX2m2JaZDSIxh4RyFK2XP2ibDzTTywxdZwBx+qpnbX PscAtgL0ClaEp5RA/sZwPjRyYNXd0Pg0iNOZEryIMFo+FwmKoE3YpqwsgSl+XShODtLa 1KvevyeduD04x7wfpcTYz0LtZJLe13Ld/C8Q2GX2//L0bS1W/Kdf88qVXPoF1r45B3u4 Y7FiZBZP+Ev+/fPv3dbtafbV9H7IEWpToSy5K5ySPRWxWiE5LIdzijPHOJOgIXwTBBD6 9SFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=n984TvmX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a630f4a000000b0054fa5f25cfasi3125452pgp.568.2023.06.25.02.55.32; Sun, 25 Jun 2023 02:55:44 -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=@gmail.com header.s=20221208 header.b=n984TvmX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231844AbjFYIkT (ORCPT + 99 others); Sun, 25 Jun 2023 04:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbjFYIkS (ORCPT ); Sun, 25 Jun 2023 04:40:18 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FC0610C0; Sun, 25 Jun 2023 01:40:15 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-7654e1d83e8so178712385a.1; Sun, 25 Jun 2023 01:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687682414; x=1690274414; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BQinQxvp5MdiOhBT5QzM2xeQ6/LVgVdhwk/Y8pJ2LoI=; b=n984TvmX6TnPC3y7cfLRidC4bWfLJl8+7Rh8EBWn3qdlg/nDb5bIGgrOL0sPlEd0kk f51NImUKcw4Jbg3xUvOXBU9z0ozvlWndSH2k9V/VVoockK3v139z3/DCAp9r2XgS3n0Q yuRlPBrZcvDDf/cjSoybKKSFvB8gQjJtU51RGrYpBcfjNYhNCIX2W3y3Y0HGkESFP++j GPp1jf7Iyx86Kf4ecWnBlHj+y0xw5T2XC0sZPcej3skrKSLd6BzwTQ6TGn8P84KUCApW 5DNBuiyrRaPjrfy+I7o5oRawvGlSHwlvfqwSv4MjObFgSJy+DceOBngx92YDQ3LbzBxi vuhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687682414; x=1690274414; 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=BQinQxvp5MdiOhBT5QzM2xeQ6/LVgVdhwk/Y8pJ2LoI=; b=HfMFzi5g//MLZO6FXHrXupRMLr8JEa21nuJR6WyPaEHlX+C35R/3RHgBZ0qirLM8Ug 9fhAFERnPlQf1kziOHLbMDmVaGBw0F9s/C4jKaDLeVP5FRT6mGSOSqRWi7Kl/yxySWT0 8EvqCjK2Wg6U0nUFpNMrlk3OJrif9W7rjJAz2RVIMv7rUxSG3LAFEuD6UtrS3Vy9o5O3 orL7JFxAzwjTQlZVAjxh/BZqkGOn4O0SLViBbz7+ZZSD8rervVdswapSh1G6dwZ7OvgX 3hVToKjnnHijFewadgcHFu2+HBA/1gJL9Kb/epUOWTT3FW1d7tcb0fZ9UHAJJh+P0Zrb vDSA== X-Gm-Message-State: AC+VfDxHoAM1HZyAzZWIXCsRVy4Z/VxXg/N9Md4KB487zB/LQZ/H5apz V2li9WIySZJFjYNWoEcFD+annNdrokM5wuXqobA= X-Received: by 2002:a05:620a:2493:b0:765:65bd:614e with SMTP id i19-20020a05620a249300b0076565bd614emr3730304qkn.51.1687682414147; Sun, 25 Jun 2023 01:40:14 -0700 (PDT) MIME-Version: 1.0 References: <6aad180f-410c-5b11-b30b-c7bc02cbe054@linaro.org> <20230619063534.12831-1-di.shen@unisoc.com> <62c35d1c-7dcd-7bf2-253e-65cdfd6e92cc@arm.com> <2884a54e-4db0-bf47-3b8a-0deb337208d8@arm.com> <86da9945-04d5-047a-cb2d-5fb63737839f@arm.com> In-Reply-To: <86da9945-04d5-047a-cb2d-5fb63737839f@arm.com> From: Di Shen Date: Sun, 25 Jun 2023 16:40:03 +0800 Message-ID: Subject: Re: [PATCH V4] thermal/core/power_allocator: reset thermal governor when trip point is changed To: Lukasz Luba Cc: "Rafael J. Wysocki" , Di Shen , daniel.lezcano@linaro.org, rui.zhang@intel.com, amitk@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, xuewen.yan@unisoc.com, jeson.gao@unisoc.com, zhanglyra@gmail.com, orsonzhai@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Sat, Jun 24, 2023 at 1:54=E2=80=AFAM Lukasz Luba w= rote: > > > > On 6/23/23 17:55, Rafael J. Wysocki wrote: > > On Fri, Jun 23, 2023 at 9:43=E2=80=AFAM Lukasz Luba wrote: > >> > >> > >> > > [snip] > > >> > >> I agree, the patch header doesn't explain that properly. Here is the > >> explanation for this Intelligent Power Allocator (IPA): > >> > >> The IPA controls temperature using PID mechanism. It's a closed > >> feedback loop. That algorithm can 'learn' from the 'observed' > >> in the past reaction for it's control decisions and accumulates that > >> information in the part called 'error integral'. Those accumulated > >> 'error' gaps are the differences between the set target value and the > >> actually achieved value. In our case the target value is the target > >> temperature which is coming from the trip point. That part is then use= d > >> with the 'I' (of PID) component, so we can compensate for those > >> 'learned' mistakes. > >> Now, when you change the target temperature value - all your previous > >> learned errors won't help you. That's why Intelligent Power Allocator > >> should reset previously accumulated history. > > > > Right. > > > > And every other governor using information from the past for control > > will have an analogous problem, won't it? > > Not necessarily, but to play safe I would go case-by-case and make > sure other governors are aligned to this new feature. > > E.g. the bang-bang governor operates only on current temperature and > current trip value + trip hysteresis. The flow graph describes it [1]. > The control (state of the fan: ON or OFF) of that governor could be > simply adjusted to the new reality -> new trip point temp. That would > just mean 'toggling' the fan if needed. There are only 2 'target' > states: 0 or 1 for the fan. You can images a situation when the > temperature doesn't change, but we manipulate the trip value for that > governor. The governor would react correctly always in such situation > w/o a need of a reset IMO. > > > > >>> > >>>>> > >>>>>> For the 2nd case IIUC the code, we pass the 'trip.temperature' > >>>>>> and should be ready for what you said (modification of that value)= . > >>>>> > >>>>> Generally speaking, it needs to be prepared for a simultaneous chan= ge > >>>>> of multiple trip points (including active), in which case it may no= t > >>>>> be useful to invoke the ->reset() callback for each of them > >>>>> individually. > >>>> > >>>> Although, that looks more cleaner IMO. Resetting one by one in > >>>> a temperature order would be easily maintainable, won't be? > >>> > >>> I wouldn't call it maintainable really. > >>> > >>> First of all, the trips may not be ordered. There are no guarantees > >>> whatsoever that they will be ordered, so the caller may have to > >>> determine the temperature order in the first place. This would be an > >>> extra requirement that currently is not there. > >>> > >>> Apart from this, I don't see any fundamental difference between the > >>> case when trip points are updated via sysfs and when they are updated > >>> by the driver. The governor should reset itself in any of those case= s > >>> and even if one trip point changes, the temperature order of all of > >>> them may change, so the governor reset mechanism should be able to > >>> handle the case when multiple trip points are updated at the same > >>> time. While you may argue that this is theoretical, the ACPI spec > >>> clearly states that this is allowed to happen, for example. > >>> > >>> If you want a generic reset callback for governors, that's fine, but > >>> make it generic and not specific to a particular use case. > >> > >> I think we agree here, but probably having slightly different > >> implementation in mind. Based on you explanation I think you > >> want simply this API: > >> void (*reset)(struct thermal_zone_device *tz); > >> > >> 1. no return value > >> 2. no specific trip ID as argument > >> > >> Do you agree? > > > > Yes, I do. > > OK, thanks. > > Di could you implement that 'reset()' API according to this description, > please? > Yes, happy to do that. > > > >> IMO such implementation and API would also work for this IPA > >> purpose. Would that work for the ACPI use case as well? > > > > It would AFAICS. > > Thanks Rafael for the comments and the progress that we made :) > > Regards, > Lukasz > > [1] > https://elixir.bootlin.com/linux/v6.3/source/drivers/thermal/gov_bang_ban= g.c#L80 Thanks Lukas and Rafeal for the comments. I will send the next version late= r. Best regards, Di