From: Stephen Hemminger <shemminger@osdl.org>
To: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH 4/6] net neighbour: convert to RCU
Date: Tue, 29 Aug 2006 16:49:40 -0700 [thread overview]
Message-ID: <20060829164940.13d03500@localhost.localdomain> (raw)
In-Reply-To: <20060829232126.GA18636@ms2.inr.ac.ru>
On Wed, 30 Aug 2006 03:21:26 +0400
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> wrote:
> Hello!
>
> > This should not be any more racy than the existing code.
>
> Existing code is not racy.
Race 1: w/o RCU
Cpu 0: is in neigh_lookup
gets read_lock()
finds entry
++refcount to 2
updates it
Cpu 1: is in forced_gc()
waits at write_lock()
releases read_lock()
drops ref count to 1.
sees ref count is 1
deletes it
Race 1: w RCU
Cpu 0: is in __neigh_lookup
updates it
Cpu 1: is in forced_gc()
leaves refcount=1
sees ref count is 1
deletes it
>
> Critical place is interpretation of refcnt==1. Current code assumes,
> that when refcnt=1 and entry is in hash table, nobody can take this
> entry (table is locked). So, it can be unlinked from the table.
>
> See? __neigh_lookup()/__neigh_lookup_errno() _MUST_ return alive
> and hashed entry. And will stay hashed until the reference is held.
> Or until neigh entry is forced for destruction by device going down,
> in this case referring dst entries will die as well.
Why must it be hashed, it could always get zapped just after the update.
> If dst cache grabs an entry, which is purged from table because for some
> time it had refcnt==1, you got a valid dst entry referring to dead
> neighbour entry.
Hmm.. Since this is a slow path, grabbing the write_lock on the neighbour
entry would block the gc from zapping it.
in __neigh_lookup()
neigh_hold();
write_lock(&n->lock);
if (n->dead) {
write_unlock()
neigh_release()
goto rescan;
}
write_unlock()
--
Stephen Hemminger <shemminger@osdl.org>
next prev parent reply other threads:[~2006-08-29 23:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-28 23:07 [PATCH 0/6] Lockless neighbour table Stephen Hemminger
2006-08-28 23:07 ` [PATCH 1/6] net neighbor: convert top level list to RCU Stephen Hemminger
2006-08-28 23:07 ` [PATCH 2/6] neighbour: convert neighbour hash table to hlist Stephen Hemminger
2006-08-28 23:07 ` [PATCH 3/6] neighbour: convert pneigh " Stephen Hemminger
2006-08-28 23:07 ` [PATCH 4/6] net neighbour: convert to RCU Stephen Hemminger
2006-08-29 15:28 ` Alexey Kuznetsov
2006-08-29 18:22 ` Stephen Hemminger
2006-08-29 18:34 ` Martin Josefsson
2006-08-29 20:17 ` Stephen Hemminger
2006-08-29 21:17 ` Alexey Kuznetsov
2006-08-29 21:46 ` Stephen Hemminger
2006-08-29 22:16 ` Alexey Kuznetsov
2006-08-29 23:00 ` Stephen Hemminger
2006-08-29 23:21 ` Alexey Kuznetsov
2006-08-29 23:49 ` Stephen Hemminger [this message]
2006-08-30 0:06 ` Alexey Kuznetsov
2006-08-29 23:36 ` Alexey Kuznetsov
2006-08-28 23:07 ` [PATCH 5/6] neighbour: convert lookup to sequence lock Stephen Hemminger
2006-08-28 23:07 ` [PATCH 6/6] neighbour: convert hard header cache to sequence number 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=20060829164940.13d03500@localhost.localdomain \
--to=shemminger@osdl.org \
--cc=davem@davemloft.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox