Re: Kernel rwlock design, Multicore and IGMP

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Thursday, November 11, 2010 - 8:32 am

Le jeudi 11 novembre 2010 à 16:23 +0100, Eric Dumazet a écrit :

I meant, a percpu spinlock, and extra logic to spin_lock() it one time,
even if nested.

static inline void xt_info_rdlock_bh(void)
{
        struct xt_info_lock *lock;

        local_bh_disable();
        lock = &__get_cpu_var(xt_info_locks);
        if (likely(!lock->readers++))
                spin_lock(&lock->lock);
}

static inline void xt_info_rdunlock_bh(void)
{
        struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks);

        if (likely(!--lock->readers))
                spin_unlock(&lock->lock);
        local_bh_enable();
}

The write 'rwlock' side has to lock the percpu spinlock of all possible
cpus.

/*
 * The "writer" side needs to get exclusive access to the lock,
 * regardless of readers.  This must be called with bottom half
 * processing (and thus also preemption) disabled.
 */
static inline void xt_info_wrlock(unsigned int cpu)
{
        spin_lock(&per_cpu(xt_info_locks, cpu).lock);
}

static inline void xt_info_wrunlock(unsigned int cpu)
{
        spin_unlock(&per_cpu(xt_info_locks, cpu).lock);
}



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Thu Nov 11, 6:49 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Thu Nov 11, 8:23 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Thu Nov 11, 8:32 am)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Thu Nov 11, 8:32 pm)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Thu Nov 11, 11:28 pm)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 12:13 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Fri Nov 12, 12:27 am)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 1:19 am)
Re: Kernel rwlock design, Multicore and IGMP, Yong Zhang, (Fri Nov 12, 2:09 am)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 2:18 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Fri Nov 12, 2:22 am)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 2:33 am)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Fri Nov 12, 4:06 am)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Fri Nov 12, 4:10 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Fri Nov 12, 4:25 am)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 11:28 pm)
Re: Kernel rwlock design, Multicore and IGMP, Américo Wang, (Fri Nov 12, 11:35 pm)
Re: Kernel rwlock design, Multicore and IGMP, Peter Zijlstra, (Sat Nov 13, 3:52 pm)
Re: Kernel rwlock design, Multicore and IGMP, Peter Zijlstra, (Sat Nov 13, 3:53 pm)
Re: Kernel rwlock design, Multicore and IGMP, Peter Zijlstra, (Sat Nov 13, 3:54 pm)
Re: Kernel rwlock design, Multicore and IGMP, Chris Metcalf, (Sat Nov 13, 4:03 pm)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Mon Nov 15, 12:22 am)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Mon Nov 15, 4:18 am)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Mon Nov 15, 4:31 am)
Re: Kernel rwlock design, Multicore and IGMP, Cypher Wu, (Tue Nov 16, 6:30 pm)
Re: Kernel rwlock design, Multicore and IGMP, Eric Dumazet, (Tue Nov 16, 9:43 pm)