Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4986243imm; Fri, 18 May 2018 14:18:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcSTk0SXfySHY+4HMdzcB9WL2N8gHEr3wWneKA0BxYRMCqcdPr223dvZT4RQ7CsVRcrIVA X-Received: by 2002:a65:5a4a:: with SMTP id z10-v6mr8767306pgs.243.1526678329255; Fri, 18 May 2018 14:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526678329; cv=none; d=google.com; s=arc-20160816; b=w9lEIVawICLQUblF9PTNxSU8jQ0oQYQWJr3Q2NFhOaIIPEb8BuE7bn9IF/zyW390oW EcifmfcJBIIktaDphbLvepIzfbi2OKTCgEswbKBFmeKKvj67tHtJXXhN7N/IoUibcrtQ Vo11w5g5qmw3lqvkjuZiuU2GwQckr6zWx+Ofibxi8Hbwcn2YpCIqtJx6p6DwqUYrZqY3 yZDh6+5xyfk1wzP7lvTV2xp53efmvCmLS6Ya9eZHdiEi5Ur6OnecdGx2ZAq6DlCM0k4K AbsmxA8h+dVemW5sPbCumBqbZdBHlnQaK8Q0xUxRykdhauH2xzdI1VpePw2juapwnUQp DG6Q== 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=hscuGX4xNa1GZltkOYFHesz16tcne0LwyoXD6R3YqUc=; b=pdunQ+hvOzo1+UdgwwFZbazIbDOfuonv9+Cz65uRP/5OjXQVcRxfhZjifSeYO4NZpM U1dbwi5epSn/tsc1dWwZdMfnKElTyz6at756nefrDmnlSA+Ur/xV6KIMYpWkPCAvSeMn k4slxoZxux1RVLDHSEtRR0oQ3Cec9ZtOzCLaRdVhgX5BogbwrRunDO68jpXMF+q4dkad GzVKodtugwin5DSN0D3Yh5sDgCmTgWmUFY8YaTtnTBC1DCXU/ppJrAcWCd2w7H1OLWHw f0ZRTYimY06kyu+azJ3spGDJhd++fhpjYfK8wBD2BnNZ9wEGWiu3/r0xa2EJEk5hlmuy +wAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uGlhjNCs; 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 t17-v6si8294523pfj.10.2018.05.18.14.18.35; Fri, 18 May 2018 14:18:49 -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=uGlhjNCs; 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 S1752428AbeERVRJ (ORCPT + 99 others); Fri, 18 May 2018 17:17:09 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:41659 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752224AbeERVRG (ORCPT ); Fri, 18 May 2018 17:17:06 -0400 Received: by mail-oi0-f66.google.com with SMTP id 11-v6so8302605ois.8; Fri, 18 May 2018 14:17:06 -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=hscuGX4xNa1GZltkOYFHesz16tcne0LwyoXD6R3YqUc=; b=uGlhjNCsCZMvhq68gWkipMka6TUMMSGOYHxWhhmPKpiK81ywsmDZddyjOK8++t6GOq 44ab8Kyia9xvDSgTtZK5J2LXrNOUgXH58tyfTF2Y5LxMfgiR81u4cewleGL2661U+qTP bUrZac10S9hvLK3FpUUDq0Xss8z9UwuP+KNRXS5KLjLRWCSff0rsHgB13qdAfvLfQ5Zy INVFQGvXX34avddpxvG1Px/QDOeEqbzIJyW2ZCZglwFEEmCTqxXeuKLRlGfTu0wZlqTx w6nXdt9zSZTbVTm959kEEJGMTOm7bQJxHXZL4LjnVQlT59Uxjr5BuwPcaRbBx6gUtX8k hbBQ== 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=hscuGX4xNa1GZltkOYFHesz16tcne0LwyoXD6R3YqUc=; b=o1xyACFUAWEAQkYnfBuruDA0SaxbFJKQWk4QvMBZJVAdIot4pWjSOPP09yBrbJk8XV hS4sI5IB1iXqRbNnNkQijQY/HkySA0wGiYPVTQMEofQjeA8+U0mXclCRhcwA7Kp4MPfP gumN5SYoHnWssR3x5OtrkoVa4QrZRcd6WV1+rq/oO1eGAMntN2gczQyg97Y+rxi3fdiT T0NFADe0pOElYj9WL23HJIx9FHIc09S/YKU9kzi59yJreV+HDAaW7wF28isUtz9by68n j+xyM4+ErbqeTemZy9NJdSXL6fFLz4Et3CJreD0RuPwZ44iJ7kNkYvjbTRhQG5TrQOzj 6y9A== X-Gm-Message-State: ALKqPwfm4Ft+98B++My3zIYYba0M/G+eN6i2l1GwLfbGWHK7L60sAh+e bWoopi/3eB/pZMML7pTWqavugoolqCcjDZgD7q8= X-Received: by 2002:aca:e156:: with SMTP id y83-v6mr6273576oig.282.1526678225905; Fri, 18 May 2018 14:17:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Fri, 18 May 2018 14:17:05 -0700 (PDT) In-Reply-To: <5AFF41F9.6050300@codeaurora.org> References: <20180518185501.173552-1-joel@joelfernandes.org> <5AFF41F9.6050300@codeaurora.org> From: "Rafael J. Wysocki" Date: Fri, 18 May 2018 23:17:05 +0200 X-Google-Sender-Auth: H7RneGRbFoVbYkmaswkne1u3NQ4 Message-ID: Subject: Re: [PATCH v2] schedutil: Allow cpufreq requests to be made even when kthread kicked To: Saravana Kannan Cc: "Joel Fernandes (Google.)" , Linux Kernel Mailing List , "Joel Fernandes (Google)" , Viresh Kumar , "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Juri Lelli , Luca Abeni , Todd Kjos , Claudio Scordino , kernel-team@android.com, Linux PM 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 Fri, May 18, 2018 at 11:13 PM, Saravana Kannan wrote: > On 05/18/2018 11:55 AM, Joel Fernandes (Google.) wrote: >> >> From: "Joel Fernandes (Google)" >> >> Currently there is a chance of a schedutil cpufreq update request to be >> dropped if there is a pending update request. This pending request can >> be delayed if there is a scheduling delay of the irq_work and the wake >> up of the schedutil governor kthread. >> >> A very bad scenario is when a schedutil request was already just made, >> such as to reduce the CPU frequency, then a newer request to increase >> CPU frequency (even sched deadline urgent frequency increase requests) >> can be dropped, even though the rate limits suggest that its Ok to >> process a request. This is because of the way the work_in_progress flag >> is used. >> >> This patch improves the situation by allowing new requests to happen >> even though the old one is still being processed. Note that in this >> approach, if an irq_work was already issued, we just update next_freq >> and don't bother to queue another request so there's no extra work being >> done to make this happen. >> >> I had brought up this issue at the OSPM conference and Claudio had a >> discussion RFC with an alternate approach [1]. I prefer the approach as >> done in the patch below since it doesn't need any new flags and doesn't >> cause any other extra overhead. >> >> [1] https://patchwork.kernel.org/patch/10384261/ >> >> LGTMed-by: Viresh Kumar >> LGTMed-by: Juri Lelli >> CC: Viresh Kumar >> CC: Rafael J. Wysocki >> CC: Peter Zijlstra >> CC: Ingo Molnar >> CC: Patrick Bellasi >> CC: Juri Lelli >> Cc: Luca Abeni >> CC: Joel Fernandes >> CC: Todd Kjos >> CC: claudio@evidence.eu.com >> CC: kernel-team@android.com >> CC: linux-pm@vger.kernel.org >> Signed-off-by: Joel Fernandes (Google) >> --- >> v1 -> v2: Minor style related changes. >> >> kernel/sched/cpufreq_schedutil.c | 34 ++++++++++++++++++++++++-------- >> 1 file changed, 26 insertions(+), 8 deletions(-) >> >> diff --git a/kernel/sched/cpufreq_schedutil.c >> b/kernel/sched/cpufreq_schedutil.c >> index e13df951aca7..5c482ec38610 100644 >> --- a/kernel/sched/cpufreq_schedutil.c >> +++ b/kernel/sched/cpufreq_schedutil.c >> @@ -92,9 +92,6 @@ static bool sugov_should_update_freq(struct sugov_policy >> *sg_policy, u64 time) >> !cpufreq_can_do_remote_dvfs(sg_policy->policy)) >> return false; >> >> - if (sg_policy->work_in_progress) >> - return false; >> - >> if (unlikely(sg_policy->need_freq_update)) { >> sg_policy->need_freq_update = false; >> /* >> @@ -128,7 +125,7 @@ static void sugov_update_commit(struct sugov_policy >> *sg_policy, u64 time, >> >> policy->cur = next_freq; >> trace_cpu_frequency(next_freq, smp_processor_id()); >> - } else { >> + } else if (!sg_policy->work_in_progress) { > > > Not really something you added, but if you are modifying it: > Do we really need this work_in_progress flag? irq_work_queue() already > checks if the work is pending and then returns true/false. > > Wouldn't the issue you are trying to fix be resolved just by dropping this > flag check entirely? You've missed the entire discussion on that several days ago, sorry. Thanks, Rafael