Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp133055imm; Tue, 22 May 2018 15:29:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQ4c+bcP0hKD9z+8kAwELeItgH5eRR867FHeFycQBNd2RTe6gFqyg5/mq8Q5dCg+1QVrsx X-Received: by 2002:a17:902:76c3:: with SMTP id j3-v6mr300915plt.15.1527028151636; Tue, 22 May 2018 15:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527028151; cv=none; d=google.com; s=arc-20160816; b=PiratZGBfjypoDzryHv8wb9lH1fqK3fRy/ew+AyzSLJI5NlzXcGZYVFh0srnb3/pI2 aDbvFihgxGNO1nVtHMaW9VBi2z8r5vqn5Pj538PLvyzQ6T8QuqLWmm/Elm7JDoKDlyUH JSLJPEgPN5wyb0erBn1SDn7Ovy1u5fHCfs/gavqSBQ0XaqomhxVdYih1X9EAopmLtoIM o5EzGzUtLvkVz936PzETn+3bDaVkYs/8qZjp+euwKFld38xwmG2UD/+yEU9R23teWlRB u04Kx1XLh/KwU64yN85xI6+EjhfOMyj0RGl5r6jQgyjd7mydjqZ8AVc5LHliruhOiwkv 93fQ== 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=yLMhxHegt7cJHjVUN8z2FN6KtXaiJ/U0lx2HLjSPBy0=; b=GxU0JHn0pcqObhXAmms/BWPHJRvY8s7m75efMgpqIN6y1nRuo4Gf8FaMQAIiBY2PEF yEBQPAhfslFoSIMAlaX9tDfmRBvwSDI5wZWif3gLRugOf3JfzpxRGXUiDTOaxuY58n7i DlzxRG/SI14ZRknC4QXR9PCc9xT+CG+87yFMaaxKHVBj1W2ydYtLjn7DfyKwHfBU6Yx0 43ijxXfsMcYlHEUWSMC2ly3U0rjU6cc2da7AdP/AA1bTJ9Lsxug1hjJkx8/JoY6zuY/j nNAuawJOsigCFq8cY/D8wTEFrHE+AvAT6vWSlLs1Act8HLBAB2MsYg6Nn3tr5Vl1oMWY xJlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=isuqo3dc; 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 s14-v6si17041881plp.589.2018.05.22.15.28.57; Tue, 22 May 2018 15:29:11 -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=isuqo3dc; 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 S1753458AbeEVW2m (ORCPT + 99 others); Tue, 22 May 2018 18:28:42 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39536 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753406AbeEVW2j (ORCPT ); Tue, 22 May 2018 18:28:39 -0400 Received: by mail-pl0-f66.google.com with SMTP id c19-v6so11735231pls.6 for ; Tue, 22 May 2018 15:28:39 -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=yLMhxHegt7cJHjVUN8z2FN6KtXaiJ/U0lx2HLjSPBy0=; b=isuqo3dc4i2wOWSE32dBx0bf1gautolTeOY4PEv/FXYebAQ0JeCkm3yOu+NLLv61bQ +jyz3OeCnuA2eyrMoNOkZvwvuYNLHz2IEdw/4z6Gs+pPg1l8dzusTU8Oo/z3LTTtpoPJ 3LHUzaXB7i30XoVluwkd4kHMMrt64Jvr+ntVg= 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=yLMhxHegt7cJHjVUN8z2FN6KtXaiJ/U0lx2HLjSPBy0=; b=bmkjwEac7UmpHAzk9Ocsh+ZQ4Br0jJrXBDxRUKiCkexqRX4ixhAmzLPAmrEUM4+00+ AYZu1F12iUgO2G9t99mvGbYUC1ZwhKucJwBrgM3zbeX0/QOv7SZ63B1Fivi9I/cuZ+4j l477IAWgio4PZz/KPNUSe8iDnvuhMmynk81+ZVStifz6n5iQ6KqurNr9EFoC/oJS6hDB JOv1zfTvift2QvGT8qJTaeF1pjFajERDrt1WgooOR2jPCU2WG3rSPnYJyw7P2Q3ur+kL 570svSSD+xiHh4AnjadNe52ee5ObCMOJSOmH4j/JLiIdpIxC5XGXTviZXkpMEiNbXu/f TY1Q== X-Gm-Message-State: ALKqPwfjerOjBNMgvNk+Wp3Ln/68LVemW7O5bvZtqo7YcOfbLwqNB6na WabH5rLeCMdZnOoKztL5bhXCxw== X-Received: by 2002:a17:902:d916:: with SMTP id c22-v6mr224089plz.293.1527028119323; Tue, 22 May 2018 15:28:39 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id s1-v6sm26064387pgr.66.2018.05.22.15.28.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 May 2018 15:28:38 -0700 (PDT) Date: Tue, 22 May 2018 15:28:37 -0700 From: Joel Fernandes To: "Rafael J. Wysocki" Cc: Viresh Kumar , Linux Kernel Mailing List , "Rafael J . Wysocki" , Peter Zijlstra , Ingo Molnar , Patrick Bellasi , Juri Lelli , Luca Abeni , Todd Kjos , Claudio Scordino , kernel-team@android.com, Linux PM , "Joel Fernandes (Google.)" Subject: Re: [PATCH v2] schedutil: Allow cpufreq requests to be made even when kthread kicked Message-ID: <20180522222837.GA55359@joelaf.mtv.corp.google.com> References: <20180518185501.173552-1-joel@joelfernandes.org> <20180522113844.5rz3skjeck57arft@vireshk-i7> <4237890.zlzv5C60QP@aspire.rjw.lan> <20180522213113.GA40506@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, May 22, 2018 at 11:52:46PM +0200, Rafael J. Wysocki wrote: > On Tue, May 22, 2018 at 11:41 PM, Joel Fernandes wrote: > > On Tue, May 22, 2018 at 05:27:11PM +0200, Rafael J. Wysocki wrote: > >> On Tue, May 22, 2018 at 2:22 PM, Rafael J. Wysocki wrote: > >> > On Tuesday, May 22, 2018 1:42:05 PM CEST Rafael J. Wysocki wrote: > >> >> On Tue, May 22, 2018 at 1:38 PM, Viresh Kumar wrote: > >> >> > On 22-05-18, 13:31, Rafael J. Wysocki wrote: > >> >> >> So below is my (compiled-only) version of the $subject patch, obviously based > >> >> >> on the Joel's work. > >> >> >> > >> >> >> Roughly, what it does is to move the fast_switch_enabled path entirely to > >> >> >> sugov_update_single() and take the spinlock around sugov_update_commit() > >> >> >> in the one-CPU case too. > >> > > >> > [cut] > >> > > >> >> > > >> >> > Why do you assume that fast switch isn't possible in shared policy > >> >> > cases ? It infact is already enabled for few drivers. > >> > > >> > I hope that fast_switch is not used with devfs_possible_from_any_cpu set in the > >> > one-CPU policy case, as that looks racy even without any patching. > >> > >> Which would be the only case in which sugov_update_single() would run > >> on a CPU that is not the target. > >> > >> And running sugov_update_single() concurrently on two different CPUs > >> for the same target is a no-no, as we don't prevent concurrent updates > >> from occurring in that path. > >> > >> Which means that the original patch from Joel will be sufficient as > >> long as we ensure that sugov_update_single() can only run on one CPU > >> at a time. > > > > Since target CPU's runqueue lock is held, I don't see how we can run > > sugov_update_single concurrently with any other CPU for single policy, so > > protecting such race shouldn't be necessary. > > If dvfs_possible_from_any_cpu is set, any CPU can run > sugov_update_single(), but the kthread will only run on the target > itself. So another CPU running sugov_update_single() for the target > may be racing with the target's kthread. > Yes, I agree. I thought you meant the case of sugov_update_single running currently with other sugov_update_single. So just to be on the same page, I'll fix the commit log and repost this one as is. And then I'll post the smp_rmb() patch separately to address the memory order issue (which I believe is in mainline as well). Basically I was thinking to address Viresh's issue, there should be an smp_mb() after the next_freq is read, but before the write to work_in_progress. thanks, - Joel