From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keir Fraser Subject: Re: Problems with spin_lock_irqsave() and for_each_online_cpu() Date: Fri, 18 Oct 2013 05:57:22 +0100 Message-ID: References: <52603BD1.40901@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52603BD1.40901@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , Xen-devel List , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org On 17/10/2013 20:34, "Andrew Cooper" wrote: > As for the spinlocks, while I as the programmer am fairly sure that > "&per_cpu(t_lock, i)" is unlikely to change, coverity takes into account > that updates to __per_cpu_offset[i] have no protection. Because of > RELOC_HIDE(), gcc can't hoist the per_cpu() calculation, but will run > from register cached values of per_cpu__t_lock and __per_cpu_offset[i], > so is guaranteed to find the same lock both times even if > __per_cpu_offset[i] changes. > > However, it occurs to me that there is no protection between > for_each_online_cpu() finding a bit set in the cpu_online_map and safely > using per_cpu() to poke at another cpus data. One solution seems to be > to make use of {get,put}_cpu_maps() but this seems overkill especially > as the innards of a for_each_online_cpu() loop only care about one > particular pcpu not disappearing under its feet. CPUs are taken offline in a stop_machine_run environment, *and* the __per_cpu_offset[i] change is done via RCU. We're safe here I'm sure. -- Keir