Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp20665ybt; Tue, 30 Jun 2020 13:58:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGBcCXojxAXCLo013Ax2AZ8rFEvsjqbgoApswP3dlsndmrog4Er10vRZBs7TqrYAzxdfN3 X-Received: by 2002:a50:f058:: with SMTP id u24mr25277659edl.351.1593550349973; Tue, 30 Jun 2020 13:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593550349; cv=none; d=google.com; s=arc-20160816; b=DbTD18+Yx9rocI539NVWKVe2mfVyX0qciz3kOB4RvW6JTc/AtOdW+xufWPDwzePxYI asYeGbWYXNx1Bm8cVbO8YnaEgDNqCZquuQ1kSav94HSNXMoR4JJXRAaTjzfObDqquxQ2 RsOLcA9BT4SCvKSXPOmdjLLpDCBlzdEfn1JUtV5JYItSNT1p7jkf5iXi+yMvK41o6eiF bSb/XVpYaEwhP5jxo/E8/DvAEH43iMJ5/HZEpqkgkV6S4xZPdVQ21QCGE2GpxzGnRZ6v yXwCE0y+0opon8Gi2J9VZXiuei9jOj3Fd7hGm53ePHhPRZkdz+H5Gl6H8CEFqFzwD46G 8p0A== 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; bh=UdfDix8ocUJVJJEg57ehql0DPyFQgTwOkYvbyPaosF4=; b=CtDMtNSInjhGd/pyv2kpt+vS8s8lkP1B/1D6taxhGpmwl0wH7gtUbUW8ysOxXAIDzS FOjFEBIs+TNwV9b4F3Esk1ccd/JBY/7IxeLAT6vFJb/U7goIqEWs28rrkuT2atqNB5kP Qb3qh3U0bt08RbdVMqfJ5mxnsw10cAVQ0Z79fmOYMEGoT75rdVNGVV3httDoasFgNS5N Me+RfvPbyeMluQ9T5HM7z8bEYSdJA1KNHs7SvnMz3zX8Co+Ll/TQIzn3zLRC84qo1IAr thvPgsNftLr5mwSTbb73LM4VI3S6q4SFAtQ2V1gh3Rmv6ngL2V1Q8zO11J101jymWL2H ecXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si2795141edn.92.2020.06.30.13.52.07; Tue, 30 Jun 2020 13:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgF3T21 (ORCPT + 99 others); Tue, 30 Jun 2020 15:28:27 -0400 Received: from foss.arm.com ([217.140.110.172]:59204 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbgF3T21 (ORCPT ); Tue, 30 Jun 2020 15:28:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4231231B; Tue, 30 Jun 2020 12:28:26 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 943703F68F; Tue, 30 Jun 2020 12:28:24 -0700 (PDT) Date: Tue, 30 Jun 2020 20:28:22 +0100 From: Qais Yousef To: Peter Zijlstra Cc: Ingo Molnar , Valentin Schneider , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Patrick Bellasi , Chris Redpath , Lukasz Luba , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/2] sched/uclamp: Protect uclamp fast path code with static key Message-ID: <20200630192821.xzg53b3mx7hvjmr4@e107158-lin.cambridge.arm.com> References: <20200630112123.12076-1-qais.yousef@arm.com> <20200630112123.12076-3-qais.yousef@arm.com> <20200630170751.GA4817@hirez.programming.kicks-ass.net> <20200630175502.otw4seymlynghje7@e107158-lin.cambridge.arm.com> <20200630190643.GC4817@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200630190643.GC4817@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/30/20 21:06, Peter Zijlstra wrote: > On Tue, Jun 30, 2020 at 06:55:02PM +0100, Qais Yousef wrote: > > On 06/30/20 19:07, Peter Zijlstra wrote: > > > > There's a fun race described in 9107c89e269d ("perf: Fix race between > > > event install and jump_labels"), are we sure this isn't also susceptible > > > to something similar? > > > > > > I suspect not, but I just wanted to make sure. > > > > IIUC, the worry is that not all CPUs might have observed the change in the > > static key state; hence could not be running the patched > > enqueue/dequeue_task(), so we could end up with some CPUs accounting for > > uclamp in the enqueue/dequeue path but not others? > > > > I was hoping this synchronization is guaranteed by the static_branch_*() call. > > It is, that isn't quite the the problem. Looking at it more I think > commit 1dbb6704de91 ("jump_label: Fix concurrent > static_key_enable/disable()") fixed some of it. > > From what I can remember there were two parts to this problem, one being > fixed by the above commit, the other being that if we enable while a > task is running we miss the switch-in event (exactly how in this patch > we miss the enqueue). > > Due to the missing switch-in, the state is 'weird' and the subsequent > IPI to install a remote event didn't quite work. > > So I put that sync_sched() call in to guarantee all CPUs have done a > schedule() cycle after having the key switched. This makes sure that > every running task has seen the switch-in and thus the state is as > expected. > > But like I said, I think we're good, that one extra branch deals with > the half-state. Got it, thanks. Yes, we should be good for currently running tasks. Thanks -- Qais Yousef