Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3267025imm; Thu, 17 May 2018 06:12:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpIRlaRKTraBRFvAYMSYCYHC/kFbXxIuu8vlM8goiFB69pd5FfJrfYegiOMO3NvUUEpJq+8 X-Received: by 2002:a63:2783:: with SMTP id n125-v6mr3987098pgn.377.1526562743374; Thu, 17 May 2018 06:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526562743; cv=none; d=google.com; s=arc-20160816; b=WlcXK0LPPmxUu0AM5511npE5xa3wmK9DhoQI1aSPzK/sONw7Bh3QVpz155aF4GL/Kt Kz11aDloO8f4SiJO56ym4Akasuw3aOg4tFdB6Faz+jXRB13mUtDiwEop1RpeK7G3Ulwd QTr/UqtESdNNo/RxB9uyWXyoat6+AR+Wt3J3D4WAW3uNu5d7iMIbLhK4B4oIM7xCF8t9 63OCV8GR7ML0LxfQYOXbYjWUX6MsTUF97sCGvFwMwcDQEWHMcjHTe6nbpz9KSIi7GJih s6AenfI7Wa0pOH6fBBPEMnQc8+CKMJ4bAoYsae84Ub2G8yMFjBQRs+4SM7+9QLkh1gz4 9UEQ== 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=KjiPoBkIrV0iu3geCuzt7YgqJEKOhN88RxSwEJxvtAI=; b=zx+8kSfWSO8b/ysa8RHBOSUr9Sx/BxBzj0Q21cti/fTUJf88Inpzb+/vznGjkXp97e LGo0LPNhwU+sZtgwdtiLTcQD8eeeGfq6N3H/c2v1eR6/mE8ltgfkYDIIYZQIzYrIqLn/ qFmvMipIPh+Y2p1Y9gy6oAeOtkTVpAHM3BpwiWE/4yT4Hbku1pZAFK4TAh8J71O4clko VRdJM9wdBjzyJGy0xwumuWQpmrGZAXIZxbPfxMVYbrHri65J3gpMc2YHGJUaccGv5TIO s/Av08OwATX/VFFb2xeZKxg3kL7ic92ijAaTaW1bTtRu8FlE9HlAEO11p9PxhpnU5hxN ZuUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=ebkAW8GO; 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 u6-v6si4876979plz.461.2018.05.17.06.12.08; Thu, 17 May 2018 06:12:23 -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 header.s=google header.b=ebkAW8GO; 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 S1751976AbeEQNL6 (ORCPT + 99 others); Thu, 17 May 2018 09:11:58 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38041 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbeEQNL5 (ORCPT ); Thu, 17 May 2018 09:11:57 -0400 Received: by mail-pg0-f66.google.com with SMTP id n9-v6so1823390pgq.5 for ; Thu, 17 May 2018 06:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KjiPoBkIrV0iu3geCuzt7YgqJEKOhN88RxSwEJxvtAI=; b=ebkAW8GOlY8x3ql1RBlQfRwk1bt2NXg8web/Chk63n3ekr8+NebrMhQUM4t+zU2QlT 2fB6CFKIdPytkwW4tFpZEi/HxzMgd2isTT7e0brzzfmvCzJzgAQ6VKzMFfCgkLS6J+Is tLIqJmnvZRa/DbvBnTCCyDkfjLGzCzxnNzgMQ= 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=KjiPoBkIrV0iu3geCuzt7YgqJEKOhN88RxSwEJxvtAI=; b=HqVe2YvLyRfgwTjBKmZZ8z3egm7pauFT//b/MbHfuQN5bVgKPlio5zjDP6497K8ioT 3i2puusdpEFL1IsqnK/G2YEI9tA3Dh5iimFBDLgtoVXjMotfB98KQu3ZBTPAl7euSjWn ubfg5kDpwllX0B2UlvdmzgD9gjmmI60nZpC17SlJVoB/+kemLkM9DhDTERwA8xhfRsUd pYwYXaODfyFDHyVzS5S2DI8SS2siaaijc0rn9QrgqyEQX14faekweQQuvoyjVqTEGRxT 9ArGG79GXklQk1xHCidzgwjR7WPEWnylgdjNw4oglLqzD7VDBNuGrxdiyRclYcU4Sdco dzAg== X-Gm-Message-State: ALKqPwf9bby//sz8iK+tJEKkwZovx4BNwSUaJJb/eAjozfeDwBaeqwy9 6hqseDlMrbFJoz/RZnnpx/1b5Q== X-Received: by 2002:a63:7453:: with SMTP id e19-v6mr3951265pgn.87.1526562716561; Thu, 17 May 2018 06:11:56 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id k24-v6sm12261771pfi.37.2018.05.17.06.11.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 06:11:55 -0700 (PDT) Date: Thu, 17 May 2018 06:11:55 -0700 From: Joel Fernandes To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Juri Lelli , Luca Abeni , kernel-team@android.com, linux-pm@vger.kernel.org Subject: Re: [PATCH RFC] schedutil: Allow cpufreq requests to be made even when kthread kicked Message-ID: <20180517131155.GB139147@joelaf.mtv.corp.google.com> References: <20180516224518.109891-1-joel@joelfernandes.org> <20180517050611.yj2alkzckl3ximzu@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180517050611.yj2alkzckl3ximzu@vireshk-i7> 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 Thu, May 17, 2018 at 10:36:11AM +0530, Viresh Kumar wrote: > On 16-05-18, 15:45, Joel Fernandes (Google) wrote: > > kernel/sched/cpufreq_schedutil.c | 36 +++++++++++++++++++++++++------- > > 1 file changed, 28 insertions(+), 8 deletions(-) > > > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > > index e13df951aca7..a87fc281893d 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; > > /* > > @@ -129,8 +126,11 @@ 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); > > + /* Don't queue request if one was already queued */ > > + if (!sg_policy->work_in_progress) { > > Merge it above to make it "else if". Sure. > > + sg_policy->work_in_progress = true; > > + irq_work_queue(&sg_policy->irq_work); > > + } > > } > > } > > > > @@ -291,6 +291,15 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, > > > > ignore_dl_rate_limit(sg_cpu, sg_policy); > > > > + /* > > + * For slow-switch systems, single policy requests can't run at the > > + * moment if the governor thread is already processing a pending > > + * frequency switch request, this can be fixed by acquiring update_lock > > + * while updating next_freq and work_in_progress but we prefer not to. > > + */ > > + if (sg_policy->work_in_progress) > > + return; > > + > > @Rafael: Do you think its worth start using the lock now for unshared > policies ? Will wait for confirmation before next revision. > > if (!sugov_should_update_freq(sg_policy, time)) > > return; > > > > @@ -382,13 +391,24 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags) > > static void sugov_work(struct kthread_work *work) > > { > > struct sugov_policy *sg_policy = container_of(work, struct sugov_policy, work); > > + unsigned int freq; > > + unsigned long flags; > > + > > + /* > > + * Hold sg_policy->update_lock shortly to handle the case where: > > + * incase sg_policy->next_freq is read here, and then updated by > > + * sugov_update_shared just before work_in_progress is set to false > > + * here, we may miss queueing the new update. > > + */ > > + raw_spin_lock_irqsave(&sg_policy->update_lock, flags); > > + freq = sg_policy->next_freq; > > + sg_policy->work_in_progress = false; > > + raw_spin_unlock_irqrestore(&sg_policy->update_lock, flags); > > > > mutex_lock(&sg_policy->work_lock); > > - __cpufreq_driver_target(sg_policy->policy, sg_policy->next_freq, > > + __cpufreq_driver_target(sg_policy->policy, freq, > > CPUFREQ_RELATION_L); > > No need of line break anymore. Yes, will fix. > > mutex_unlock(&sg_policy->work_lock); > > - > > - sg_policy->work_in_progress = false; > > } > > > > static void sugov_irq_work(struct irq_work *irq_work) > > LGTM. Cool, thanks. - Joel