1/* 2 * <asm/smplock.h> 3 * 4 * Default SMP lock implementation 5 */ 6#include <linux/interrupt.h> 7#include <linux/spinlock.h> 8#include <linux/sched.h> 9 10#include <asm/current.h> 11#include <asm/hardirq.h> 12 13extern spinlock_t kernel_flag; 14 15#define kernel_locked() spin_is_locked(&kernel_flag) 16 17/* 18 * Release global kernel lock and global interrupt lock 19 */ 20static __inline__ void 21release_kernel_lock(struct task_struct *task, int cpu) 22{ 23 if (task->lock_depth >= 0) 24 spin_unlock(&kernel_flag); 25 release_irqlock(cpu); 26 __sti(); 27} 28 29/* 30 * Re-acquire the kernel lock 31 */ 32static __inline__ void 33reacquire_kernel_lock(struct task_struct *task) 34{ 35 if (task->lock_depth >= 0) 36 spin_lock(&kernel_flag); 37} 38 39/* 40 * Getting the big kernel lock. 41 * 42 * This cannot happen asynchronously, 43 * so we only need to worry about other 44 * CPU's. 45 */ 46static __inline__ void 47lock_kernel(void) 48{ 49 if (!++current->lock_depth) 50 spin_lock(&kernel_flag); 51} 52 53static __inline__ void 54unlock_kernel(void) 55{ 56 if (--current->lock_depth < 0) 57 spin_unlock(&kernel_flag); 58} 59

