Received: by 10.192.165.148 with SMTP id m20csp5283259imm; Wed, 9 May 2018 02:23:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp0+tMwXBwriaRow4vmsykph8MXrYxGkW6meHI8xWY9MbfyF/CelhS0DjiEWkvGBG7A8/mZ X-Received: by 2002:a63:6e0e:: with SMTP id j14-v6mr4560751pgc.218.1525857825497; Wed, 09 May 2018 02:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525857825; cv=none; d=google.com; s=arc-20160816; b=y0i9DadXGvMdJcWkBGhm2RCbUVf9GfPskYIfUIMLVH9DTTDLYnepreXhio8NwiyuKq hR4fIGu5N7Uy/uomU1K71jCg/1iMJxV4bYBvsMZ386fw5MktmI25EIpEoRtwdoHVyPGS aVoegGWPREMWQ9pLFFcurt+k+jtjQIiR9hHJ5VsU6/qJDCHt4jwplCjU2TpGj9EBP5Rr LsWsa2pAv2SwRHkLfQBQ78FpyuE17tpo5CNaIcDB7KMB+PdU3SQM1Z8bTBVl13UM9wpf DJu6n+6EdQVl6dqlmEzjkXDopRZqxErcA08tM5IDNe/Fgr3x5TrCCxsuX/YGeRTLrZUy 0SIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=pmu+EeoXdsGysnT9iUcchHq1KV2f8u5Jbkc4iwBGgDI=; b=VUJYFNa2LxGAFSZkYbE8jV90fFVGmCvMxzKkormjfUCXGNUxVAyJPKPM3JQXeysaLK wYVp4qY2DyB7OtvwexjMKGppWeCdeBidVDr2VGmC/3PERRRsM4fEKex8PO0LxcPGpXbt B/HxPXk8vqAhjCxpL19xbeA2SuvYy0e0SqJnnwVVv92xvqwuB91GeYgrFKCBHatSbDg5 PpPQrc8ND0Yc25ozgDnE6mbXQIFi9Za8kV8GCrFKSyPDa8NTgMZC2rPa2sej7TlFZ4HB MS/Fgy4cQGi08Vqrl8mQ4iCscZAnildWytKeo/XcIcNDD4PAHJp+BvEq1216+R+6x8Um Wiww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=p9hMEQ65; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si4847311pfi.254.2018.05.09.02.23.30; Wed, 09 May 2018 02:23:45 -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=fail header.i=@gmail.com header.s=20161025 header.b=p9hMEQ65; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934604AbeEIJXE (ORCPT + 99 others); Wed, 9 May 2018 05:23:04 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:43054 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934387AbeEIJXC (ORCPT ); Wed, 9 May 2018 05:23:02 -0400 Received: by mail-ot0-f194.google.com with SMTP id y10-v6so39354878otg.10; Wed, 09 May 2018 02:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=pmu+EeoXdsGysnT9iUcchHq1KV2f8u5Jbkc4iwBGgDI=; b=p9hMEQ65Uz3waDklBhPHmpSvREOtOYLy6AWQdgRJGQy+MZsGNh9NDbTbOq4C5v1rGd X5EP8sMr77utVf4Py/fDSgT2yQdB5OnRi8BwB1jo7PqYSa0p9n7s4UloJnNT6tXb6NYM N6ITFR1hDDehRxjd25mJymdi4KLy4ktGnON9ZzQsAS3FtgJzqypn1HllSALkiDgRoLwM UDye8To6PMC/Plu55S00/BZErFGECIM9q0WIorN4fxCliWMDbj5e4G8EzzslrvGAHnwu ap5GuktVYEkhn4Fu+HuR6FJ0S4FG/VfFQzh9ITCZSp/V5deze0hScxthPGXeHtgIImqp DJcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=pmu+EeoXdsGysnT9iUcchHq1KV2f8u5Jbkc4iwBGgDI=; b=ueFFhDyKFfYuo4+2KbcAxXTy92dM5AOVj8PwvFMEyZGd/S0JHqkknlKLrrltL0W9p8 dr6nrPcIQGzgLYdPBwRDISkSBrhPDVwxH/V/YPCnTi8wFV/erbhl2M4rq6cPt/n9o2b0 Ek6LpM/w8++KnJfIGPTTbC7R9MIqENQdIztMa9JZbKkVXCbQ91rVV6l/4C6jcBKv5PRs igFDEf/CjG+Pg1X/mXPRTIg9YmfRHp/6VIGCgx8+vUMe+UXTEMhz820gEESULb4O7srV SfDsM2DST960wo+F64ENKEHJKDCySeSj0WSuigaQKICbGYih21B8/mUClKjS58v4Lfis OpSw== X-Gm-Message-State: ALQs6tBemeQbWnFIHsKhkqXrIS/VizNRukJdmR/HUSW/VJYMZYuOuQME GV4IiODhjZbh/uLCFKYyzFo5t7yHhCpbzAMJgg8= X-Received: by 2002:a9d:721d:: with SMTP id u29-v6mr30672972otj.305.1525857781564; Wed, 09 May 2018 02:23:01 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Wed, 9 May 2018 02:23:01 -0700 (PDT) In-Reply-To: <20180509091519.czq5zu5l7xfhqph4@vireshk-i7> References: <872c3f8690d9362820639d91a807e535f10a9a36.1525761635.git.viresh.kumar@linaro.org> <20180509084128.s3nu57njyep4tw2w@vireshk-i7> <20180509091519.czq5zu5l7xfhqph4@vireshk-i7> From: "Rafael J. Wysocki" Date: Wed, 9 May 2018 11:23:01 +0200 X-Google-Sender-Auth: sX7I-KvMFurIS7i3bQAgq9sl_uk Message-ID: Subject: Re: [PATCH] sched/schedutil: Don't set next_freq to UINT_MAX To: Viresh Kumar Cc: "Rafael J. Wysocki" , Rafael Wysocki , Ingo Molnar , Peter Zijlstra , Linux PM , Vincent Guittot , Claudio Scordino , Patrick Bellasi , Juri Lelli , Joel Fernandes , "4 . 12+" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 9, 2018 at 11:15 AM, Viresh Kumar wrote: > 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. The fast switch case doesn't use it, though. > 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. So I prefer to do the above as a -stable fix and make the UNIT_MAX change on top of that.