All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Thomas Graf <tgraf@suug.ch>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@oss.sgi.com
Subject: Re: [PATCH] loop unrolling in net/sched/sch_generic.c
Date: Wed, 06 Jul 2005 02:53:24 +0200	[thread overview]
Message-ID: <42CB2B84.50702@cosmosbay.com> (raw)
In-Reply-To: <42CB2698.2080904@cosmosbay.com>

Eric Dumazet a écrit :
>
> 
> Maybe we can rewrite the whole thing without branches, examining prio 
> from PFIFO_FAST_BANDS-1 down to 0, at least for modern cpu with 
> conditional mov (cmov)
> 
> struct sk_buff_head *best = NULL;
> struct sk_buff_head *list = qdisc_priv(qdisc)+PFIFO_FAST_BANDS-1;
> if (skb_queue_empty(list)) best = list ;
> list--;
> if (skb_queue_empty(list)) best = list ;
> list--;
> if (skb_queue_empty(list)) best = list ;
> if (best != NULL) {
>     qdisc->q.qlen--;
>     return __qdisc_dequeue_head(qdisc, best);
>     }
> 
> This version should have one branch.
> I will test this after some sleep :)
> See you
> Eric
> 
> 

(Sorry, still using 2.6.12, but the idea remains)

static struct sk_buff *
pfifo_fast_dequeue(struct Qdisc* qdisc)
{
         struct sk_buff_head *list = qdisc_priv(qdisc);
         struct sk_buff_head *best = NULL;

	list += 2;
         if (!skb_queue_empty(list))
                 best = list;
         list--;
         if (!skb_queue_empty(list))
                 best = list;
         list--;
         if (!skb_queue_empty(list))
                 best = list;
         if (best) {
                 qdisc->q.qlen--;
                 return __skb_dequeue(best);
                 }
         return NULL;
}



At least the compiler output seems promising :

0000000000000550 <pfifo_fast_dequeue>:
  550:   48 8d 97 f0 00 00 00    lea    0xf0(%rdi),%rdx
  557:   31 c9                   xor    %ecx,%ecx
  559:   48 8d 87 c0 00 00 00    lea    0xc0(%rdi),%rax
  560:   48 39 97 f0 00 00 00    cmp    %rdx,0xf0(%rdi)
  567:   48 0f 45 ca             cmovne %rdx,%rcx
  56b:   48 8d 97 d8 00 00 00    lea    0xd8(%rdi),%rdx
  572:   48 39 97 d8 00 00 00    cmp    %rdx,0xd8(%rdi)
  579:   48 0f 45 ca             cmovne %rdx,%rcx
  57d:   48 39 87 c0 00 00 00    cmp    %rax,0xc0(%rdi)
  584:   48 0f 45 c8             cmovne %rax,%rcx
  588:   31 c0                   xor    %eax,%eax
  58a:   48 85 c9                test   %rcx,%rcx
  58d:   74 32                   je     5c1 <pfifo_fast_dequeue+0x71> // one conditional branch
  58f:   ff 4f 40                decl   0x40(%rdi)
  592:   48 8b 11                mov    (%rcx),%rdx
  595:   48 39 ca                cmp    %rcx,%rdx
  598:   74 27                   je     5c1 <pfifo_fast_dequeue+0x71> // never taken branch : always predicted OK
  59a:   48 89 d0                mov    %rdx,%rax
  59d:   48 8b 12                mov    (%rdx),%rdx
  5a0:   ff 49 10                decl   0x10(%rcx)
  5a3:   48 c7 40 10 00 00 00    movq   $0x0,0x10(%rax)
  5aa:   00
  5ab:   48 89 4a 08             mov    %rcx,0x8(%rdx)
  5af:   48 89 11                mov    %rdx,(%rcx)
  5b2:   48 c7 40 08 00 00 00    movq   $0x0,0x8(%rax)
  5b9:   00
  5ba:   48 c7 00 00 00 00 00    movq   $0x0,(%rax)
  5c1:   90                      nop
  5c2:   c3                      retq

I Will post tomorrow some profiling results.
Eric

  parent reply	other threads:[~2005-07-06  0:53 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-11 21:15 [TG3]: Add hw coalescing infrastructure David S. Miller
2005-05-11 21:17 ` Michael Chan
2005-05-12  2:28   ` David S. Miller
2005-05-12  7:53     ` Robert Olsson
2005-06-22 15:25 ` [TG3]: About " Eric Dumazet
2005-06-22 19:03   ` Michael Chan
2005-07-04 21:22     ` Eric Dumazet
2005-07-04 21:26       ` David S. Miller
2005-07-04 21:39         ` Eric Dumazet
2005-07-04 21:49           ` David S. Miller
2005-07-04 22:31           ` Eric Dumazet
2005-07-04 22:47             ` David S. Miller
2005-07-04 22:55               ` Eric Dumazet
2005-07-04 22:57                 ` Eric Dumazet
2005-07-04 23:01                   ` David S. Miller
2005-07-05  7:38                     ` [PATCH] loop unrolling in net/sched/sch_generic.c Eric Dumazet
2005-07-05 11:51                       ` Thomas Graf
2005-07-05 12:03                         ` Thomas Graf
2005-07-05 13:04                         ` Eric Dumazet
2005-07-05 13:48                           ` Thomas Graf
2005-07-05 15:58                             ` Eric Dumazet
2005-07-05 17:34                               ` Thomas Graf
2005-07-05 21:22                                 ` David S. Miller
2005-07-05 21:33                                   ` Thomas Graf
2005-07-05 21:35                                     ` David S. Miller
2005-07-05 23:16                                       ` Eric Dumazet
2005-07-05 23:41                                         ` Thomas Graf
2005-07-05 23:45                                           ` David S. Miller
2005-07-05 23:55                                             ` Thomas Graf
2005-07-06  0:32                                           ` Eric Dumazet
2005-07-06  0:51                                             ` Thomas Graf
2005-07-06  1:04                                               ` Eric Dumazet
2005-07-06  1:07                                                 ` Thomas Graf
2005-07-06  0:53                                             ` Eric Dumazet [this message]
2005-07-06  1:02                                               ` Thomas Graf
2005-07-06  1:09                                                 ` Eric Dumazet
2005-07-06 12:42                                               ` Thomas Graf
2005-07-07 21:17                                                 ` David S. Miller
2005-07-07 21:34                                                   ` Thomas Graf
2005-07-07 22:24                                                     ` David S. Miller
     [not found]                                                   ` <42CE22CE.7030902@cosmosbay.com>
2005-07-08  7:30                                                     ` David S. Miller
2005-07-08  8:19                                                       ` Eric Dumazet
2005-07-08 11:08                                                         ` Arnaldo Carvalho de Melo
2005-07-12  4:02                                                           ` David S. Miller
2005-07-05 21:26                       ` David S. Miller
2005-07-28 15:52                       ` [PATCH] Add prefetches in net/ipv4/route.c Eric Dumazet
2005-07-28 19:39                         ` David S. Miller
2005-07-28 20:56                           ` Eric Dumazet
2005-07-28 20:58                             ` David S. Miller
2005-07-28 21:24                               ` Eric Dumazet
2005-07-28 22:44                                 ` David S. Miller
2005-07-29 14:50                                 ` Robert Olsson
2005-07-29 17:06                                   ` Rick Jones
2005-07-29 17:44                                     ` Robert Olsson
2005-07-29 17:57                                     ` Eric Dumazet
2005-07-29 18:25                                       ` Rick Jones
2005-07-31  3:52                                         ` David S. Miller
     [not found]                                           ` <42EDDA50.4010405@cosmosbay.com>
2005-08-01 15:39                                             ` David S. Miller
2005-07-31  3:51                                       ` David S. Miller
2005-07-31  3:44                                   ` David S. Miller
2005-07-04 23:00                 ` [TG3]: About hw coalescing infrastructure David S. Miller
2005-07-05 16:14                   ` Eric Dumazet
2005-07-04 22:47             ` Eric Dumazet
     [not found] <C925F8B43D79CC49ACD0601FB68FF50C045E0FB0@orsmsx408>
2005-07-07 22:30 ` [PATCH] loop unrolling in net/sched/sch_generic.c David S. Miller

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=42CB2B84.50702@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    --cc=tgraf@suug.ch \
    /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.