Received: by 10.192.165.148 with SMTP id m20csp5158125imm; Tue, 8 May 2018 23:46:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwGnxMMzu8HB6I4ZXqbhU1iZGG/61iX6MumbB4WVlxBw7dyjBrpDIFHUzuy9HrzV/6IpL9 X-Received: by 2002:a17:902:229:: with SMTP id 38-v6mr18793573plc.384.1525848369812; Tue, 08 May 2018 23:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525848369; cv=none; d=google.com; s=arc-20160816; b=SWf3wo2lZbhE55VT/Nx0TVZJrMBJPk1ODodOb4gJt9iU5dnPSijdXc3kCGquF1MWBd 6X/AKmh2uf7D/b2cK3/mgf3FN90nzHWTkyHu6C8uThTyacmm5kBCVA9bcimbwmVEYf91 GUBtdok2FtjYhN+IQ1OVTbWzCbfHDS2zK8o6XT/BlIbG3FlJVvWdosEzInWS3PfRc9LG eolS9U8f9lC2T/giIhbNSCjDcs8iq+AQkjsg7l4W6vx4xap4337rhH9fJgJP6NAC5FIo APTMofgm7TEYOJJRkMHkP3PwROCjnyXay3jWEnWrY6bLskS7w9dWVpltfb4L+LMAk5pY hvuA== 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:arc-authentication-results; bh=M+qVn/EwUrBFvKT4GmL94drOX2Kv40Nzew7Knh7Sn0g=; b=gIZ4tpUAgn/S+ZlRW//8qQY3BFb3u15ge9N3DwRqHFYg+XqWlz5Xx6kA7lj5bRQLM5 4r7oZS2zpQe2gHkEK1kS1OXUF2dTCeN7ZeR5RB+JGjTRLTK+d6ah4xtgDHLCETsqtZWC 1EbRKwpvDd6BXD/HvCoZ2olk1K7QO5+eqT6BqtIW5dn0ZAOCe2aTeEBZg3crksi7hAUS TYq0mQxqJLrcybX1kcam2eKsTBV+yEVdBNj+I9VDGRqxeJZDLJ5K/aGajGRRrUi2edXS K1O0NN7RYMCVa3PffjlvpUhIJeh6pXVyY40PZiVG1DhXGodkcqCh8FZ0FnthLgs9NuXB JwJg== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7-v6si26267542plo.486.2018.05.08.23.45.55; Tue, 08 May 2018 23:46:09 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756186AbeEIGph (ORCPT + 99 others); Wed, 9 May 2018 02:45:37 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:46108 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755889AbeEIGpf (ORCPT ); Wed, 9 May 2018 02:45:35 -0400 Received: by mail-wr0-f196.google.com with SMTP id a12-v6so3681190wrn.13 for ; Tue, 08 May 2018 23:45:34 -0700 (PDT) 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=M+qVn/EwUrBFvKT4GmL94drOX2Kv40Nzew7Knh7Sn0g=; b=ORMWSrkrk9Xkyai/ta6q5CdpjHu403kHMWsU4adS6G6hHgvyGET1jtjDrlxc3SstI7 JRFii6r1Wuic3Q6Mfai/Gj9DOtdZADmQjnY/FwwNqZz2Elf6Gfi/Lv+tigWxeT7k0CE9 EnNyhv/rndXfMaOjmkEZkaOdjH0N/i8i/2/1ddLaPVMZx6VWUeRVq+UYl3gBC8PZ3wTQ Wq9G0CFX1G2kBkgunnkftoDC1E9eDTNtBq9kQbLBcENS7Ogva8RDyJyTaex2mh3Y6QYA vIGL9NO52O6yXw2EXrdDuCHI2+QGcs1wY4YkKjIMRCAqgF0li1vcJ2jHALPKbUUwEt1o 8mBw== X-Gm-Message-State: ALQs6tA8/yLx6SdqbDz+VgGy2dV5N2wPdWTuzQjR2cmSovw5FfLZSAkJ lsKSsdOyhYa8hWxUgKgVjdCfCQ== X-Received: by 2002:adf:e78b:: with SMTP id n11-v6mr33513061wrm.192.1525848333967; Tue, 08 May 2018 23:45:33 -0700 (PDT) Received: from localhost.localdomain ([151.15.207.48]) by smtp.gmail.com with ESMTPSA id 4sm15030289wmg.40.2018.05.08.23.45.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 23:45:33 -0700 (PDT) Date: Wed, 9 May 2018 08:45:30 +0200 From: Juri Lelli To: Joel Fernandes Cc: Viresh Kumar , Claudio Scordino , linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Luca Abeni , Joel Fernandes , linux-pm@vger.kernel.org Subject: Re: [RFC PATCH] sched/cpufreq/schedutil: handling urgent frequency requests Message-ID: <20180509064530.GA1681@localhost.localdomain> References: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> <20180509045425.GA158882@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509045425.GA158882@joelaf.mtv.corp.google.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/05/18 21:54, Joel Fernandes wrote: [...] > Just for discussion sake, is there any need for work_in_progress? If we can > queue multiple work say kthread_queue_work can handle it, then just queuing > works whenever they are available should be Ok and the kthread loop can > handle them. __cpufreq_driver_target is also protected by the work lock if > there is any concern that can have races... only thing is rate-limiting of > the requests, but we are doing a rate limiting, just not for the "DL > increased utilization" type requests (which I don't think we are doing at the > moment for urgent DL requests anyway). > > Following is an untested diff to show the idea. What do you think? > > thanks, > > - Joel > > ----8<--- > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index d2c6083304b4..862634ff4bf3 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -38,7 +38,6 @@ struct sugov_policy { > struct mutex work_lock; > struct kthread_worker worker; > struct task_struct *thread; > - bool work_in_progress; > > bool need_freq_update; > }; > @@ -92,16 +91,8 @@ 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; > - /* > - * This happens when limits change, so forget the previous > - * next_freq value and force an update. > - */ > - sg_policy->next_freq = UINT_MAX; > return true; > } > > @@ -129,7 +120,6 @@ 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 { > - sg_policy->work_in_progress = true; > irq_work_queue(&sg_policy->irq_work); Isn't this potentially introducing unneeded irq pressure (and doing the whole wakeup the kthread thing), while the already active kthread could simply handle multiple back-to-back requests before going to sleep? Best, - Juri