Received: by 10.192.165.148 with SMTP id m20csp5165233imm; Tue, 8 May 2018 23:56:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqovHomQozLeMaIWhbMmRYh+YeYUZKRK3u7f3AYNPmcUC7wi4aI14sc/ky/EXpa3Tvfa6hk X-Received: by 2002:a63:6307:: with SMTP id x7-v6mr3218651pgb.269.1525849002555; Tue, 08 May 2018 23:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525849002; cv=none; d=google.com; s=arc-20160816; b=TNL/tUeLiRq9w2sCkHIDM7Px5KuRf13KsN4g0NIWlEe74b2pPj9dQw7ePYD29m3msj h1NZF9xHFzq0dt4jZd1GgrjE/SHlIaCr/fble05mkw4wJ3ag2RS+mt3aX3N+udwVxD3S 21itzyW856VZPZ2FsQ4FncPWBJm2NW0cS5Fopr9dXFnq1aHY0gbJuR0fKYSiwoJ3GOqo VZBMmBMCxHibmliCDZcEzYs7bTZ9EErZutdJaD6ME56bfk+oBOenYADIARHJaFO2ZWGr iNnrVuan/QpLH5aE1Umib/4EJfwZ+k+VQm82zxmBBR9KUX6LVdfabzHUd/mUGRZ6IiG8 kLlA== 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=uo5bIagifMxeSpUw6V3xewKhZ8TSn/FgiP5HzXSZqNM=; b=QV1gu7uf7ttb7cO40Z52bcVGS8VT5RSKnMeRRsehp7q7bFmhipWUJXwGCJxfVcqy2V f6KC4c7U7CIIwvKdXCXHt0iT/FbZDMYMeCeyw5MT5aDE0wp94NCakZO9cr1f9+p2xOwm KyN6p3oNjmLzKrCF8KvRG/NqjowozwplyMLw6dJjm4qUS4JKoX8ICJW3N4ZTou4oK5dk AbRJ06AmwHfacrRKLqGebm6r08IDpFDiab7ZBD5zXiG8qDIXDdaPUvcy37C9ffl+LGIW Vekkz9IyBwb493hT/vtoSd+O0j23/LbCpESzxqe8bti2EfGO0jD4qKVkFzED7w4JtvK0 gUwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=D3Pg7ln3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si25564781plb.312.2018.05.08.23.56.28; Tue, 08 May 2018 23:56:42 -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=@joelfernandes-org.20150623.gappssmtp.com header.s=20150623 header.b=D3Pg7ln3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756218AbeEIGzV (ORCPT + 99 others); Wed, 9 May 2018 02:55:21 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:43181 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756199AbeEIGzS (ORCPT ); Wed, 9 May 2018 02:55:18 -0400 Received: by mail-pl0-f67.google.com with SMTP id a39-v6so3735097pla.10 for ; Tue, 08 May 2018 23:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uo5bIagifMxeSpUw6V3xewKhZ8TSn/FgiP5HzXSZqNM=; b=D3Pg7ln32r/lAbZ99YxfYyzZcCTB/iJLHLZhtW1eI+59Jr9qXaZE3GnR5+9GBWOD0I NoldckbRbmCkngP9KDADmdl4cIWzZFHqhI6Y1gQchnwpnLRTxxQhfqOnKRLWmTmcg917 CzDMu7eaq1p1nAYF3tN4MSmPCCJoRPFO9LNjnVQxki8RIrHpgRHt8rgrXfqJuQk1kzKl XpreUeRgSZE9803jQcMyowiNOMv99JJEzSS/Fdi5eNxXKu5bsoBVgH5YXQq0igobannH sNT758XACmy/3dXJJgVi8y/57BpMLw8sYwWj34F26UuPdA8b3TMnI54TBXxzmrqdGMnU yaMA== 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=uo5bIagifMxeSpUw6V3xewKhZ8TSn/FgiP5HzXSZqNM=; b=SssIPMHBm/OTHzsW8FLEbzPFReJKTDuIm4KLqHTyd33lnBA1SRKcJe8fuIbdeweS+E gFCaRGpRyxuhJPpXc8TyVJV9VjvpuxKGkDVbzT32XtukU+yxZBJi1Z0hulZaPpTt9rdd 0mSK/QjwImUIAuKA3e7/H0WWnLe90+9nYkU5c4+wXope8v62cdkjsaKM1UKe5Smfv4Ps pm4GTzlgt9aG3BOchCR+GWN52KThEC3eohi9nRteQuTG9oSb3JEVqjmi1D6AqsaWjRIp dK0zwCRGKVXPOpdcjkWNGd/2mp9naqGKt0ovMhela2o6RsRp0Iw4F4xtL9CVhcIrdkAw lRqA== X-Gm-Message-State: ALQs6tAErB5lX3dBBClvtxKW14OQ0MJ+KK+sexuFXIAJnHkY0yOyI6oV UpxEfNbpO7rTgXdruQqlJv5TMQ== X-Received: by 2002:a17:902:b485:: with SMTP id y5-v6mr12644572plr.381.1525848917401; Tue, 08 May 2018 23:55:17 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id n10sm58595691pfj.68.2018.05.08.23.55.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 23:55:16 -0700 (PDT) Date: Tue, 8 May 2018 23:55:16 -0700 From: Joel Fernandes To: Juri Lelli 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: <20180509065516.GA52784@joelaf.mtv.corp.google.com> References: <1525704215-8683-1-git-send-email-claudio@evidence.eu.com> <20180508065435.bcht6dyb3rpp6gk5@vireshk-i7> <20180509045425.GA158882@joelaf.mtv.corp.google.com> <20180509064530.GA1681@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509064530.GA1681@localhost.localdomain> 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 Wed, May 09, 2018 at 08:45:30AM +0200, Juri Lelli wrote: > 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? Yes, I was also thinking the same. I think we can come up with a better mechanism that still doesn't use work_in_progress. I am cooking up a patch but may take a bit longer since I'm traveling. I'll share it once I have something :) thanks, - Joel