18 Jul 2012 22:36
Re: [PATCH 09/15] ipv4: Cache output routes in fib_info nexthops.
David Miller <davem <at> davemloft.net>
2012-07-18 20:36:47 GMT
2012-07-18 20:36:47 GMT
From: Eric Dumazet <eric.dumazet <at> gmail.com>
Date: Wed, 18 Jul 2012 22:34:19 +0200
> On Wed, 2012-07-18 at 11:24 -0700, David Miller wrote:
>> If we have an output route that lacks nexthop exceptions, we can cache
>> it in the FIB info nexthop.
>>
>> Such routes will have DST_HOST cleared because such routes refer to a
>> family of destinations, rather than just one.
>
>
>> - const struct fib_result *res,
>> +static void rt_cache_route(struct fib_nh *nh, struct rtable *rt)
>> +{
>> + static DEFINE_SPINLOCK(fib_cache_lock);
>> + struct rtable **p = &nh->nh_rth_output;
>> +
>> + if (*p)
>> + return;
>> +
>> + spin_lock_bh(&fib_cache_lock);
>> + if (!*p) {
>> + *p = rt;
>> + dst_clone(&rt->dst);
>> + }
>> + spin_unlock_bh(&fib_cache_lock);
>> +}
>> +
>
> This probably should use cmpxchg()
Do you really think it's faster/better in this case? I did consider
it.
RSS Feed