From patchwork Fri May 1 08:38:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 26749 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id CA7ABB7043 for ; Fri, 1 May 2009 18:38:35 +1000 (EST) Received: by ozlabs.org (Postfix) id BC5B2DDDF9; Fri, 1 May 2009 18:38:35 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 583D8DDDB2 for ; Fri, 1 May 2009 18:38:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbZEAIi1 (ORCPT ); Fri, 1 May 2009 04:38:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751839AbZEAIi0 (ORCPT ); Fri, 1 May 2009 04:38:26 -0400 Received: from gw1.cosmosbay.com ([212.99.114.194]:39622 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbZEAIiZ convert rfc822-to-8bit (ORCPT ); Fri, 1 May 2009 04:38:25 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by gw1.cosmosbay.com (8.13.7/8.13.7) with ESMTP id n418cL8m029185; Fri, 1 May 2009 10:38:21 +0200 Message-ID: <49FAB4FC.6040907@cosmosbay.com> Date: Fri, 01 May 2009 10:38:20 +0200 From: Eric Dumazet User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: David Miller CC: shemminger@vyatta.com, kaber@trash.net, netfilter-devel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] netfilter: use likely() in xt_info_rdlock_bh() References: <20090428092411.5331c4a1@nehalam> <20090428.223708.168741998.davem@davemloft.net> In-Reply-To: <20090428.223708.168741998.davem@davemloft.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [0.0.0.0]); Fri, 01 May 2009 10:38:22 +0200 (CEST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org David Miller a écrit : > From: Linus Torvalds > Date: Tue, 28 Apr 2009 09:55:32 -0700 (PDT) > >> On Tue, 28 Apr 2009, Linus Torvalds wrote: >>> Ack. >>> >>> It could do with the update from Eric about how non-current CPU writelocks >>> only require preemp-disable around get_counters() (and then the >>> local_bh_disable() only around the current-CPU case). >> Btw, regardless, that's an incremental improvement, and does not negate >> the "Ack" part. > > I've applied this, thanks everyone! Small followup on this one, since the likely() were forgotten. (I trimmed down CCed list, which was insane) It makes a difference on my x86_32 machine, gcc-4.4.0 Thank you [PATCH] netfilter: use likely() in xt_info_rdlock_bh() Signed-off-by: Eric Dumazet --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 1b2e435..c9efe03 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -472,7 +472,7 @@ static inline void xt_info_rdlock_bh(void) local_bh_disable(); lock = &__get_cpu_var(xt_info_locks); - if (!lock->readers++) + if (likely(!lock->readers++)) spin_lock(&lock->lock); } @@ -480,7 +480,7 @@ static inline void xt_info_rdunlock_bh(void) { struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks); - if (!--lock->readers) + if (likely(!--lock->readers)) spin_unlock(&lock->lock); local_bh_enable(); }