From patchwork Sat Dec 7 00:40:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 3304301 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6EF4B9F37A for ; Sat, 7 Dec 2013 00:42:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2F8F2042B for ; Sat, 7 Dec 2013 00:42:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C169D2042A for ; Sat, 7 Dec 2013 00:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161062Ab3LGAl2 (ORCPT ); Fri, 6 Dec 2013 19:41:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57331 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758332Ab3LGAl0 (ORCPT ); Fri, 6 Dec 2013 19:41:26 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB70fCux009459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 6 Dec 2013 19:41:12 -0500 Received: from potion.localdomain (ovpn-116-19.ams2.redhat.com [10.36.116.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB70fBkU012850; Fri, 6 Dec 2013 19:41:12 -0500 Received: by potion.localdomain (Postfix, from userid 1000) id 2060D46385C4; Sat, 7 Dec 2013 01:41:09 +0100 (CET) From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, linux-arch@vger.kernel.org, rostedt@goodmis.org, pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, arnd@arndb.de, rusty@rustcorp.com.au, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH v2 5/5] static_key: improve deferred inc behavior Date: Sat, 7 Dec 2013 01:40:06 +0100 Message-Id: <1386376806-924-6-git-send-email-rkrcmar@redhat.com> In-Reply-To: <1386376806-924-1-git-send-email-rkrcmar@redhat.com> References: <1386376806-924-1-git-send-email-rkrcmar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We can cancel deferred static_key_slow_dec() instead of increasing .enabled.counter. Timer now won't fire before 'timeout' since the last increase, so this patch further stabilizes the case of frequent switching. Signed-off-by: Radim Kr?má? --- kernel/jump_label.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index bd7ad31..9b57261 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -79,7 +79,8 @@ void static_key_slow_inc_deferred(struct static_key_deferred *key) STATIC_KEY_CHECK_USE(); if (atomic_dec_if_positive(&key->enabled_debt) >= 0) return; - static_key_slow_inc(&key->key); + if (!cancel_delayed_work(&key->work)) + static_key_slow_inc(&key->key); } EXPORT_SYMBOL_GPL(static_key_slow_inc_deferred);