All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Iavor Stoev <iavor@icdsoft.com>,
	Netfilter Developer Mailing List
	<netfilter-devel@vger.kernel.org>
Subject: Re: [NETFILTER][PATCH] Re: Question about the hashlimit network mask patch
Date: Wed, 02 Apr 2008 11:52:51 +0200	[thread overview]
Message-ID: <47F35773.4080700@trash.net> (raw)
In-Reply-To: <alpine.LNX.1.10.0804011653460.13835@fbirervta.pbzchgretzou.qr>

Jan Engelhardt wrote:
> On Tuesday 2008-04-01 14:49, Patrick McHardy wrote:
> 
>> Jan Engelhardt wrote:
>>>  [NETFILTER]: xt_hashlimit: add workaround for >>32 case
>>>
>>>  Hardware surprisingly does nothing when a 32-bit right-shift is
>>>  to be done. Worse yet, compilers do not even work around it.
>>
>> Thats because the C standard states that the result is undefined.
>> Anyways, I think this patch is slightly nicer because it
>> gets rid of the double negation and the %32 == 0 special-casing
>> for IPv6.
>>
>> Do you want to add an ACKed-by?
> 
> 
> The special casing for %32==0 in the IPv6 block was not a workaround for 
> '>>32', but speed. 

I'm aware of that.

> Assuming the C code is already perfect and gets 
> transformed 1:1 into assembly without any further optimization, the cost 
> of the operation is 4 simple 'mov' instructions for %32==0, whereas 
> calling maskl() will involve a fair number of operations (at least 27 by 
> the count). [With your patch, maskl() is now 28 + a branch.]

The "optimization" results in bigger code and more branches itself.
Just removing it without fixing maskl reduces code size by over 35%:

net/netfilter/xt_hashlimit.c:
   hashlimit_ipv6_mask | -103 # 274 -> 171
  1 function changed, 103 bytes removed

Fixing maskl bloats it up again, but still a net win:

   hashlimit_ipv6_mask |   -9 # 274 -> 265, size inlines: 71 -> 148
   hashlimit_init_dst  |   +6 # 589 -> 595, size inlines: 86 -> 106
  2 functions changed, 6 bytes added, 9 bytes removed, diff: -3

Just the maskl fix results in:

net/netfilter/xt_hashlimit.c:
   hashlimit_ipv6_mask |  +95 # 274 -> 369, size inlines: 71 -> 143
   hashlimit_init_dst  |   +6 # 589 -> 595, size inlines: 86 -> 106
  2 functions changed, 101 bytes added

      reply	other threads:[~2008-04-02  9:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <47E39230.90400@icdsoft.com>
     [not found] ` <alpine.LNX.1.00.0803211404530.10642@fbirervta.pbzchgretzou.qr>
     [not found]   ` <47E3E861.9090707@icdsoft.com>
     [not found]     ` <alpine.LNX.1.00.0803211805340.10642@fbirervta.pbzchgretzou.qr>
     [not found]       ` <47E90678.7090405@icdsoft.com>
2008-03-26  7:44         ` [NETFILTER][PATCH] Re: Question about the hashlimit network mask patch Jan Engelhardt
2008-03-26  9:54           ` Niki Denev
2008-03-26 10:28           ` Michał Mirosław
2008-03-26 13:18             ` Jan Engelhardt
2008-04-01 12:49           ` Patrick McHardy
2008-04-01 15:32             ` Jan Engelhardt
2008-04-02  9:52               ` Patrick McHardy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47F35773.4080700@trash.net \
    --to=kaber@trash.net \
    --cc=iavor@icdsoft.com \
    --cc=jengelh@computergmbh.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.