netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Octavian Purdila <opurdila@ixiacom.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
	Lucian Adrian Grijincu <lgrijincu@ixiacom.com>,
	netdev@vger.kernel.org
Subject: Re: neighbour table RCU
Date: Tue, 01 Sep 2009 18:14:37 +0200	[thread overview]
Message-ID: <4A9D486D.4020408@gmail.com> (raw)
In-Reply-To: <200909011855.34175.opurdila@ixiacom.com>

Octavian Purdila a écrit :
> On Tuesday 01 September 2009 09:50:17 Eric Dumazet wrote:
>> Stephen Hemminger a écrit :
>>> Looking at the neighbour table, it should be possible to get
>>> rid of the two reader/writer locks.  The hash table lock is pretty
>>> amenable to RCU, but the dynamic resizing makes it non-trivial.
>>> Thinking of using a combination of RCU and sequence counts so that the
>>> reader would just rescan if resize was in progress.
>> I am not sure neigh_tbl_lock rwlock should be changed, I did not
>> see any contention on it.
>>
> 
> Speaking about neighbour optimizations, here is a RFC patch which makes the 
> tables double linked, for constant time deletion. It has given us a significant 
> performance improvement - in less then usual setups though, with lots of 
> neighbours.

How many "struct neigh_parms" do you have in your setups, and
what is the frequency of neigh_parms_release() calls ???

> 
> Would something like this be acceptable for upstream? (pardon the p4 diff dump 
> :) - but I think it will give a rough idea, if acceptable will clean it up and 
> properly submit it)

Seems straightforward

> 
> BTW, would switching to list_head be better?

Yes, definitly :)

> 
> Thanks,
> tavi
> 
> ==== //packages/linux-2.6.7/main/src/include/net/neighbour.h#2 (text) ====
> 
> @@ -56,6 +56,7 @@
>  struct neigh_parms
>  {
>         struct neigh_parms *next;
> +       struct neigh_parms **pprev;
>         int     (*neigh_setup)(struct neighbour *);
>         struct neigh_table *tbl;
>         int     entries;
> 
> ==== //packages/linux-2.6.7/main/src/net/core/neighbour.c#3 (text) ====
> 
> @@ -1127,8 +1127,10 @@
>                 }
>                 p->sysctl_table = NULL;
>                 write_lock_bh(&tbl->lock);
> -               p->next         = tbl->parms.next;
> +               if ((p->next = tbl->parms.next))
> +                       p->next->pprev = &p->next;
>                 tbl->parms.next = p;
> +               p->pprev = &tbl->parms.next;
>                 write_unlock_bh(&tbl->lock);
>         }
>         return p;
> @@ -1136,21 +1138,14 @@
>  
>  void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
>  {
> -       struct neigh_parms **p;
> -
>         if (!parms || parms == &tbl->parms)
>                 return;
>         write_lock_bh(&tbl->lock);
> -       for (p = &tbl->parms.next; *p; p = &(*p)->next) {
> -               if (*p == parms) {
> -                       *p = parms->next;
> -                       write_unlock_bh(&tbl->lock);
> -                       kfree(parms);
> -                       return;
> -               }
> -       }
> +       if ((*parms->pprev = parms->next))
> +               parms->next->pprev = parms->pprev;
>         write_unlock_bh(&tbl->lock);
> -       NEIGH_PRINTK1("neigh_parms_release: not found\n");
> +       kfree(parms);
> +       return;
>  }
> --

  reply	other threads:[~2009-09-01 16:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31 22:04 neighbour table RCU Stephen Hemminger
2009-09-01  6:50 ` Eric Dumazet
2009-09-01 15:55   ` Octavian Purdila
2009-09-01 16:14     ` Eric Dumazet [this message]
2009-09-01 16:56       ` Octavian Purdila
2009-09-01 16:23     ` Stephen Hemminger
2009-09-01 15:59   ` Stephen Hemminger
2009-09-01 16:13     ` Eric Dumazet
2009-09-01 21:24       ` Stephen Hemminger

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=4A9D486D.4020408@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=lgrijincu@ixiacom.com \
    --cc=netdev@vger.kernel.org \
    --cc=opurdila@ixiacom.com \
    --cc=shemminger@vyatta.com \
    /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 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).