Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1405759imm; Tue, 22 May 2018 03:39:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqWEqF76AWaMgW/TXIYAzTL+RjJdIrJCs/gfZdTCfnKZPKTm/eWWrMkxRc2DIkR3W046Yz2 X-Received: by 2002:a17:902:42e:: with SMTP id 43-v6mr24190876ple.365.1526985568074; Tue, 22 May 2018 03:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526985568; cv=none; d=google.com; s=arc-20160816; b=St4uphB9UhyoeDBJBos+yIRiqkQqONQMCAgv3m2wQZ79BbJnlxYXL7cuL8HuJwRcX0 X8Eq92JOItclIHBnnnR5611Rd226oqqiacntVUcJZwhtMTxmMNu2kbCVGDfIENagWx0s qdITEIb/swb8leFjL9faIiOKT9aogIDUP1USGqbJmtvVOMFdHBYUHh7yB5VliSAMjiL0 tzzD79YzmUFwMznhUDW87kk1aFqUo7oZSjAk1JDJmIUtTxCaQWUMF3kLeG5GcuykaowG 8BQfPouZcKT1XG0xVlS2jGKpFwadl7i9+zjygUFbE6buWf8WnYwxmKDeQru2zJP9/qOh mkcA== 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=nVOF8G7Ia9D7wwWhPGCPbUxyW5Iobgkp3JKHn0s+Ilw=; b=VxEnHJ79EuXHZQUOi82FWy1tphSv2cKN2DMxrHrUReUJzQYGo2aArYs46NCVRHQ0qV vg0UO8X/SW0HlymKYwTK1J20dxNymUITCyIQFO7qHxw5AwLIoYPd4cwFfqGlzfCeE4wD smbupC6ISPZnw3Im5CufXf4C3b2mt8r+T9exo9xG4pRd5XykFz4H7D1gTRKeikkSrdLh cJY+rtYCgz4yI6RNJiThOTpFFLkUzEg50htP9ijI5pnz2lHXBEaOxJSUOSCKEN/Vwy+e Dcg935xJEZSxgG+Bk4YrRqeNnkyX5qmU8EDN13zOuqlSzhE5b3l9OzGPt7vbo/Vg0jOY J8cA== 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 o4-v6si15637281plk.321.2018.05.22.03.39.12; Tue, 22 May 2018 03:39:28 -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 S1751275AbeEVKjA (ORCPT + 99 others); Tue, 22 May 2018 06:39:00 -0400 Received: from foss.arm.com ([217.140.101.70]:34618 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbeEVKi5 (ORCPT ); Tue, 22 May 2018 06:38:57 -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 E3ED91596; Tue, 22 May 2018 03:38:56 -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 989C13F24A; Tue, 22 May 2018 03:38:54 -0700 (PDT) Date: Tue, 22 May 2018 11:38:52 +0100 From: Patrick Bellasi To: Viresh Kumar Cc: Joel Fernandes , "Joel Fernandes (Google.)" , linux-kernel@vger.kernel.org, "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: <20180522103851.GW30654@e110439-lin> References: <20180518185501.173552-1-joel@joelfernandes.org> <20180521105055.GQ30654@e110439-lin> <20180521154957.GA14065@joelaf.mtv.corp.google.com> <20180521170050.GT30654@e110439-lin> <20180521172001.GA21678@joelaf.mtv.corp.google.com> <20180522102305.uxph4u4o2zrvu4tx@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180522102305.uxph4u4o2zrvu4tx@vireshk-i7> 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 Hi Viresh, thanks for clarifying... On 22-May 15:53, Viresh Kumar wrote: > On 21-05-18, 10:20, Joel Fernandes wrote: > > On Mon, May 21, 2018 at 06:00:50PM +0100, Patrick Bellasi wrote: > > > If that's the case, this means that if, for example, during a > > > frequency switch you get a request to reduce the frequency (e.g. > > > deadline task passing the 0-lag time) and right after a request to > > > increase the frequency (e.g. the current FAIR task tick)... you will > > > enqueue a freq drop followed by a freq increase and actually do two > > > frequency hops? > > I don't think so. > > Consider the kthread as running currently and has just cleared the > work_in_progress flag. Sched update comes at that time and we decide > to reduce the frequency, we queue another work and update next_freq. > Now if another sched update comes before the kthread finishes its > previous loop, we will simply update next_freq and return. So when the > next time kthread runs, it will pick the most recent update. Mmm... right... looking better at the two execution contexts: // A) Frequency update requests sugov_update_commit() { sg_policy->next_freq = next_freq; if (!sg_policy->work_in_progress) { sg_policy->work_in_progress = true; irq_work_queue(&sg_policy->irq_work); } } // B) Actual frequency updates sugov_work() { freq = sg_policy->next_freq; sg_policy->work_in_progress = false; __cpufreq_driver_target(sg_policy->policy, freq, CPUFREQ_RELATION_L); } It's true that A will enqueue only one B at the first next_freq update and then it will keep just updating the next_freq. Thus, we should be ensure to have always just one kwork pending in the queue. > Where is the problem both of you see ? Perhaps the confusion comes just from the naming of "work_in_progress", which is confusing since we use it now to represent that we enqueued a frequency change and we wait for the kwork to pick it up. Maybe it can help to rename it to something like kwork_queued or update_pending, update_queued... ? -- #include Patrick Bellasi