lkml.org 
[lkml]   [2009]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] netfilter: use per-cpu recursive lock (v11)
On Tue, Apr 21, 2009 at 10:55:59AM +0200, Eric Dumazet (dada1@cosmosbay.com) wrote:
> Maybe just dont care about calling several time local_bh_disable()
> (since we were doing this in previous kernels anyway, we used to call read_lock_bh())
>
> This shortens fastpath, is faster than local_irq_save()/local_irq_restore(),
> and looks better.

Yeah, given that non-nested locking is more likely condition, it will be
even faster than preemption case.

> void xt_info_rdlock_bh(void)
> {
> struct xt_info_lock *lock;
>
> local_bh_disable();
> lock = &__get_cpu_var(xt_info_locks);
> if (likely(++lock->depth == 0))
> spin_lock(&lock->lock);
> }
>
> void xt_info_rdunlock_bh(void)
> {
> struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks);
>
> BUG_ON(lock->depth < 0);
> if (likely(--lock->depth < 0))
> spin_unlock(&lock->lock);
> local_bh_enable();
> }
>
>

--
Evgeniy Polyakov


\
 
 \ /
  Last update: 2009-04-21 11:25    [W:0.234 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site