Received: by 10.192.165.148 with SMTP id m20csp5291126imm; Wed, 9 May 2018 02:33:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNfRvjXqa+0RW9FAR/C+X49yY+kwGkfiDfAB41K2W5MF2ottOZGQ/vITNymKWKwjvhTlsh X-Received: by 10.98.127.145 with SMTP id a139mr43368643pfd.25.1525858436228; Wed, 09 May 2018 02:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525858436; cv=none; d=google.com; s=arc-20160816; b=ibFkINiq/4bWazZKotZj8PTSyT/c28HwOnR+bs2lXHlzv7rD6geZQlUlP7he3VhUH9 ENmD7kYl30Pu/TdyydMZuTprFLbd+AbPookBSXtyaMmiIew2Tfuq9POivI+bq7VtVqvE spUys+KmOlgjZyRFugVbjJn+2OEoDx2AYClGLWtIoS+1IFP0e0f6SUcd7AIkPUrv11do q0VJh3kZgVL8XYkESyHAbBBc5lAMGPRjvZbIoxPPb1k99ZQWXdx97RG1hVaNyhjrIfcU OJMk9KYmeuQtD0exjjNq4t2gzzAH0hes7mZtbYLHnpAi6eOWuKCXLDh7J/OofpHDZbSv 7NbQ== 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=ms3tLTjjYBl1Wg+jpBjyhbZwVAyo10a6hIMKe06ir40=; b=nicjkRqH+om/Mwcm0WdwIIRw5Z2Dfw/ywG+lcn4MAPExR3JR15JWmsBSrRHhyHhVfC +l1VKzsjN+jJBsbCsJQbyHJuEaaJ76aMdAwXCbtS4IU9WLXPJ1R6ay6o3Rqw5e6MHmj4 87w7vF0+d1E5/HyAbDg9SDGf2fZoxcjNZSa1R1a6f4GHqBwZchq4/0926M+ERS/+iWQH 2QQcKU+LlKxH+RTXFCLxcO7kNw1KjhdsaQ2mj4Sb12OZIX1sRfDSKpE4XKdko3F5UO8/ J5fjU/rRs55wt4Yo0ngRvc2ttP6D/PyyFp3f5Rdv70KVqde6vRmqzd/Yghdw1n4fXVyD uXNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KzY7e2Uh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4-v6si3888722plr.373.2018.05.09.02.33.35; Wed, 09 May 2018 02:33:56 -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=@linaro.org header.s=google header.b=KzY7e2Uh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934596AbeEIJ2c (ORCPT + 99 others); Wed, 9 May 2018 05:28:32 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:37359 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934275AbeEIJ20 (ORCPT ); Wed, 9 May 2018 05:28:26 -0400 Received: by mail-pg0-f68.google.com with SMTP id a13-v6so22416451pgu.4 for ; Wed, 09 May 2018 02:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ms3tLTjjYBl1Wg+jpBjyhbZwVAyo10a6hIMKe06ir40=; b=KzY7e2UhobmGZywqITVENlukF62DaPsTlKJ2Xy7BQh6UtN0fOAQ/LcIhWlAHgdcUnB mXjBOOaphoo533kraxtaSXkfYb+ThYpJ+T7Dp9VmMHI/sV/BOBZoTOaMR0TbMbSpfrMU 3WDVxUzU8Iu3lgUicpIgTXuBkZCIqp1Vi01u0= 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=ms3tLTjjYBl1Wg+jpBjyhbZwVAyo10a6hIMKe06ir40=; b=jjdUqvdQ8OYSTXqI+fThg+PYbsE8EZW4vKhrJPfd4f027r++yxVdKDHu61ZkD18Vxe NG06oCdA+gaICzvzwLOROO+LywUWAPNtB6S1U+y1Z17Pk6Ck3fJ6LI9myuFSK3rG7KKk wTZObIhR8EXdGl3U7j8U6P0kMXOQa2UaGRhnQ0v8DuRN715bAUsTIPqtmJKolW/tXmyO 5pWBAPxI/1wRPtCBqs6X2du/UaynmFeRYH+94Hayjcoy47XHux/RHz+bV8jIw4Z6RZe6 X9/Tj0A9/topxLLEyS8xonUMkcoyLbLjdDoLNGV8OfTHIuYQvtJ/flUGzfD7RcGcY1md nAcw== X-Gm-Message-State: ALKqPwdYBoHXuGR+Vizwx0G12wEIebvzeIhpebceuR9km0oBNaPf37ms 0KdGu26L7/koN/7u6PIrOMggFQ== X-Received: by 2002:a63:ac43:: with SMTP id z3-v6mr404137pgn.291.1525858105457; Wed, 09 May 2018 02:28:25 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id o70sm15628743pfo.49.2018.05.09.02.28.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 02:28:24 -0700 (PDT) Date: Wed, 9 May 2018 14:58:23 +0530 From: Viresh Kumar To: Joel Fernandes Cc: "Rafael J. Wysocki" , Juri Lelli , Claudio Scordino , Linux Kernel Mailing List , "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Luca Abeni , Joel Fernandes , Linux PM Subject: Re: [RFC PATCH] sched/cpufreq/schedutil: handling urgent frequency requests Message-ID: <20180509092823.sfph4gomnblb7jgr@vireshk-i7> 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> <20180509080644.GA76874@joelaf.mtv.corp.google.com> <20180509084001.bghnwpv3a3xnuxce@vireshk-i7> <20180509090259.GD76874@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509090259.GD76874@joelaf.mtv.corp.google.com> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09-05-18, 02:02, Joel Fernandes wrote: > On Wed, May 09, 2018 at 02:10:01PM +0530, Viresh Kumar wrote: > > Right, none of the above changes are required now. > > I didn't follow what you mean the changes are not required? I was developing > against Linus mainline. Also I replied to Rafael's comment in the other > thread. At least for the shared policy case the entire sequence of sugov_should_update_freq() followed by sugov_update_commit() is executed from within spinlock protected region and you are using the same lock below. And so either the above two routines or the kthread routine below will execute at a given point of time. So in case kthread has started doing the update and acquired the lock, the util update handler will wait until the time work_in_progress is set to false, that's not a problem we are trying to solve here. And if kthread hasn't acquired the lock yet and util handler has started executing sugov_should_update_freq() .... And ^^^ this is where I understood that your earlier change is actually required, so that we accumulate the latest updated next_freq value. And with all that we wouldn't require a while loop in the kthread code. > > > > @@ -381,13 +381,23 @@ 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; > > > > + > > > > + /* > > > > + * Hold sg_policy->update_lock just enough to handle the case where: > > > > + * if sg_policy->next_freq is updated before work_in_progress is set to > > > > + * false, we may miss queueing the new update request since > > > > + * work_in_progress would appear to be true. > > > > + */ > > > > + raw_spin_lock(&sg_policy->update_lock); > > > > + freq = sg_policy->next_freq; > > > > + sg_policy->work_in_progress = false; > > > > + raw_spin_unlock(&sg_policy->update_lock); > > > > One problem we still have is that sg_policy->update_lock is only used > > in the shared policy case and not in the single CPU per policy case, > > so the race isn't solved there yet. > > True.. I can make the single CPU case acquire the update_lock very briefly > around sugov_update_commit call in sugov_update_single. Rafael was very clear from the beginning that he wouldn't allow a spin lock in the un-shared policy case :) -- viresh