From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751923AbdHAQqV (ORCPT ); Tue, 1 Aug 2017 12:46:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44316 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751655AbdHAQqU (ORCPT ); Tue, 1 Aug 2017 12:46:20 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C81AC113806 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH 1/3] jump_labels: fix concurrent static_key_enable/disable() To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org References: <1501601046-35683-1-git-send-email-pbonzini@redhat.com> <1501601046-35683-2-git-send-email-pbonzini@redhat.com> <20170801164520.5a56wrieijlwgyds@hirez.programming.kicks-ass.net> From: Paolo Bonzini Message-ID: Date: Tue, 1 Aug 2017 18:46:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170801164520.5a56wrieijlwgyds@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 01 Aug 2017 16:46:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/08/2017 18:45, Peter Zijlstra wrote: > > 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? Sure, and that applies to static_key_slow_inc as well. Paolo >> + atomic_set(&key->enabled, 1); >> + } >> + jump_label_unlock(); >> + cpus_read_unlock(); >> +} >> +EXPORT_SYMBOL_GPL(static_key_enable);