Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp589297ybm; Wed, 22 May 2019 08:17:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDPubSHqblYYUTXOMhkbar4o09mz14aCzr104Izxan6EKPD1UwUXR8yGqYWTBJpOMwjSv7 X-Received: by 2002:a62:4281:: with SMTP id h1mr97155105pfd.162.1558538226210; Wed, 22 May 2019 08:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558538226; cv=none; d=google.com; s=arc-20160816; b=Kjr6aEDkc50r1qtcW6y+ifYRz82o7stNjazQHU+3PyReYzqfdac4wLV5NekOP3/sCs GVpRBun3tlnBATWla/EI1Gkr6wtrUQAA3eMGa/wysQ9QsILXL0EqLOkRMvuE4g92VWhT oclUZk4haJdpfvt6qOZCQ7DCl6EUszakiIVFqe2LYDNU6iM/syboGhyVmcCoXcLCup0y imzbLWSSzS8eZsJyYvLtEVWUg1xZOprXv64gfl/6MJa/iUafFETq1g7sjJ3SdQN2jZqO PRxyBE9WZi5xXOu+cCVh44s/hqxjU4f/CQ3Q2UxvglofDoq0S5puUCWeImf6ml4YfnTb dflQ== 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=qnmpGU5gl7idWNHF6+aZnk1ZcZ+Tl7yhVQM5D+ION2Y=; b=Cx2J36j/q2pq+TOFxGQ5OdSJatR/F5A6nfFLEqDAnx+9Eo3KvkDAdC98oHidXW2r64 pEZZt0/GO9EixvcHDuqApUKKHThKpeGT6OhhMS3Nfb0iSEZA2N380vipKJRToBQJppTC IkHdOZuMXFmTG+OaGry5RYvOMMJvbHEUxW/hx41SqjqxJpzYPLc88U3A83Pgk5lxaipM CPoulSDBxNIv5/pekoc12DwVeorB0HeUtUQGL5e08cNNIXmzTssW4em0Y7Eef7Efqx/O QYGa2sOK2OltD1ILPnoqtHEhIIino6Wo/xykFbqZZJ1PEK4B0q8DuJixhUN2fdHE+5Oz Getw== 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 u9si27837518pgq.44.2019.05.22.08.16.50; Wed, 22 May 2019 08:17:06 -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 S1729828AbfEVPO0 (ORCPT + 99 others); Wed, 22 May 2019 11:14:26 -0400 Received: from foss.arm.com ([217.140.101.70]:53466 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729658AbfEVPO0 (ORCPT ); Wed, 22 May 2019 11:14:26 -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 8CBA880D; Wed, 22 May 2019 08:14:25 -0700 (PDT) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 24ED33F718; Wed, 22 May 2019 08:14:24 -0700 (PDT) Date: Wed, 22 May 2019 16:14:23 +0100 From: Andrew Murray To: Peter Zijlstra Cc: Thomas Gleixner , Rik van Riel , linux-kernel@vger.kernel.org Subject: Re: [PATCH] smp,cpumask: Don't call functions on offline CPUs Message-ID: <20190522151422.GD8268@e119886-lin.cambridge.arm.com> References: <20190522111537.27815-1-andrew.murray@arm.com> <20190522140921.GD16275@worktop.programming.kicks-ass.net> <20190522143711.GC8268@e119886-lin.cambridge.arm.com> <20190522144918.GH16275@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190522144918.GH16275@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2019 at 04:49:18PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2019 at 03:37:11PM +0100, Andrew Murray wrote: > > > Is perhaps the problem that on_each_cpu_cond() uses cpu_onlne_mask > > > without protection? > > > > Does this prevent racing with a CPU going offline? I guess this prevents > > the warning at the expense of a lock - but is only beneficial in the > > unlikely path. (In the likely path this prevents new CPUs going offline > > but we don't care because we don't WARN if they aren't they when we > > attempt to call functions). > > > > At least this is my limited understanding. > > Hmm.. I don't think it could matter, we only use the mask when > preempt_disable(), which would already block offline, due to it using > stop_machine(). OK, so as long as all arches use stop_machine to bring down a CPU then preeempt_disable will stop racing with CPUs going offline (I don't know if they all do or not). > > So the patch is a no-op. > > What's the WARN you see? TLB invalidation should pass mm_cpumask(), > which similarly should not contain offline CPUs I'm thinking. So the only remaining issue is if callers pass offline CPUs to the function (I guess there is still the chance of a race between calling on_each_cpu_cond_mask and entering the preempt disabled'd bit). As you suggest they probably don't. Given the above, should we add a " @mask: The mask of cpus it can run on." to on_each_cpu_cond_mask? (Which is different to the wording of other functions in the same file that mask it with online CPUs, e.g. " @mask: The set of cpus to run on (only runs on online subset).". (I haven't seen any WARN, but from looking at the code thought that it was possible.) Thanks, Andrew Murray