Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1394269imm; Tue, 22 May 2018 03:26:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrf4qv6kTggvp/YZHisCTu+/MKJ2O8tdN19TDyoXqsFE+hNcTI6MOwP3lkqDJS/VIQzTB9l X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr24240218plc.248.1526984815805; Tue, 22 May 2018 03:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526984815; cv=none; d=google.com; s=arc-20160816; b=tpRpRWrm3eU2FEJvA5emn4g0ufn4BJc4LbZeJpNtqsNam0QrVR6LJL20bNBQlI5dGo H0WO3lSqhvbRmnpwUTrxHqkil/zp89s5/aLm3pberH95GqqjwPciir3ammf/xl+ITcLX wWk7E+QSNT/T/hKHNT1y5r+CRsSLzNjTabw9cLDkPb7QbCU91gaQ2rnlVG5qmfDOy433 leobBy8wGFGuNz0dm1ZIe3InvlOiz/rF5OioN/8cqXdDxgrsBvss8052d+PN01HTxJQ9 umkHlsV6noZaqc7TXDt8Yfh0gxLMHvuvDMy/OCay3WqejgQhmBp+9RX2BfFbruUGXXU0 QFlg== 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=o3nui+xZTw+3q0jwg+w4Pg24QxG1Sz2y/zA4N/3VTQM=; b=pXJ3RcujsxjxwWntj10MnXiOIFst05MLuTneEZ8ZRj8argl+d+K30NXsYGkA+KGTgA bkrmD51BLKyGlklATR4nuXYqcTEqPktCLpEPdCuhGcZcMVqWgLNkj04qhQ4DgF5Fcu1n upB+cpkpXeWxOvJloG5f1f2DpgXBBwF29VAIwaoFsC/+UGD0A7VQL+A9zLZGOTXsGw3R BHswUSM2UOQBglGx+/BPRsS+XyNoYQmMQLT4ovb0i+gDC9DVSt/bESb6DyZ4Qp29ESxI 86J9wf9pX0MTLVfxJhhypvX0YpW1Gzy2Yn7ZWYdInXwbrr4KFycc31vDrUqD4B2RzGLN T2xg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8-v6si12502249pgr.111.2018.05.22.03.26.41; Tue, 22 May 2018 03:26:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751401AbeEVK0R (ORCPT + 99 others); Tue, 22 May 2018 06:26:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34510 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751160AbeEVK0O (ORCPT ); Tue, 22 May 2018 06:26:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F6801596; Tue, 22 May 2018 03:26:14 -0700 (PDT) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EC7CF3F24A; Tue, 22 May 2018 03:26:11 -0700 (PDT) Date: Tue, 22 May 2018 11:26:09 +0100 From: Patrick Bellasi To: Joel Fernandes 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: <20180522102609.GV30654@e110439-lin> References: <20180518185501.173552-1-joel@joelfernandes.org> <20180521105055.GQ30654@e110439-lin> <20180521180557.GA40541@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180521180557.GA40541@joelaf.mtv.corp.google.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-May 11:05, Joel Fernandes wrote: > 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? : No, that check is different... > > 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; > ---- ... in my snippet the check is required to verify if, once a freq swich has been completed by the kthread, the sugov_update_commit has actually committed a new and different frequency wrt the one the kthread has just configured. It means we will have two async paths: 1. sugov_update_commit() which updates sg_policy->next_freq 2. sugov_work_update() which will run in a loop until the last freq it configures matches with the current value of sg_policy->next_freq But again, as we was discussing yesterday, we can have these additional bits in a following patch on top of your. -- #include Patrick Bellasi