Received: by 10.192.165.148 with SMTP id m20csp5277344imm; Wed, 9 May 2018 02:16:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoOMb6ktb/Cv+3CDlvx1tNhgIz9+XF5gMWiIsXPjce5nD5sGizFd0VEz+Jl+sChUWFtrY9l X-Received: by 2002:a63:41c1:: with SMTP id o184-v6mr35237459pga.393.1525857408438; Wed, 09 May 2018 02:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525857408; cv=none; d=google.com; s=arc-20160816; b=ceroLm2oMtn6j22W7z38FA9epD7J9HBy6p/2CCr1RMqcLbiHRHV6qCK9L+rC5isBBM g+/tQHU4wYMEW74HP7wzcr9nOneVZAQsZqP/xMcvRmT0qXgpnX6bJQNJGby/dSWA2fUJ eU8As+8JY9pQJgYr/qG959zfWg3qu8Rz4tj5x+hAAZiqSxMJupJGbE5Zwgh8Hx1Qhwfx jzHdsxrG+YfOHF4axZbTwo8Ea30EtK0WmJYp6BBFQp/Pm7cj4cPeKI/HaOMyDpqqJdx5 h43mIi1wY/L4ZzQiEwRrKp06erEK/+42gr1TsSLsp1IqfSNciy9+rMoekR04wdQSWV2L xOPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=qdhqL6oU5gWbxAkSmwsUsgPTfvgr0qUyefDvcxnYKvk=; b=VlCxBiFP/v2d54tyPQrijR6glZ854Mg8sdKc8t3Z0CmbUW8h76nQWofNjbEe+9y+7M mHZtZDLcu9Q5C45H43GG2hJNxyv0EldR693e7WUYw+Z/u2FFQn1ofAunEtqKrDHULBrr pGcc9XiNttx9jbipoE7xRycLf3FaPzbgJOFhwReK1qC3gAgqMsg3dxT/Tf+FDvUJXXsE fz8f+nAVLmuQ0w4gZp54Xahhfdnw2YZ8Sl8L93qdwysLrXRqo1jlS4aKnG/umEHN+Rfa sOyZhSjHeGN8f4WYb6XHMHgNvw7WZ9zJDmSa6PFDNoRa/VT4pupKUaYmdE6Dl/qcrvOL DX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rb1yhgFN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j7si25604629pfh.3.2018.05.09.02.16.34; Wed, 09 May 2018 02:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rb1yhgFN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S934537AbeEIJPZ (ORCPT + 99 others); Wed, 9 May 2018 05:15:25 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37522 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934246AbeEIJPW (ORCPT ); Wed, 9 May 2018 05:15:22 -0400 Received: by mail-pl0-f65.google.com with SMTP id f7-v6so3938946plr.4 for ; Wed, 09 May 2018 02:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qdhqL6oU5gWbxAkSmwsUsgPTfvgr0qUyefDvcxnYKvk=; b=Rb1yhgFN9ARHPgF38JxyktoCBsyhN0BAEVTmbtj53YTr+Zdngzq+xi8Ei2pN4Np0gz 4/HwNdLwzPewmeQV9ootP/msnEbSyzyLDog8mkG02hB/CvWNpBVNquEczD2aMCwZH1In K/fmf95mA1ZGLfoSFDDceEbAdVRro1NIzQk9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qdhqL6oU5gWbxAkSmwsUsgPTfvgr0qUyefDvcxnYKvk=; b=AUuAf31zdWDEfHulyQjhY//gabWcx0iWLFcofGNqO3qRgGT/6PTvBf9/8H3mTj7Q9F CRTKAKGyp8Xszi9cWxPwLPkc12kOZnsX9dVAV2XNGpT3+xmfUcu8+DQkI0HCeckyqI2R QnpbYvGrl+RDGnE+aStM2KHkfB1U+ALaEJDwThMPtyPcUtDEKJqDbcD2MVCfLklT8MAm vHnxvGdvJIub1gb0r9hcs/hiQkGI2lYU4GwugWxhw/dJ91pyIRgR1niqRka01kHI2Jun 3N9HMa7v7RghRliAxNTPez+tfoLJOqtf9naXqSyTxfJMgyRUjbuLUy0qNOO190lEoV1J JFtQ== X-Gm-Message-State: ALQs6tA7tAxHaNhlt3B301OJP/5Ktsn/pyAQYaUTi2An6Tc8CC3bjykb NQif8EuAm3GMTwk8DGKgzzIZHQ== X-Received: by 2002:a17:902:7441:: with SMTP id e1-v6mr30367241plt.238.1525857321617; Wed, 09 May 2018 02:15:21 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id y197sm47537873pfg.184.2018.05.09.02.15.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 02:15:21 -0700 (PDT) Date: Wed, 9 May 2018 14:45:19 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Rafael Wysocki , Ingo Molnar , Peter Zijlstra , Linux PM , Vincent Guittot , Claudio Scordino , Patrick Bellasi , Juri Lelli , Joel Fernandes , "4 . 12+" , Linux Kernel Mailing List Subject: Re: [PATCH] sched/schedutil: Don't set next_freq to UINT_MAX Message-ID: <20180509091519.czq5zu5l7xfhqph4@vireshk-i7> References: <872c3f8690d9362820639d91a807e535f10a9a36.1525761635.git.viresh.kumar@linaro.org> <20180509084128.s3nu57njyep4tw2w@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09-05-18, 10:56, Rafael J. Wysocki wrote: > I'm kind of concerned about updating the limits via sysfs in which > case the cached next frequency may be out of range, so it's better to > invalidate it right away then. That should not be a problem as __cpufreq_driver_target() will anyway clamp the target frequency to be within limits, whatever the cached value of next_freq is. And we aren't invalidating the cached next freq immediately currently as well, as we are waiting until the next time the util update handler is called to set sg_policy->next_freq to UINT_MAX. > > What else do you have in mind to solve this problem ? > > Something like the below? > > --- > kernel/sched/cpufreq_schedutil.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > Index: linux-pm/kernel/sched/cpufreq_schedutil.c > =================================================================== > --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c > +++ linux-pm/kernel/sched/cpufreq_schedutil.c > @@ -305,7 +305,8 @@ static void sugov_update_single(struct u > * Do not reduce the frequency if the CPU has not been idle > * recently, as the reduction is likely to be premature then. > */ > - if (busy && next_f < sg_policy->next_freq) { > + if (busy && next_f < sg_policy->next_freq && > + sg_policy->next_freq != UINT_MAX) { > next_f = sg_policy->next_freq; > > /* Reset cached freq as next_freq has changed */ This will fix the problem we have identified currently, but adding a special meaning to next_freq == UINT_MAX invites more hidden corner cases like the one we just found. IMHO, using next_freq only for the *real* frequency values makes its usage more transparent and readable. And we already have the need_freq_update flag which we can use for this special purpose, as is done in my patch. -- viresh