Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5211540rwd; Mon, 12 Jun 2023 01:26:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xLEHnbcP7MIvPMTgJDDdM9BCuV5lZT5gxPB67+jjTlHc/dulVm/GF+svbTnzn3l/d/OwN X-Received: by 2002:a2e:9889:0:b0:2b1:e668:30c6 with SMTP id b9-20020a2e9889000000b002b1e66830c6mr2404049ljj.34.1686558404929; Mon, 12 Jun 2023 01:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686558404; cv=none; d=google.com; s=arc-20160816; b=ru50J+n1BYfYlhxM1uenHcodzYfLh9P6pPiduUBb3Bpx7I3p7R+TmlFQjTTH/hQZN9 UjjxrbW7pLgmHPnRNAQ7oC7iOkSbO7HCdoLgG6ocueL1EOy5KlIZUcDKZKywnmqSgCGr EmcXliE2+93sWab2a+RzmVQwgFvs5ytbkwWLa1yBDePmjKAAjm9ZDunIGpVVC9GU2goS r6uO4JdchNupr3cYYrICT8OiMk2gQpVZe1Y0dh0PARCUVAgVjfVJ/y1uP6JfTDUIgK/L fDWM25YZ4bhudz1kE2xr8qasa0o+lFEEKtOZ+ouHcaXSJi8quzG0wq/vXZFB3s8PXSMR unGA== 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=/BLdKV6ydqTF5FF9wuUDahLeHWRQMuZz0P9EBbaIRdk=; b=Fwaf6fxvWlFT6vEAWHHI8ACuu6aihNby5gn4tgzuMh4WrVEw3dhrx9RahyvEhDe6pG jF/3CH8emchzARHj/gMGx1ERlNIj+wPscO+1p3jIiHYAg611NDzQFb+fuxh3s8RcAB1K h8GcBUZHUWd4hEwPGScaMv8Zm8or6umSWgiiN18A/iQR9Lv0mkIZo+5rYuXkKB5MWTJe nrNeQto9VdVHPiBjofJau0clBeag+Cmj/KhkTOBK/ybN1rHQDiETtXfLhHcaB7bm6jPq BNKp8G5Zy3Hi42RJO3l68HZxGLxGVpiIZZvpLNZ7EIcbUVPxmEu5fqV3cbxijeqTDG9+ j4UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=twR2vTIn; 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 m15-20020aa7c2cf000000b0050bc4575219si1542677edp.607.2023.06.12.01.26.16; Mon, 12 Jun 2023 01:26: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=@linaro.org header.s=google header.b=twR2vTIn; 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 S230054AbjFLISa (ORCPT + 99 others); Mon, 12 Jun 2023 04:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbjFLISO (ORCPT ); Mon, 12 Jun 2023 04:18:14 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB8C51FDC for ; Mon, 12 Jun 2023 01:17:54 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-30fbac9639fso1156126f8f.1 for ; Mon, 12 Jun 2023 01:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686557873; x=1689149873; 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=/BLdKV6ydqTF5FF9wuUDahLeHWRQMuZz0P9EBbaIRdk=; b=twR2vTInGL8pHkStNJy5NRmM+Wca1Y/S3lt6RVZyWVxtSYFclxfkNUCZfK69Xg2Y1T YRM5Ap8g6gFmuyLVhj/YfTe/Wo5ArRei/EPJJsaF32bfcWKorSwGDsNIvM1h3YC+fv0r YlnIcEf3qC1jx7iCr+Jxweq9DU80U5CSwHoRCbGothCClZWUlc7HYVRqRfQopRPGVjD4 EP8aaxpcLigGPOnEXUjsw0ho1F1RQ5mH0zdKolCsoKfiPGsHeJZ6xn6oOTnlylsbWuXm JXdbinv7zF/7Eq3Y42sl56hQ0YwpAzFBAD1jh6oW6RKU2juC9LJMsAHuylEIwQefFePh wF3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686557873; x=1689149873; 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=/BLdKV6ydqTF5FF9wuUDahLeHWRQMuZz0P9EBbaIRdk=; b=FPsSgbUUdjwWU44c537zPz6mNiLhYt8WgZdCC/8P1jSC21rsCgWn0a8AlPlN8nIlaa x5TunlJYpwZS2mX0yBT2rb2H7PHa82XXEFjXIUit17oEuV6UtDwyVRSbiJK+Cp33wkPI FtcUD5FoAhnYJHr4DsK6UWliMnthYpSTHikngkqjCaNSCG1jgh/gPh3gCvi6q8uDnZcz L211hJycY7CMd27V54ipdol6ytDv78Y3rXTZ+UZg9fFnr9i52zMgwQ6+y5Ope186NVvy /OFe/zI0w43pKFbyL9MOE0bJLiinbZMyBDnq2OoZh5K9aSfsDM1Ki02xJaZNfd4Wx6J8 N66Q== X-Gm-Message-State: AC+VfDwrR62Vf2VKqJ8LyXn3GAFEpnBISYu4Cjp11XoB0Vz6tt/kdV5n Oo+E2CS8gmxfJYCb7+BqLz75bw== X-Received: by 2002:a5d:522b:0:b0:30f:c1f5:e91e with SMTP id i11-20020a5d522b000000b0030fc1f5e91emr1381133wra.27.1686557873141; Mon, 12 Jun 2023 01:17:53 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:bb02:9baa:82d1:2486? ([2a05:6e02:1041:c10:bb02:9baa:82d1:2486]) by smtp.googlemail.com with ESMTPSA id m11-20020a5d6a0b000000b0030b5d203e7esm11695296wru.97.2023.06.12.01.17.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 01:17:52 -0700 (PDT) Message-ID: <7616fd9d-aa0d-2ecd-8751-894b1c9073c0@linaro.org> Date: Mon, 12 Jun 2023 10:17:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 1/1] thermal: sysfs: avoid actual readings from sysfs Content-Language: en-US To: Eduardo Valentin Cc: eduval@amazon.com, rafael@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui References: <20230607003721.834038-1-evalenti@kernel.org> From: Daniel Lezcano In-Reply-To: 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 autolearn=unavailable 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 08/06/2023 19:44, Eduardo Valentin wrote: [ ... ] >> Do you have a use case with some measurements to spot an issue or is it >> a potential issue you identified ? > > > yes, a governor that is using I2C device as input, behind I2C fast mode (100KHz) > and needs to update the zone every 100ms. Each read in this bus, if done alone > would be around 500us, takes 10bytes to read the device, it is 10 clocks per byte, > well technically 9, but rounding for the sake of the example, which gets you > 50 / 100KHz = 500 us. That is for a single read. You add one single extra > userspace read triggering an unused device update, that is already a 1ms drift. > Basically you looking at 0.5% for each extra userspace read competing in this > sysfs node. You add extra devices in the same I2C bus, your governor is looking > at more than 1% overhead. And I am talking also about a main CPU of ~800MHz. > I did not even include the lock overhead considered for this CPU ;-) > > Again, this is not about controlling the DIE temperature of the CPU you > are running the thermal subsystem. This is about controlling > a target device. Ok. The target device is on a bus which is slow and prone to contention. This hardware is not designed to be monitored with a high precision, so reading the temperature at a high rate does not really make sense. Moreover (putting apart a potential contention), the delayed read does not change the time interval, which remains the same from the governor point of view. In addition, i2c sensors are usually handled in the hwmon subsystem which are registered in the thermal framework from there. Those have most of their 'read' callback with a cached value in a jiffies based way eg. [1]. So the feature already exists for slow devices and are handled in the drivers directly via the hwmon subsystem. From my POV, the feature is not needed in the thermal framework. [1] https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/tree/drivers/hwmon/lm95234.c#n163 -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog