![Alan Stern](/assets/img/avatar_default.png)
This patch (as751) adds a new type of notifier chain, based on the SRCU (Sleepable Read-Copy Update) primitives recently added to the kernel. An SRCU notifier chain is much like a blocking notifier chain, in that it must be called in process context and its callout routines are allowed to sleep. The difference is that the chain's links are protected by the SRCU mechanism rather than by an rw-semaphore, so calling the chain has extremely low overhead: no memory barriers and no cache-line bouncing. On the other hand, unregistering from the chain is expensive and the chain head requires special runtime initialization (plus cleanup if it is to be deallocated). SRCU notifiers are appropriate for notifiers that will be called very frequently and for which unregistration occurs very seldom. The proposed "task notifier" scheme qualifies, as may some of the network notifiers. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Paul E. McKenney <paulmck@us.ibm.com> Acked-by: Chandra Seetharaman <sekharan@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
/*
|
|
* Sleepable Read-Copy Update mechanism for mutual exclusion
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* Copyright (C) IBM Corporation, 2006
|
|
*
|
|
* Author: Paul McKenney <paulmck@us.ibm.com>
|
|
*
|
|
* For detailed explanation of Read-Copy Update mechanism see -
|
|
* Documentation/RCU/ *.txt
|
|
*
|
|
*/
|
|
|
|
#ifndef _LINUX_SRCU_H
|
|
#define _LINUX_SRCU_H
|
|
|
|
struct srcu_struct_array {
|
|
int c[2];
|
|
};
|
|
|
|
struct srcu_struct {
|
|
int completed;
|
|
struct srcu_struct_array *per_cpu_ref;
|
|
struct mutex mutex;
|
|
};
|
|
|
|
#ifndef CONFIG_PREEMPT
|
|
#define srcu_barrier() barrier()
|
|
#else /* #ifndef CONFIG_PREEMPT */
|
|
#define srcu_barrier()
|
|
#endif /* #else #ifndef CONFIG_PREEMPT */
|
|
|
|
void init_srcu_struct(struct srcu_struct *sp);
|
|
void cleanup_srcu_struct(struct srcu_struct *sp);
|
|
int srcu_read_lock(struct srcu_struct *sp) __acquires(sp);
|
|
void srcu_read_unlock(struct srcu_struct *sp, int idx) __releases(sp);
|
|
void synchronize_srcu(struct srcu_struct *sp);
|
|
long srcu_batches_completed(struct srcu_struct *sp);
|
|
|
|
#endif
|