Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964999AbVIUVcb (ORCPT ); Wed, 21 Sep 2005 17:32:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965008AbVIUVcb (ORCPT ); Wed, 21 Sep 2005 17:32:31 -0400 Received: from mf00.sitadelle.com ([212.94.174.67]:7739 "EHLO smtp.cegetel.net") by vger.kernel.org with ESMTP id S964968AbVIUVc3 (ORCPT ); Wed, 21 Sep 2005 17:32:29 -0400 Message-ID: <4331D168.6090604@cosmosbay.com> Date: Wed, 21 Sep 2005 23:32:24 +0200 From: Eric Dumazet User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: fr, en MIME-Version: 1.0 To: linux-kernel@vger.kernel.org, netfilter-devel@lists.netfilter.org, netdev@vger.kernel.org Cc: Andi Kleen Subject: [PATCH 2/3] netfilter : 3 patches to boost ip_tables performance References: <432EF0C5.5090908@cosmosbay.com> <200509191948.55333.ak@suse.de> <432FDAC5.3040801@cosmosbay.com> <200509201830.20689.ak@suse.de> <433082DE.3060308@cosmosbay.com> <43308324.70403@cosmosbay.com> In-Reply-To: <43308324.70403@cosmosbay.com> Content-Type: multipart/mixed; boundary="------------060702070101090202020705" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6337 Lines: 105 This is a multi-part message in MIME format. --------------060702070101090202020705 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Patch 2/3 (please apply after Patch 1/3) 2) Loop unrolling It seems that with current compilers and CFLAGS, the code from ip_packet_match() is very bad, using lot of mispredicted conditional branches I made some patches and generated code on i386 and x86_64 is much better. Signed-off-by: Eric Dumazet --------------060702070101090202020705 Content-Type: text/plain; name="patch_ip_tables_numa.2" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="patch_ip_tables_numa.2" LS0tIGxpbnV4LTIuNi9uZXQvaXB2NC9uZXRmaWx0ZXIvaXBfdGFibGVz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JCShjb25zdCB1bnNp Z25lZCBsb25nICopaXBpbmZvLT5vdXRpZmFjZV9tYXNrKTsKIAotCWlmIChGV0lOVihyZXQg IT0gMCwgSVBUX0lOVl9WSUFfT1VUKSkgeworCWJvb2wxID0gRldJTlYocmV0ICE9IDAsIElQ VF9JTlZfVklBX09VVCk7CisJaWYgKGJvb2wxKSB7CiAJCWRwcmludGYoIlZJQSBvdXQgbWlz bWF0Y2ggKCVzIHZzICVzKS4lc1xuIiwKIAkJCW91dGRldiwgaXBpbmZvLT5vdXRpZmFjZSwK IAkJCWlwaW5mby0+aW52ZmxhZ3MmSVBUX0lOVl9WSUFfT1VUID8iIChJTlYpIjoiIik7CkBA IC0xODUsOCArMjExLDkgQEAKIAl9CiAKIAkvKiBDaGVjayBzcGVjaWZpYyBwcm90b2NvbCAq LwotCWlmIChpcGluZm8tPnByb3RvCi0JICAgICYmIEZXSU5WKGlwLT5wcm90b2NvbCAhPSBp cGluZm8tPnByb3RvLCBJUFRfSU5WX1BST1RPKSkgeworCWJvb2wxID0gRldJTlYoaXAtPnBy b3RvY29sICE9IGlwaW5mby0+cHJvdG8sIElQVF9JTlZfUFJPVE8pIDsKKwlib29sMSAmPSAo aXBpbmZvLT5wcm90byAhPSAwKTsKKwlpZiAoYm9vbDEpIHsKIAkJZHByaW50ZigiUGFja2V0 IHByb3RvY29sICVoaSBkb2VzIG5vdCBtYXRjaCAlaGkuJXNcbiIsCiAJCQlpcC0+cHJvdG9j b2wsIGlwaW5mby0+cHJvdG8sCiAJCQlpcGluZm8tPmludmZsYWdzJklQVF9JTlZfUFJPVE8g PyAiIChJTlYpIjoiIik7Cg== --------------060702070101090202020705-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/