Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3388318ybk; Tue, 19 May 2020 03:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI0rGEEhO0vq7Dn/X2TtEIAVQd7X2Ao2SCYQcgAt5SUnA2TsN3le4Q6BmkcMpqpNV6mMpa X-Received: by 2002:a05:6402:2292:: with SMTP id cw18mr17834896edb.217.1589884141988; Tue, 19 May 2020 03:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589884141; cv=none; d=google.com; s=arc-20160816; b=LpXdEt//BKC5DMZFlADkXOeYaMFcZPs4jW2kQqt0e9cDGY3WDFdrvGP/4wVW6FYaw9 +D9gJa188icvo0Iuo5ogjGVXaUGaOpRyH0FCYCuEHYs03GAEhZvuG5CGOgUhbpe/J9lh YXP8jhSoHMW2zKD6sTMIksxN9Sqmua1rZJjM7XdMEj1J7ISyccNI8oZI/fc3PjiL1ZU2 M4iczwpvrEt6wGEzv7sEg6lQirN0ZNCXDexIAqYB0C1vEb6uTVbxs5fKScVla6qtNu6E 8INBfpP/vrPGOPdhy9su/hgGWL6tf94scc3pwdaTIPFWLpL0VXdRxuKIL0hzWwFwdk4m 06yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=awX2jX8LmUgDnV/EUVgSbcUlz7JrWITf9HWfSAf2CVQ=; b=eRThl0J79unXl9GN44iYMmlTpT3Aw5qnGAmPNAQS0sPpX5UM8KnEZvJFNPEjZIN8zc XR/O1Xos25YyUzWJ0ImOm9nDl9kuQh6hdVwG6ugalvjZiqtM4BlmBE/01nkJyH73rgyW Ss3MgrBlCLj1DvEBIWkBqnamyf6arL1n5KaERWlgEmu9mwcO4u0KVvUxJ0inUlaxqhVQ gxTOx04GdwtFP8W8mZ8KOWvD5GY6lUS+7nkktWtK+16CnmWVaMZxDj/wXOl63ecvia8Q dJQluzxxHsnX3f/0MPh/APy2XkrBsHXnxKPTa2iHX01NIYLx7KwM4PW/piVHun/fobUg H0Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMsQmaXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oa21si7912902ejb.375.2020.05.19.03.28.38; Tue, 19 May 2020 03:29:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMsQmaXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726508AbgESKZI (ORCPT + 99 others); Tue, 19 May 2020 06:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbgESKZE (ORCPT ); Tue, 19 May 2020 06:25:04 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE25C061A0C for ; Tue, 19 May 2020 03:25:03 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id n18so2861562wmj.5 for ; Tue, 19 May 2020 03:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=awX2jX8LmUgDnV/EUVgSbcUlz7JrWITf9HWfSAf2CVQ=; b=xMsQmaXiJ9VvVmdReYjodGgkm8EEhzCHVGSQFm47FrlYqPR/OHZqgTVBmJL5mEVBo3 gVBlJASFpfphtWqcb/NjT7kQtfXcs0L7ikF88YcheiyZGzWQCGSfbZQHAHr7agXMvKb1 5sk/8ElwA8L+SGCyI6TwiA/hhvI2VabhMbqmSZ0gPMt4Zj7NdYS6HHr2U7v29rKcCaFQ SP628cok5ydOh9OtbOmThuVPn5iHhcIk0fw/Rqx2+iUy1GXz5FL2jzZI9IlTCsOnZCZa ciiO+ssSR6klZ+hjEMzS9uaMIucaT1P0dt8CKbieKf/VUuUswBK4vmNa6Hvn8JLUI7Zc YaBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=awX2jX8LmUgDnV/EUVgSbcUlz7JrWITf9HWfSAf2CVQ=; b=L65by+uLxw5Hd5A5++5fQ3/Ju+wInjKqZ29oXTLoxyMdeKBmIb+kd17zn9OwUw7whU kIoJAL4jLTiK6u1Rl2yzZYZ1HdW0Z+ktoDC4Mg427Ru2wevt/oLtZ96tIyUuGRZ7pKfc oOoQQLer8XPQlepFzzQgJHnzT2B0tAchaZ1Vzk0E/ZoiJIRV+y2jq4BTeT1DNg0yCVo5 dfEyNf3w076FS7cPZh51bRd5LvneDhb+9jhpHXchpvwqykEt4jp0v04aDUZh/7Aeihtu lA+96bToRBu9yhQx0BQxUMLfcftMA3UZTljbgVjO/qMvynef8eM84Umnijh0zJ3l91dT Tc7A== X-Gm-Message-State: AOAM5327TSDJMyGzKotqtpYblEdxpclApF+m9yOcuzDZFAC6CgtPQsrP kQPHH0aKFdcQaFlMs7GwJqFAiQ== X-Received: by 2002:a1c:e903:: with SMTP id q3mr4499067wmc.76.1589883902079; Tue, 19 May 2020 03:25:02 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:e504:4297:986:ffb0? ([2a01:e34:ed2f:f020:e504:4297:986:ffb0]) by smtp.googlemail.com with ESMTPSA id 8sm3519290wmb.15.2020.05.19.03.25.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2020 03:25:01 -0700 (PDT) Subject: Re: [RFC][PATCH 4/5] thermal: Add support for setting polling interval To: Srinivas Pandruvada , rui.zhang@intel.com, amit.kucheria@verdurent.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org References: <20200504181616.175477-1-srinivas.pandruvada@linux.intel.com> <20200504181616.175477-5-srinivas.pandruvada@linux.intel.com> From: Daniel Lezcano Message-ID: <3898cf1a-8e4c-def4-73f7-9ef4954e88b8@linaro.org> Date: Tue, 19 May 2020 12:25:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/05/2020 01:46, Srinivas Pandruvada wrote: > On Mon, 2020-05-18 at 18:51 +0200, Daniel Lezcano wrote: >> On 04/05/2020 20:16, Srinivas Pandruvada wrote: >>> Add new attribute in the thermal syfs for setting temperature >>> sampling >>> interval when CONFIG_THERMAL_USER_EVENT_INTERFACE is defined. The >>> default >>> value is 0, which means no polling. >>> >>> At this interval user space will get an event THERMAL_TEMP_SAMPLE >>> with >>> temperature sample. This reuses existing polling mecahnism when >>> polling >>> or passive delay is specified during zone registry. To avoid >>> interference >>> with passive and polling delay, this new polling attribute can't be >>> used >>> for those zones. >> >> The userspace can get the temperature whenever it wants via the >> temperature file. The polling is designed for a specific hardware and >> the slope of the temperature graphic. >> >> The userspace has the alternative of reading the temperature based on >> its own timer or wait for (and stick to) the thermal framework >> sampling >> rate. Adding a notification in the update is enough IMO. >> > The problem with this approach is that the user can't change sampling > interval. Those polling intervals are fixed during thermal-zone > register. Is there any way to change those defaults from user space? No, we can't but the userspace can decide when to read the temperature (via sysfs or netlink) and thus decide its own sampling rate. Otherwise, we are talking about an userspace governor, so the platform is setup with the desired sampling rate + userspace governor. > Kernel can start with some long polling interval and user space can > change close to some trip. Ok, let me rephrase it. This (big) comment encompass also patch 3/5. I understood now the initial need of adding user trip points. There are platforms where the interrupt mode does not exist so setting an user trip point does not set the interrupt for the closer temperature, hence we end up with a kernel sampling rate and in this case adding a trip point + new user sampling rate is pointless as the userspace can poll the temperature at its convenient rate. If we summarize the different combinations we have: 1. monitoring : interrupt mode, mitigation : interrupt mode There are no thermal zone update until an interrupt fires. The mitigation is based on trip point crossed. 2. monitoring : interrupt mode, mitigation : polling There are no thermal zone update until an interrupt fires. The mitigation happens with a sampling rate specified with the polling rate. 3. monitoring : polling, mitigation : polling The thermal zone is updated at the polling rate, the mitigation occurs with an update at the second polling rate. IIUC, the RFC proposes to add a new type of temperature threshold, followed a new polling rate to update the userspace. IMHO, it is not a good thing to delegate to the kernel what the userspace can handle easily. I suggest: - Not add another polling rate. If the thermal zone has a polling rate or supports the interrupt mode, then the user trip point setup succeed otherwise it fails and up to the userspace to read the temperature at its convenient rate. (Note multiple process may want to get temperature, so one should not set the rate of others). - Not add another temp threshold structure but add a new trip type "user" and keep using the existing trip structures, so the notification can happen in the handle_trip_point function. The sysfs only reflects the setup via the "trip_point_x_hyst", "trip_point_0_temp", "trip_point_x_type" - Do not use sysfs for setup but rely on the genetlink for one message setup instead of multiple sysfs file writing. Adding a trip point will be straighforward. What do you think? -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog