Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp606287imm; Mon, 21 May 2018 11:06:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZofX6pcYkeYxQxZR/n2zhTmNtsY61ajJHz0I3ruZ9UoIda/zkslaD8prIltrodjsA8GY8iG X-Received: by 2002:a63:6e88:: with SMTP id j130-v6mr2153278pgc.200.1526925997666; Mon, 21 May 2018 11:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526925997; cv=none; d=google.com; s=arc-20160816; b=Eprp235tZd9EU93WmKLVej7ywojzewdWIAdKdfGnPAG2nHr1s+Ck60iDNRW2nVoJFT WcPHxhQeKjbsgiB7RdAxyRvHZCcUobuPXndoBtNTkrF5PLdzwX+e2j1JW1tgZ4AbbKX5 CE83TNp4uGtvLoQ6FwFFmNdsiNAEMkxsgxsWslPZGNqoSds3j0Mgh0/MfpEqlptxE6Wk b3nS1z/GDPXg2xGLpQCN+eHPkUKLig2Wa7nMZyp+IlylL3Q+w0plywO3lkENXs+4j5km DFPQOnTMhvCgISzmTbNIrxTN6zvKxb6UvD5WSYlPL7WV6ZvwFTI2xojVFUWoA1a1wE/a CIKg== 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=HfVCCQ57jSTzk488fiZybuIKKiwimkGKajuAQ+NALjo=; b=GLtICOn8NSjPpUnFZly3Ov+mJC9+E30Z67rvMVLHMjsqGX+brVCShPSD7zaXJMhvlt XZHoA+nTRQ0Tc2raIp8E/HrHkk0ixM9bfd01TlszJa9NiIeerhcz6Xlf4aglGGAgf9x3 fARAL90CU1UbveHZ3U0i6OZvqi27SxwoGsTcfjFySEjgcIqSgQbyk5ElaoobWtTD0jRn QfWUiIWStVebU+kpya7xAxGzyCAidMoVpvOQWZFkKskpVoRdK38RtVxhomdaJattGVUi D2EcLcCXO0Eh8VQ6B4eBW76n8PwsfCTl2IDAlrvy7y5RbKY20ZqEKQto1BUMj/aRj1+X +2xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=kOo3xH7P; 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 d31-v6si14790295pld.23.2018.05.21.11.06.22; Mon, 21 May 2018 11:06:37 -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=kOo3xH7P; 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 S1753545AbeEUSGC (ORCPT + 99 others); Mon, 21 May 2018 14:06:02 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36714 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753291AbeEUSF6 (ORCPT ); Mon, 21 May 2018 14:05:58 -0400 Received: by mail-pl0-f66.google.com with SMTP id v24-v6so9253205plo.3 for ; Mon, 21 May 2018 11:05:58 -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=HfVCCQ57jSTzk488fiZybuIKKiwimkGKajuAQ+NALjo=; b=kOo3xH7PwIB5SI5JDKOr3PyNVDLR1V0Y/05tDhb7COICliuuuAmqUvE5hQDua6v+1L fhZDDwAwvhghDnJdJN+HpoXjqp/Hwm/349TG1MMZFPq07dS25R1PGmqUrv1tODDxc2qj OvdHZ65H/bDvHXqE0l+FA4dKft4GXpzkodTLU= 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=HfVCCQ57jSTzk488fiZybuIKKiwimkGKajuAQ+NALjo=; b=skb2BKERthKjO8WitkTAwmzclSz5C2BlW0Werj3uTfkAcUEG7il9QTMbjTppHyGlcK BiE5m/HU4ueE42lWtwZF2rUyp/nV0tDjiWb5QaMowcY60SHRq7dJLc2013h+zW2jilsP 7MoJ3N6zo7oSkRHrlMj6HCujIEN7jKlp2UaC88ycuqP/auhL/tkaSbsioKtY3pIMLmTj CPLg8PG6/2AjWzmgtegrFA0TX7wOTkxYSVCMxMqlaMq4/FkBOyx+bptGq1QHtQo7Pc14 qnnC4MwuBkUdGQdJllNx5bAOIl/6mZ53wFYWgyAirFOleexLmQkqbj0ZDv1YtLzPZiB2 rKVw== X-Gm-Message-State: ALKqPwdXSZ2B2vCv1gFUMNN50DXN0iA3RMWpl3gYWZ/nwyszpGfRGLqc mh/uCQepP9fdp1a/CpaokavmcA== X-Received: by 2002:a17:902:145:: with SMTP id 63-v6mr21504411plb.332.1526925958425; Mon, 21 May 2018 11:05:58 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id u8-v6sm24262770pgq.7.2018.05.21.11.05.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 11:05:57 -0700 (PDT) Date: Mon, 21 May 2018 11:05:57 -0700 From: Joel Fernandes To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, Viresh Kumar , "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Juri Lelli , Luca Abeni , Todd Kjos , claudio@evidence.eu.com, kernel-team@android.com, linux-pm@vger.kernel.org Subject: Re: [PATCH v2] schedutil: Allow cpufreq requests to be made even when kthread kicked Message-ID: <20180521180557.GA40541@joelaf.mtv.corp.google.com> References: <20180518185501.173552-1-joel@joelfernandes.org> <20180521105055.GQ30654@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180521105055.GQ30654@e110439-lin> 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 Mon, May 21, 2018 at 11:50:55AM +0100, Patrick Bellasi wrote: > On 18-May 11:55, 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. > > Maybe I'm missing something but... is not this patch just a partial > mitigation of the issue you descrive above? > > If a DL freq increase is queued, with this patch we store the request > but we don't actually increase the frequency until the next schedutil > update, which can be one tick away... isn't it? > > If that's the case, maybe something like the following can complete > the cure? > > ---8<--- > #define SUGOV_FREQ_NONE 0 > > static unsigned int sugov_work_update(struct sugov_policy *sg_policy, > unsigned int prev_freq) > { > unsigned long irq_flags; > bool update_freq = true; > unsigned int next_freq; > > /* > * 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. > * > * Note: If a work was queued after the update_lock is released, > * sugov_work will just be called again by kthread_work code; and the > * request will be proceed before the sugov thread sleeps. > */ > raw_spin_lock_irqsave(&sg_policy->update_lock, irq_flags); > next_freq = sg_policy->next_freq; > sg_policy->work_in_progress = false; > if (prev_freq == next_freq) > update_freq = false; About this patch on top of mine, I believe this check is already being done by sugov_update_commit? : static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, unsigned int next_freq) { struct cpufreq_policy *policy = sg_policy->policy; if (sg_policy->next_freq == next_freq) return; sg_policy->next_freq = next_freq; sg_policy->last_freq_update_time = time; ---- thanks, - Joel