From: Eric Dumazet <eric.dumazet@gmail.com>
To: Julian Anastasov <ja@ssi.bg>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH 0/5] Long term PMTU/redirect storage in ipv4.
Date: Wed, 18 Jul 2012 05:46:06 +0200 [thread overview]
Message-ID: <1342583166.2626.1367.camel@edumazet-glaptop> (raw)
In-Reply-To: <alpine.LFD.2.00.1207180358190.2128@ja.ssi.bg>
On Wed, 2012-07-18 at 04:06 +0300, Julian Anastasov wrote:
>
> I created patch with seqlock usage. This version
> is with global seqlock because I'm not sure if 2048 locks
> per NH are good idea. This is only compile tested.
> After comments may be I have to resubmit in separate message.
>
>
> Subject: [PATCH] ipv4: use seqlock for nh_exceptions
>
> From: Julian Anastasov <ja@ssi.bg>
>
> Use global seqlock for the nh_exceptions. Call
> fnhe_oldest with the right hash chain. Correct the diff
> value for dst_set_expires.
>
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
> ---
> include/net/ip_fib.h | 2 +-
> net/ipv4/route.c | 117 ++++++++++++++++++++++++++++++++------------------
> 2 files changed, 76 insertions(+), 43 deletions(-)
>
...
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index f67e702..e037c73 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1334,8 +1334,9 @@ static void ip_rt_build_flow_key(struct flowi4 *fl4, const struct sock *sk,
> }
>
> static DEFINE_SPINLOCK(fnhe_lock);
> +static DEFINE_SEQLOCK(fnhe_seqlock);
Hi Julian
I find this patch too complex.
You could only change fnhe_lock to a seqlock
net/ipv4/route.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index f67e702..a96fc9d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1333,7 +1333,7 @@ static void ip_rt_build_flow_key(struct flowi4 *fl4, const struct sock *sk,
build_sk_flow_key(fl4, sk);
}
-static DEFINE_SPINLOCK(fnhe_lock);
+static DEFINE_SEQLOCK(fnhe_seqlock);
static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash, __be32 daddr)
{
@@ -1454,11 +1454,11 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
struct fib_nh *nh = &FIB_RES_NH(res);
struct fib_nh_exception *fnhe;
- spin_lock_bh(&fnhe_lock);
+ write_seqlock_bh(&fnhe_seqlock);
fnhe = find_or_create_fnhe(nh, fl4->daddr);
if (fnhe)
fnhe->fnhe_gw = new_gw;
- spin_unlock_bh(&fnhe_lock);
+ write_sequnlock_bh(&fnhe_seqlock);
}
rt->rt_gateway = new_gw;
rt->rt_flags |= RTCF_REDIRECTED;
@@ -1665,13 +1665,13 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
struct fib_nh *nh = &FIB_RES_NH(res);
struct fib_nh_exception *fnhe;
- spin_lock_bh(&fnhe_lock);
+ write_seqlock_bh(&fnhe_seqlock);
fnhe = find_or_create_fnhe(nh, fl4->daddr);
if (fnhe) {
fnhe->fnhe_pmtu = mtu;
fnhe->fnhe_expires = jiffies + ip_rt_mtu_expires;
}
- spin_unlock_bh(&fnhe_lock);
+ write_sequnlock_bh(&fnhe_seqlock);
}
rt->rt_pmtu = mtu;
dst_set_expires(&rt->dst, ip_rt_mtu_expires);
@@ -1904,18 +1904,29 @@ static void rt_bind_exception(struct rtable *rt, struct fib_nh *nh, __be32 daddr
for (fnhe = rcu_dereference(hash[hval].chain); fnhe;
fnhe = rcu_dereference(fnhe->fnhe_next)) {
- if (fnhe->fnhe_daddr == daddr) {
- if (fnhe->fnhe_pmtu) {
- unsigned long expires = fnhe->fnhe_expires;
- unsigned long diff = jiffies - expires;
+ unsigned int seq;
+ __be32 fnhe_daddr, gw;
+ u32 pmtu;
+ unsigned long expires;
+
+ do {
+ seq = read_seqbegin(&fnhe_seqlock);
+ fnhe_daddr = fnhe->fnhe_daddr;
+ gw = fnhe->fnhe_gw;
+ pmtu = fnhe->fnhe_pmtu;
+ expires = fnhe->fnhe_expires;
+ } while (read_seqretry(&fnhe_seqlock, seq));
+ if (fnhe_daddr == daddr) {
+ if (pmtu) {
+ unsigned long diff = expires - jiffies;
if (time_before(jiffies, expires)) {
- rt->rt_pmtu = fnhe->fnhe_pmtu;
+ rt->rt_pmtu = pmtu;
dst_set_expires(&rt->dst, diff);
}
}
- if (fnhe->fnhe_gw)
- rt->rt_gateway = fnhe->fnhe_gw;
+ if (gw)
+ rt->rt_gateway = gw;
fnhe->fnhe_stamp = jiffies;
break;
}
next prev parent reply other threads:[~2012-07-18 3:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-17 13:14 [PATCH 0/5] Long term PMTU/redirect storage in ipv4 David Miller
2012-07-17 18:03 ` David Miller
2012-07-18 4:58 ` net-next and IPv6 Eric Dumazet
2012-07-18 7:04 ` Eric Dumazet
2012-07-18 7:23 ` Eric Dumazet
2012-07-18 7:38 ` [PATCH net-next] ipv6: fix inet6_csk_xmit() Eric Dumazet
2012-07-18 16:00 ` David Miller
2012-07-17 20:41 ` [PATCH 0/5] Long term PMTU/redirect storage in ipv4 Julian Anastasov
2012-07-17 20:46 ` David Miller
2012-07-17 22:14 ` Julian Anastasov
2012-07-17 22:09 ` David Miller
2012-07-18 1:06 ` Julian Anastasov
2012-07-18 3:46 ` Eric Dumazet [this message]
2012-07-18 7:28 ` Julian Anastasov
2012-07-18 7:30 ` Eric Dumazet
2012-07-18 8:36 ` Julian Anastasov
2012-07-18 16:07 ` David 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=1342583166.2626.1367.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=ja@ssi.bg \
--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