From patchwork Mon Oct 9 21:30:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 823532 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VaA2L9Xe"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y9tmM657Sz9t5Q for ; Tue, 10 Oct 2017 08:34:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754506AbdJIVd6 (ORCPT ); Mon, 9 Oct 2017 17:33:58 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38901 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbdJIVd5 (ORCPT ); Mon, 9 Oct 2017 17:33:57 -0400 Received: by mail-pf0-f196.google.com with SMTP id a7so30591867pfj.5; Mon, 09 Oct 2017 14:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=sHZW9RjDDsyk3GbW+8+JMrW6RRS8LvySngx5hOw6+Oo=; b=VaA2L9XeS1Ibt8q9JCNmtWcspY4eFMA3V1AfcW7gS5Kb4Ium9dWPjE+CdBMvsfHX5v FecrguwDrPc8hwhz5ww9Jzs4fnvm9GWZL5Yo2UZJ3n1jjjhrE/T/b7NWvmRx7t2sEuOq DY2VyNqjQWaRn/H3Lbl+Bth9OvvhDGjKqC5v2VwQeDHLs+b7LeyZhY9w1CVZ0loRcuyB DlheLBr/XazwlvrI76rOCndACNYiEkLP/wwaJD5fUkmcoeozQdADkjfJvmxgC0jXR+8X kA459zKcwvr9ADlUP7ZtkN/XVP0C0+P+Gf2pn+JbrdojmFWhsjIsgKnxr47Wq8r1JEN6 r2DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sHZW9RjDDsyk3GbW+8+JMrW6RRS8LvySngx5hOw6+Oo=; b=otTLcSTLA2LHx5xK6spcCqGzBmXBENRUMJJYizgBhfL0w1mGCZ6h+b1FMYoZiqOQqV eatwxsK77DXk3As6zDl11w8Dyg2//7aDnbHHplH5w7v52VpVxe5KCFSKt215y9dfNNz7 7njDC2TgnV9W0zAIGZfDaYafPDuBQErJm6IsDb+KRHc4M5bpnZxv8h4A2tF2f+h1iAat 8GgG9FiNcYErzBJuKLIpf2FslNDkKN9RNcG+s4kySn4swWXbWVq9hF8cZijCFV+WTaBL UccCGiocrsDuNTIv7D3jSf5S4mza8xmsBT7giJGn3j+XQ6KdS/qZZ9cQPqzJfxQ49ML3 ARZQ== X-Gm-Message-State: AMCzsaU00PTr4drXcOqnOHi1OMZPYe6ZJF+7h7h5bPLOu32UggpjiNp7 F7u17pFz76SAFmTpPE8NvbaKuvZ/grc= X-Google-Smtp-Source: AOwi7QBoC1vZ/Lw4KAyZ7PK9m655JWoTVwK2ZTW+e829DpkW8memtFpR+oGf9bHYALk2Linl5kkhQg== X-Received: by 10.84.217.206 with SMTP id d14mr10050418plj.62.1507584836328; Mon, 09 Oct 2017 14:33:56 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id x11sm14925470pgq.29.2017.10.09.14.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 14:33:55 -0700 (PDT) From: Eric Biggers To: netdev@vger.kernel.org Cc: "David S . Miller" , linux-kernel@vger.kernel.org, Hannes Frederic Sowa , Jason Baron , Peter Zijlstra , Eric Biggers Subject: [PATCH net-next] once: switch to new jump label API Date: Mon, 9 Oct 2017 14:30:52 -0700 Message-Id: <20171009213052.97771-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.14.2.920.gcf0c67979c-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Biggers Switch the DO_ONCE() macro from the deprecated jump label API to the new one. The new one is more readable, and for DO_ONCE() it also makes the generated code more icache-friendly: now the one-time initialization code is placed out-of-line at the jump target, rather than at the inline fallthrough case. Acked-by: Hannes Frederic Sowa Signed-off-by: Eric Biggers --- include/linux/once.h | 6 +++--- lib/once.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/once.h b/include/linux/once.h index 9c98aaa87cbc..724724918e8b 100644 --- a/include/linux/once.h +++ b/include/linux/once.h @@ -5,7 +5,7 @@ #include bool __do_once_start(bool *done, unsigned long *flags); -void __do_once_done(bool *done, struct static_key *once_key, +void __do_once_done(bool *done, struct static_key_true *once_key, unsigned long *flags); /* Call a function exactly once. The idea of DO_ONCE() is to perform @@ -38,8 +38,8 @@ void __do_once_done(bool *done, struct static_key *once_key, ({ \ bool ___ret = false; \ static bool ___done = false; \ - static struct static_key ___once_key = STATIC_KEY_INIT_TRUE; \ - if (static_key_true(&___once_key)) { \ + static DEFINE_STATIC_KEY_TRUE(___once_key); \ + if (static_branch_unlikely(&___once_key)) { \ unsigned long ___flags; \ ___ret = __do_once_start(&___done, &___flags); \ if (unlikely(___ret)) { \ diff --git a/lib/once.c b/lib/once.c index 05c8604627eb..831c5a6b0bb2 100644 --- a/lib/once.c +++ b/lib/once.c @@ -5,7 +5,7 @@ struct once_work { struct work_struct work; - struct static_key *key; + struct static_key_true *key; }; static void once_deferred(struct work_struct *w) @@ -14,11 +14,11 @@ static void once_deferred(struct work_struct *w) work = container_of(w, struct once_work, work); BUG_ON(!static_key_enabled(work->key)); - static_key_slow_dec(work->key); + static_branch_disable(work->key); kfree(work); } -static void once_disable_jump(struct static_key *key) +static void once_disable_jump(struct static_key_true *key) { struct once_work *w; @@ -51,7 +51,7 @@ bool __do_once_start(bool *done, unsigned long *flags) } EXPORT_SYMBOL(__do_once_start); -void __do_once_done(bool *done, struct static_key *once_key, +void __do_once_done(bool *done, struct static_key_true *once_key, unsigned long *flags) __releases(once_lock) {