Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp494907rwd; Wed, 7 Jun 2023 02:59:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49l3iCmRR1N8z31HcVN11cOyfYEJ25BzFRV+wzaMDInIT7mD3oVFHafn/rE+WxMCqg345O X-Received: by 2002:a05:6a00:1a0e:b0:651:cd9d:7dd7 with SMTP id g14-20020a056a001a0e00b00651cd9d7dd7mr5611423pfv.15.1686131997541; Wed, 07 Jun 2023 02:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686131997; cv=none; d=google.com; s=arc-20160816; b=pMbt6PZ0FepawEvYBtYXd/jfD7R4HnaONhvxmJq/D3d5bHMTbUPqbOOj0nnyZKOoLA m3Wz/X5x7w6NlVfF0MhRBq7V/wKF9IzbC5dD6ANKrjdi9Z9IehXqPysSoS0CKPWOF5gG MrRDc9dw9HKXLVlhRQHig81EIEXRhwhwTsUsHZdRBVabDqha5ZpGVZvn0prtyTNNBiyH 3zN7KwhB0XECgchzAD9h/DqX1NsZng3MjLhGs3iZ+DVE2USo6gz6GraCGU21X2MRH2+v 4lEOxpD/FvKrlSQYEjT3JmfZGSm1Tb81Rxa76dXVJLdMKsC4J/BBeyeCnGGhAgfItQDY jg/Q== 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=MHiJavEgLpvPSoAWMa5+afasJi2XtguSQGZabSBoZy4=; b=0YIsAnKbf/Ok1axCfliEDqrx19lk4pu4eMUxmanDfIe6UoH+peFXY8c4aDQVG+Y1HV CqGMjrL37QqGVR0noPCD9R4RTyaAl3gkEIXuWpex/GlTGvu3GgcWVeHVL2deHeQKoRR1 JiItH5TAqGfGU0xngJJHo9XGfVy7RAzIw9q1g7FCQ7HTRnPgP3HQGg9Nfsb0K3/tkqLp DlbvHksT0Bb/tJsKiBUvCgqsBPLMy9dvkrxhPhoydVGfhwUDrVt2G9eqBOm7r2enOuuT /K4lBeKBZC0dskBT3RkpwnBb8sUODxH0va8KEkU0/wSC65TGJ51nCELydGuqcNlTPWNu A5Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yIDOuj7q; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h189-20020a6253c6000000b0063c56e46f9esi8620138pfb.294.2023.06.07.02.59.42; Wed, 07 Jun 2023 02:59:57 -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=@linaro.org header.s=google header.b=yIDOuj7q; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239472AbjFGJYe (ORCPT + 99 others); Wed, 7 Jun 2023 05:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238431AbjFGJY0 (ORCPT ); Wed, 7 Jun 2023 05:24:26 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9A458E for ; Wed, 7 Jun 2023 02:24:24 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3094910b150so7182456f8f.0 for ; Wed, 07 Jun 2023 02:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686129863; x=1688721863; 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=MHiJavEgLpvPSoAWMa5+afasJi2XtguSQGZabSBoZy4=; b=yIDOuj7qUNG9ylsspk2Kypvp30Q/UrBU5ozHjp0V0cIlT1FfoESemKGtuMJFsMI9gP ZQH9lGtuSodflpCW7WqFbNbVI8xj9beDwYYM/mYHXesZ3W4IX8jzUj501t6Lem3XoiTt OgDSDveDLa7WsJZvb8EQFPZG7t2JS/eeHNITmntY896PbJS+2C9DBWcJ9C5SlXfK9RGY r9IknGQtYpn0TzDrNvRh9mUtZEFum8gPhlu4ltQhZ9lfW/634lyTYG290DNvK7bJKptE E+ZrSaUOmQZnfm0Vplh1OWz/0l4hmAy5AV12s8VOj25xqISkAy3uJ0NnWIe7Lk2HYdTK Fi9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686129863; x=1688721863; 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=MHiJavEgLpvPSoAWMa5+afasJi2XtguSQGZabSBoZy4=; b=IYl3+nd7sORihBx6HD43craLilb08hBFnRmwwxyyTeC2C981yuMFLbMfKzSM2LduWP v9/bNp1SeuqHYTXTpM0lyCJ2Mr+qzBXYDYcD3p0+y9a2I2bTb8Qb8edzMHMf9ONbKcBQ n/K8R05RPsKVAsMMEgS8KX85VStQ7Z7vTZ6+AjXcOiNwYwAjhOLblbtMqP0qu+sRxT51 ISuPUebk7k7JA+wxLBwXf5CiY68CJSbQuRw7Oy07AEsq3E2PPiipQVqb2I3erla8Xaw0 jbwuUJWlLP0UOZbDmuFAcIEGg+TCE78O36rore0FR1EV3rs1X7HiyyrQ0YKx/CoStohe PKww== X-Gm-Message-State: AC+VfDzg6Xxk5hnUmSTZ5QTP4Gf6a1g5zZqRQyJra2GapytY3itXTQ0Z D2LIazY+RVl+luxTpkNoSR6eQA== X-Received: by 2002:a5d:5341:0:b0:30e:1fc4:d0c9 with SMTP id t1-20020a5d5341000000b0030e1fc4d0c9mr3726783wrv.9.1686129863290; Wed, 07 Jun 2023 02:24:23 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:d8fb:84d9:d402:6b22? ([2a05:6e02:1041:c10:d8fb:84d9:d402:6b22]) by smtp.googlemail.com with ESMTPSA id y13-20020adfd08d000000b003063db8f45bsm14852094wrh.23.2023.06.07.02.24.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jun 2023 02:24:22 -0700 (PDT) Message-ID: Date: Wed, 7 Jun 2023 11:24:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 1/1] thermal: sysfs: avoid actual readings from sysfs Content-Language: en-US To: Eduardo Valentin , eduval@amazon.com, rafael@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Amit Kucheria , Zhang Rui References: <20230607003721.834038-1-evalenti@kernel.org> From: Daniel Lezcano In-Reply-To: <20230607003721.834038-1-evalenti@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eduardo, On 07/06/2023 02:37, Eduardo Valentin wrote: > From: Eduardo Valentin > > As the thermal zone caches the current and last temperature > value, the sysfs interface can use that instead of > forcing an actual update or read from the device. If the read fails, userspace can handle that by using the previous value. Do we really want to hide driver dysfunctions? > This way, if multiple userspace requests are coming > in, we avoid storming the device with multiple reads > and potentially clogging the timing requirement > for the governors. Can you elaborate 'the timing requirement for the governors' ? I'm missing the point > Cc: "Rafael J. Wysocki" (supporter:THERMAL) > Cc: Daniel Lezcano (supporter:THERMAL) > Cc: Amit Kucheria (reviewer:THERMAL) > Cc: Zhang Rui (reviewer:THERMAL) > Cc: linux-pm@vger.kernel.org (open list:THERMAL) > Cc: linux-kernel@vger.kernel.org (open list) > > Signed-off-by: Eduardo Valentin > --- > drivers/thermal/thermal_sysfs.c | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) > > diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c > index b6daea2398da..a240c58d9e08 100644 > --- a/drivers/thermal/thermal_sysfs.c > +++ b/drivers/thermal/thermal_sysfs.c > @@ -35,12 +35,23 @@ static ssize_t > temp_show(struct device *dev, struct device_attribute *attr, char *buf) > { > struct thermal_zone_device *tz = to_thermal_zone(dev); > - int temperature, ret; > - > - ret = thermal_zone_get_temp(tz, &temperature); > + int temperature; > > - if (ret) > - return ret; > + /* > + * don't force new update from external reads > + * This way we avoid messing up with time constraints. > + */ > + if (tz->mode == THERMAL_DEVICE_DISABLED) { > + int r; > + > + r = thermal_zone_get_temp(tz, &temperature); /* holds tz->lock*/ > + if (r) > + return r; > + } else { > + mutex_lock(&tz->lock); > + temperature = tz->temperature; > + mutex_unlock(&tz->lock); > + } No please, we are pushing since several weeks a lot of changes to encapsulate the thermal zone device structure and prevent external core components to use the internals directly. Even if we can consider the thermal_sysfs as part of the core code, that changes is not sysfs related. > return sprintf(buf, "%d\n", temperature); > } -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog