* [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address
@ 2012-10-10 18:42 Joe Perches
2012-10-10 18:59 ` Brian Haley
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Joe Perches @ 2012-10-10 18:42 UTC (permalink / raw)
To: netdev; +Cc: LKML
Reduces object size and should be slightly faster.
allyesconfig:
$ size net/core/pktgen.o*
text data bss dec hex filename
52251 4293 11824 68368 10b10 net/core/pktgen.o.new
52310 4293 11848 68451 10b63 net/core/pktgen.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
Found by looking for if (foo) ; tests with a perl regex
Yes Eric, it could be 2 compares instead of 4 on 64-bit
systems with HAS_EFFICIENT_UNALIGNED_ACCESS. Maybe later
or if there are other tests that could become something
like ipv6_is_zeronet.
cheers, Joe
net/core/pktgen.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 148e73d..3aa8417 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2422,11 +2422,10 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
}
} else { /* IPV6 * */
- if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[1] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[2] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[3] == 0) ;
- else {
+ if (pkt_dev->min_in6_daddr.s6_addr32[0] |
+ pkt_dev->min_in6_daddr.s6_addr32[1] |
+ pkt_dev->min_in6_daddr.s6_addr32[2] |
+ pkt_dev->min_in6_daddr.s6_addr32[3]) {
int i;
/* Only random destinations yet */
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 18:42 [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address Joe Perches
@ 2012-10-10 18:59 ` Brian Haley
2012-10-10 19:01 ` Eric Dumazet
2012-10-11 8:08 ` [PATCH net-next?] " David Laight
2 siblings, 0 replies; 11+ messages in thread
From: Brian Haley @ 2012-10-10 18:59 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, LKML
On 10/10/2012 02:42 PM, Joe Perches wrote:
> Found by looking for if (foo) ; tests with a perl regex
>
> Yes Eric, it could be 2 compares instead of 4 on 64-bit
> systems with HAS_EFFICIENT_UNALIGNED_ACCESS. Maybe later
> or if there are other tests that could become something
> like ipv6_is_zeronet.
>
> cheers, Joe
>
> net/core/pktgen.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 148e73d..3aa8417 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -2422,11 +2422,10 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
> }
> } else { /* IPV6 * */
>
> - if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[1] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[2] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[3] == 0) ;
> - else {
> + if (pkt_dev->min_in6_daddr.s6_addr32[0] |
> + pkt_dev->min_in6_daddr.s6_addr32[1] |
> + pkt_dev->min_in6_daddr.s6_addr32[2] |
> + pkt_dev->min_in6_daddr.s6_addr32[3]) {
> int i;
Why not just use ipv6_addr_any() ? It has an HAS_EFFICIENT_UNALIGNED_ACCESS
check too.
-Brian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 18:42 [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address Joe Perches
2012-10-10 18:59 ` Brian Haley
@ 2012-10-10 19:01 ` Eric Dumazet
2012-10-10 19:23 ` [PATCH net-next? V2] " Joe Perches
2012-10-11 8:08 ` [PATCH net-next?] " David Laight
2 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2012-10-10 19:01 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, LKML
On Wed, 2012-10-10 at 11:42 -0700, Joe Perches wrote:
> Reduces object size and should be slightly faster.
>
> allyesconfig:
>
> $ size net/core/pktgen.o*
> text data bss dec hex filename
> 52251 4293 11824 68368 10b10 net/core/pktgen.o.new
> 52310 4293 11848 68451 10b63 net/core/pktgen.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> Found by looking for if (foo) ; tests with a perl regex
>
> Yes Eric, it could be 2 compares instead of 4 on 64-bit
> systems with HAS_EFFICIENT_UNALIGNED_ACCESS. Maybe later
> or if there are other tests that could become something
> like ipv6_is_zeronet.
>
> cheers, Joe
>
> net/core/pktgen.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 148e73d..3aa8417 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -2422,11 +2422,10 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
> }
> } else { /* IPV6 * */
>
> - if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[1] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[2] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[3] == 0) ;
> - else {
> + if (pkt_dev->min_in6_daddr.s6_addr32[0] |
> + pkt_dev->min_in6_daddr.s6_addr32[1] |
> + pkt_dev->min_in6_daddr.s6_addr32[2] |
> + pkt_dev->min_in6_daddr.s6_addr32[3]) {
> int i;
>
> /* Only random destinations yet */
>
What about ipv6_addr_any() ?
anyway net-next is not opened yet
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 19:01 ` Eric Dumazet
@ 2012-10-10 19:23 ` Joe Perches
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Joe Perches @ 2012-10-10 19:23 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, LKML, Brian Haley
Reduces object size and should be slightly faster.
allyesconfig:
$ size net/core/pktgen.o*
text data bss dec hex filename
52284 4321 11840 68445 10b5d net/core/pktgen.o.new
52310 4293 11848 68451 10b63 net/core/pktgen.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
> What about ipv6_addr_any() ?
That's better I guess.
I forgot about it and didn't see it.
I saw the IPV6_ADDR_ANY type tests and
didn't look further.
Anyway, it's odd that it generates slightly larger code
than the original patch's direct tests in 32bit with
gcc 4.7.2. Perhaps an interesting lack of optimization?
cheers, Joe
net/core/pktgen.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 148e73d..a811a7d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2422,11 +2422,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
}
} else { /* IPV6 * */
- if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[1] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[2] == 0 &&
- pkt_dev->min_in6_daddr.s6_addr32[3] == 0) ;
- else {
+ if (!ipv6_addr_any(&pkt_dev->min_in6_daddr)) {
int i;
/* Only random destinations yet */
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/
2012-10-10 19:23 ` [PATCH net-next? V2] " Joe Perches
@ 2012-10-10 19:38 ` Joe Perches
2012-10-11 0:56 ` [RFC net-next] treewide: s/is_<foo>_ether_addr/eth_addr_<foo> Joe Perches
2012-10-11 8:11 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ David Laight
2012-10-11 2:15 ` [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address Cong Wang
2012-10-11 19:20 ` David Miller
2 siblings, 2 replies; 11+ messages in thread
From: Joe Perches @ 2012-10-10 19:38 UTC (permalink / raw)
To: Eric Dumazet, David Miller; +Cc: netdev, LKML, Brian Haley
ipv4 and ipv6 use different styles for these tests.
ipv4_is_<foo>(__be32)
ipv6_addr_<foo>(struct in6_addr *)
Perhaps it'd be good to convert the ipv4 tests to the ipv6 style.
There are ~100 instances of ipv4_is_<foo> tests treewide.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC net-next] treewide: s/is_<foo>_ether_addr/eth_addr_<foo>
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
@ 2012-10-11 0:56 ` Joe Perches
2012-10-11 8:11 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ David Laight
1 sibling, 0 replies; 11+ messages in thread
From: Joe Perches @ 2012-10-11 0:56 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, LKML, Brian Haley
Maybe all the is_<foo>_ether_addr functions should be renamed
to eth_addr_<foo> for more api/style symmetry.
$ git grep --name-only -E "\bis_\w+_ether_addr" | \
xargs sed -r -i -e 's/\bis_(\w+)_ether_addr\b/eth_addr_\1/g'
$ git diff --shortstat
304 files changed, 690 insertions(+), 690 deletions(-)
Maybe add #defines of the old names for a few releases.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 19:23 ` [PATCH net-next? V2] " Joe Perches
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
@ 2012-10-11 2:15 ` Cong Wang
2012-10-11 19:20 ` David Miller
2 siblings, 0 replies; 11+ messages in thread
From: Cong Wang @ 2012-10-11 2:15 UTC (permalink / raw)
To: Joe Perches; +Cc: Eric Dumazet, netdev, LKML, Brian Haley
On Thu, Oct 11, 2012 at 3:23 AM, Joe Perches <joe@perches.com> wrote:
> Reduces object size and should be slightly faster.
>
> allyesconfig:
> $ size net/core/pktgen.o*
> text data bss dec hex filename
> 52284 4321 11840 68445 10b5d net/core/pktgen.o.new
> 52310 4293 11848 68451 10b63 net/core/pktgen.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
Looks good.
This should go to -net, net-next is not open currently.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 18:42 [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address Joe Perches
2012-10-10 18:59 ` Brian Haley
2012-10-10 19:01 ` Eric Dumazet
@ 2012-10-11 8:08 ` David Laight
2 siblings, 0 replies; 11+ messages in thread
From: David Laight @ 2012-10-11 8:08 UTC (permalink / raw)
To: Joe Perches, netdev; +Cc: LKML
> - if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[1] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[2] == 0 &&
> - pkt_dev->min_in6_daddr.s6_addr32[3] == 0) ;
> - else {
> + if (pkt_dev->min_in6_daddr.s6_addr32[0] |
> + pkt_dev->min_in6_daddr.s6_addr32[1] |
> + pkt_dev->min_in6_daddr.s6_addr32[2] |
> + pkt_dev->min_in6_daddr.s6_addr32[3]) {
Given the likely values, it might be worth using:
if (pkt_dev->min_in6_daddr.s6_addr32[0] == 0 &&
pkt_dev->min_in6_daddr.s6_addr32[1] |
pkt_dev->min_in6_daddr.s6_addr32[2] |
pkt_dev->min_in6_daddr.s6_addr32[3]) {
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
2012-10-11 0:56 ` [RFC net-next] treewide: s/is_<foo>_ether_addr/eth_addr_<foo> Joe Perches
@ 2012-10-11 8:11 ` David Laight
2012-10-11 8:28 ` Joe Perches
1 sibling, 1 reply; 11+ messages in thread
From: David Laight @ 2012-10-11 8:11 UTC (permalink / raw)
To: Joe Perches, Eric Dumazet, David Miller; +Cc: netdev, LKML, Brian Haley
> ipv4 and ipv6 use different styles for these tests.
>
> ipv4_is_<foo>(__be32)
> ipv6_addr_<foo>(struct in6_addr *)
I presume there is a 'const' in there ...
> Perhaps it'd be good to convert the ipv4 tests to the ipv6 style.
You don't want to force an IPv4 address (which might be in a register)
be written out to stack.
Taking the address also has implications for the optimiser.
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/
2012-10-11 8:11 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ David Laight
@ 2012-10-11 8:28 ` Joe Perches
0 siblings, 0 replies; 11+ messages in thread
From: Joe Perches @ 2012-10-11 8:28 UTC (permalink / raw)
To: David Laight; +Cc: Eric Dumazet, David Miller, netdev, LKML, Brian Haley
On Thu, 2012-10-11 at 09:11 +0100, David Laight wrote:
> > ipv4 and ipv6 use different styles for these tests.
> >
> > ipv4_is_<foo>(__be32)
> > ipv6_addr_<foo>(struct in6_addr *)
>
> I presume there is a 'const' in there ...
>
> > Perhaps it'd be good to convert the ipv4 tests to the ipv6 style.
>
> You don't want to force an IPv4 address (which might be in a register)
> be written out to stack.
> Taking the address also has implications for the optimiser.
Of course not, I'm just talking about renaming.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address
2012-10-10 19:23 ` [PATCH net-next? V2] " Joe Perches
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
2012-10-11 2:15 ` [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address Cong Wang
@ 2012-10-11 19:20 ` David Miller
2 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2012-10-11 19:20 UTC (permalink / raw)
To: joe; +Cc: eric.dumazet, netdev, linux-kernel, brian.haley
From: Joe Perches <joe@perches.com>
Date: Wed, 10 Oct 2012 12:23:25 -0700
> Reduces object size and should be slightly faster.
>
> allyesconfig:
> $ size net/core/pktgen.o*
> text data bss dec hex filename
> 52284 4321 11840 68445 10b5d net/core/pktgen.o.new
> 52310 4293 11848 68451 10b63 net/core/pktgen.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
Please resubmit when net-next opens.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-10-11 19:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10 18:42 [PATCH net-next?] pktgen: Use simpler test for non-zero ipv6 address Joe Perches
2012-10-10 18:59 ` Brian Haley
2012-10-10 19:01 ` Eric Dumazet
2012-10-10 19:23 ` [PATCH net-next? V2] " Joe Perches
2012-10-10 19:38 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ Joe Perches
2012-10-11 0:56 ` [RFC net-next] treewide: s/is_<foo>_ether_addr/eth_addr_<foo> Joe Perches
2012-10-11 8:11 ` [RFC net-next] treewide: s/ipv4_is_<foo>()/ipv4_addr_<foo>/ David Laight
2012-10-11 8:28 ` Joe Perches
2012-10-11 2:15 ` [PATCH net-next? V2] pktgen: Use simpler test for non-zero ipv6 address Cong Wang
2012-10-11 19:20 ` David Miller
2012-10-11 8:08 ` [PATCH net-next?] " David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).