Re: [PATCH 08/10] netfilter: ipset: Introduce RCU in all set types instead of rwlock per set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 26 Nov 2014, Pablo Neira Ayuso wrote:

> > diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
> > index f1606fa..418d360 100644
> > --- a/include/linux/netfilter/ipset/ip_set.h
> > +++ b/include/linux/netfilter/ipset/ip_set.h
> > @@ -113,10 +113,10 @@ struct ip_set_comment {
> >  };
> >  
> >  struct ip_set_skbinfo {
> > -	u32 skbmark;
> > -	u32 skbmarkmask;
> > -	u32 skbprio;
> > -	u16 skbqueue;
> > +	u32 __rcu skbmark;
> > +	u32 __rcu skbmarkmask;
> > +	u32 __rcu skbprio;
> > +	u16 __rcu skbqueue;
> >  };
> >  
> >  struct ip_set;
> > @@ -223,7 +223,7 @@ struct ip_set {
> >  	/* The name of the set */
> >  	char name[IPSET_MAXNAMELEN];
> >  	/* Lock protecting the set data */
> > -	rwlock_t lock;
> > +	spinlock_t lock;
> >  	/* References to the set */
> >  	u32 ref;
> >  	/* The core set type */
> > @@ -322,30 +322,72 @@ ip_set_update_counter(struct ip_set_counter *counter,
> >  	}
> >  }
> >  
> > +/* RCU-safe assign value */
> > +#define IP_SET_RCU_ASSIGN(ptr, value)	\
> > +do {					\
> > +	smp_wmb();			\
> > +	*(ptr) = value;			\
> > +} while (0)
> > +
> > +static inline void
> > +ip_set_rcu_assign_ulong(unsigned long *v, unsigned long value)
> > +{
> > +	IP_SET_RCU_ASSIGN(v, value);
> > +}
> > +
> > +static inline void
> > +ip_set_rcu_assign_u32(u32 *v, u32 value)
> > +{
> > +	IP_SET_RCU_ASSIGN(v, value);
> > +}
> > +
> > +static inline void
> > +ip_set_rcu_assign_u16(u16 *v, u16 value)
> > +{
> > +	IP_SET_RCU_ASSIGN(v, value);
> > +}
> > +
> > +static inline void
> > +ip_set_rcu_assign_u8(u8 *v, u8 value)
> > +{
> > +	IP_SET_RCU_ASSIGN(v, value);
> > +}
> 
> No questions regarding numbers, but I would like to see some
> explanation on the RCU approach that you're implementing in this
> patch. Thanks.

There are four types in the patch :-)

- bitmap set types: bit setting is atomic, so nothing required 
- list set type: normal list rcu
- hash set types: the pointer manipulations of the hash buckets
  are RCU protected; the cidr maintenance is changed and ordered
  so that adding/deleting does not break the list of cidrs.
- elem extensions: the manipulations of the extensions are 
  either atomic operations or integer settings. The inline functions
  above provide those RCU safe integer settings: they are the same
  as rcu_assign_pointer(), but that one can be used for pointers only.

Best regards,
Jozsef
-
E-mail  : kadlec@xxxxxxxxxxxxxxxxx, kadlecsik.jozsef@xxxxxxxxxxxxx
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
          H-1525 Budapest 114, POB. 49, Hungary
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux