void ilockdep_acquired(struct ilockdep_map *lock, unsigned long ip, void *lock_addr) { unsigned int i; unsigned long flags; struct task_struct *curr = current; raw_local_irq_save(flags); ilockdep_clear_locking(curr); if (curr->ilockdep_lock.depth >= CONFIG_DEBUG_ILOCKDEP_NUM) { raw_local_irq_restore(flags); return; } for (i = 0; i < CONFIG_DEBUG_ILOCKDEP_NUM; i++) { if (curr->ilockdep_lock.held_locks[i].key == NULL) { curr->ilockdep_lock.held_locks[i].key = lock_addr; curr->ilockdep_lock.held_locks[i].cpu = smp_processor_id(); curr->ilockdep_lock.held_locks[i].name = lock->name; curr->ilockdep_lock.held_locks[i].ip = ip; break; } } curr->ilockdep_lock.depth++; raw_local_irq_restore(flags); return; }
/** * down_interruptible - acquire the semaphore unless interrupted * @sem: the semaphore to be acquired * * Attempts to acquire the semaphore. If no more tasks are allowed to * acquire the semaphore, calling this function will put the task to sleep. * If the sleep is interrupted by a signal, this function will return -EINTR. * If the semaphore is successfully acquired, this function returns 0. */ int down_interruptible(struct semaphore *sem) { unsigned long flags; int result = 0; raw_spin_lock_irqsave(&sem->lock, flags); #ifdef CONFIG_ILOCKDEP ilockdep_acquire(&sem->idep_map, _RET_IP_, (void *)sem); #endif if (likely(sem->count > 0)) sem->count--; else result = __down_interruptible(sem); #ifdef CONFIG_ILOCKDEP if (result) ilockdep_clear_locking(current); else ilockdep_acquired(&sem->idep_map, _RET_IP_, (void *)sem); #endif raw_spin_unlock_irqrestore(&sem->lock, flags); return result; }