From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751944AbdHAQpY (ORCPT ); Tue, 1 Aug 2017 12:45:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35818 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdHAQpX (ORCPT ); Tue, 1 Aug 2017 12:45:23 -0400 Date: Tue, 1 Aug 2017 18:45:20 +0200 From: Peter Zijlstra To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] jump_labels: fix concurrent static_key_enable/disable() Message-ID: <20170801164520.5a56wrieijlwgyds@hirez.programming.kicks-ass.net> References: <1501601046-35683-1-git-send-email-pbonzini@redhat.com> <1501601046-35683-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1501601046-35683-2-git-send-email-pbonzini@redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for doing these patches, I hadn't come around to them yet. On Tue, Aug 01, 2017 at 05:24:04PM +0200, Paolo Bonzini wrote: > > +void static_key_enable(struct static_key *key) > +{ > + STATIC_KEY_CHECK_USE(); > + if (atomic_read(&key->enabled) > 0) { > + WARN_ON_ONCE(atomic_read(&key->enabled) != 1); > + return; > + } > + > + cpus_read_lock(); > + jump_label_lock(); > + if (atomic_read(&key->enabled) == 0) { > + atomic_set(&key->enabled, -1); > + jump_label_update(key); As per the previous discussion, should I do a patch adding barriers here (or using atomic_set_release()) such that we close the window where a concurrent inc/enable sees 1 but not all text changes? > + atomic_set(&key->enabled, 1); > + } > + jump_label_unlock(); > + cpus_read_unlock(); > +} > +EXPORT_SYMBOL_GPL(static_key_enable);