y.
aboutsummaryrefslogblamecommitdiffstats
path: root/include/linux/lglock.h
blob: 87f402ccec55567330943ab774ffb12ae21c7da8 (plain) (tree)























                                                                              
                      

















































                                                                                

                                                                         


                                                                         



















                                                                         







                                                                             




                                                                         








































                                                                         
                                                                         
                                                                         
                                                                         









                                                                         
                                                                         



                                                                         
                                                                         






                                                                         
                                                                         









                                                                         
                                                                         







                                                                         
/*
 * Specialised local-global spinlock. Can only be declared as global variables
 * to avoid overhead and keep things simple (and we don't want to start using
 * these inside dynamically allocated structures).
 *
 * "local/global locks" (lglocks) can be used to:
 *
 * - Provide fast exclusive access to per-CPU data, with exclusive access to
 *   another CPU's data allowed but possibly subject to contention, and to
 *   provide very slow exclusive access to all per-CPU data.
 * - Or to provide very fast and scalable read serialisation, and to provide
 *   very slow exclusive serialisation of data (not necessarily per-CPU data).
 *
 * Brlocks are also implemented as a short-hand notation for the latter use
 * case.
 *
 * Copyright 2009, 2010, Nick Piggin, Novell Inc.
 */
#ifndef __LINUX_LGLOCK_H
#define __LINUX_LGLOCK_H

#include <linux/spinlock.h>
#include <linux/lockdep.h>
#include <linux/percpu.h>
#include <linux/cpu.h>

/* can make br locks by using local lock for read side, global lock for write */
#define br_lock_init(name)	name##_lock_init()
#define br_read_lock(name)	name##_local_lock()
#define br_read_unlock(name)	name##_local_unlock()