Skip to content

Commit

Permalink
Merge branch 'v2.6.24-lockdep' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/peterz/linux-2.6-lockdep

* 'v2.6.24-lockdep' of git://git.kernel.org/pub/scm/linux/kernel/git/peterz/linux-2.6-lockdep:
  lockdep: annotate dir vs file i_mutex
  lockdep: per filesystem inode lock class
  lockdep: annotate kprobes irq fiddling
  lockdep: annotate rcu_read_{,un}lock{,_bh}
  lockdep: annotate journal_start()
  lockdep: s390: connect the sysexit hook
  lockdep: x86_64: connect the sysexit hook
  lockdep: i386: connect the sysexit hook
  lockdep: syscall exit check
  lockdep: fixup mutex annotations
  lockdep: fix mismatched lockdep_depth/curr_chain_hash
  lockdep: Avoid /proc/lockdep & lock_stat infinite output
  lockdep: maintainers
  • Loading branch information
Linus Torvalds committed Oct 15, 2007
2 parents 4937ce8 + 14358e6 commit 419217c
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 57 deletions.
9 changes: 9 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,15 @@ M: khali@linux-fr.org
L: lm-sensors@lm-sensors.org
S: Maintained

LOCKDEP AND LOCKSTAT
P: Peter Zijlstra
M: peterz@infradead.org
P: Ingo Molnar
M: mingo@redhat.com
L: linux-kernel@vger.kernel.org
T: git://git.kernel.org/pub/scm/linux/kernel/git/peterz/linux-2.6-lockdep.git
S: Maintained

LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP/Vista Dynamic Disks)
P: Richard Russon (FlatCap)
M: ldm@flatcap.org
Expand Down
12 changes: 12 additions & 0 deletions arch/s390/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ STACK_SIZE = 1 << STACK_SHIFT
l %r1,BASED(.Ltrace_irq_off)
basr %r14,%r1
.endm

.macro LOCKDEP_SYS_EXIT
l %r1,BASED(.Llockdep_sys_exit)
basr %r14,%r1
.endm
#else
#define TRACE_IRQS_ON
#define TRACE_IRQS_OFF
#define LOCKDEP_SYS_EXIT
#endif

/*
Expand Down Expand Up @@ -260,6 +266,7 @@ sysc_return:
bno BASED(sysc_leave)
tm __TI_flags+3(%r9),_TIF_WORK_SVC
bnz BASED(sysc_work) # there is work to do (signals etc.)
LOCKDEP_SYS_EXIT
sysc_leave:
RESTORE_ALL __LC_RETURN_PSW,1

Expand All @@ -283,6 +290,7 @@ sysc_work:
bo BASED(sysc_restart)
tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
bo BASED(sysc_singlestep)
LOCKDEP_SYS_EXIT
b BASED(sysc_leave)

#
Expand Down Expand Up @@ -572,6 +580,7 @@ io_return:
#endif
tm __TI_flags+3(%r9),_TIF_WORK_INT
bnz BASED(io_work) # there is work to do (signals etc.)
LOCKDEP_SYS_EXIT
io_leave:
RESTORE_ALL __LC_RETURN_PSW,0
io_done:
Expand Down Expand Up @@ -618,6 +627,7 @@ io_work_loop:
bo BASED(io_reschedule)
tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
bnz BASED(io_sigpending)
LOCKDEP_SYS_EXIT
b BASED(io_leave)

#
Expand Down Expand Up @@ -1040,6 +1050,8 @@ cleanup_io_leave_insn:
.Ltrace_irq_on: .long trace_hardirqs_on
.Ltrace_irq_off:
.long trace_hardirqs_off
.Llockdep_sys_exit:
.long lockdep_sys_exit
#endif
.Lcritical_start:
.long __critical_start + 0x80000000
Expand Down
9 changes: 9 additions & 0 deletions arch/s390/kernel/entry64.S
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
.macro TRACE_IRQS_OFF
brasl %r14,trace_hardirqs_off
.endm

.macro LOCKDEP_SYS_EXIT
brasl %r14,lockdep_sys_exit
.endm
#else
#define TRACE_IRQS_ON
#define TRACE_IRQS_OFF
#define LOCKDEP_SYS_EXIT
#endif

.macro STORE_TIMER lc_offset
Expand Down Expand Up @@ -255,6 +260,7 @@ sysc_return:
jno sysc_leave
tm __TI_flags+7(%r9),_TIF_WORK_SVC
jnz sysc_work # there is work to do (signals etc.)
LOCKDEP_SYS_EXIT
sysc_leave:
RESTORE_ALL __LC_RETURN_PSW,1

Expand All @@ -278,6 +284,7 @@ sysc_work:
jo sysc_restart
tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
jo sysc_singlestep
LOCKDEP_SYS_EXIT
j sysc_leave

#
Expand Down Expand Up @@ -558,6 +565,7 @@ io_return:
#endif
tm __TI_flags+7(%r9),_TIF_WORK_INT
jnz io_work # there is work to do (signals etc.)
LOCKDEP_SYS_EXIT
io_leave:
RESTORE_ALL __LC_RETURN_PSW,0
io_done:
Expand Down Expand Up @@ -605,6 +613,7 @@ io_work_loop:
jo io_reschedule
tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
jnz io_sigpending
LOCKDEP_SYS_EXIT
j io_leave

#
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/kernel/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ check_userspace:
jb resume_kernel # not returning to v8086 or userspace

ENTRY(resume_userspace)
LOCKDEP_SYS_EXIT
DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
Expand Down Expand Up @@ -338,6 +339,7 @@ sysenter_past_esp:
jae syscall_badsys
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp)
LOCKDEP_SYS_EXIT
DISABLE_INTERRUPTS(CLBR_ANY)
TRACE_IRQS_OFF
movl TI_flags(%ebp), %ecx
Expand Down Expand Up @@ -377,6 +379,7 @@ syscall_call:
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp) # store the return value
syscall_exit:
LOCKDEP_SYS_EXIT
DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
Expand Down Expand Up @@ -467,6 +470,7 @@ work_pending:
jz work_notifysig
work_resched:
call schedule
LOCKDEP_SYS_EXIT
DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
Expand Down
23 changes: 11 additions & 12 deletions arch/x86/kernel/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ ret_from_sys_call:
movl $_TIF_ALLWORK_MASK,%edi
/* edi: flagmask */
sysret_check:
LOCKDEP_SYS_EXIT
GET_THREAD_INFO(%rcx)
cli
TRACE_IRQS_OFF
Expand Down Expand Up @@ -333,6 +334,7 @@ int_ret_from_sys_call:
movl $_TIF_ALLWORK_MASK,%edi
/* edi: mask to check */
int_with_check:
LOCKDEP_SYS_EXIT_IRQ
GET_THREAD_INFO(%rcx)
movl threadinfo_flags(%rcx),%edx
andl %edi,%edx
Expand Down Expand Up @@ -544,11 +546,13 @@ exit_intr:
retint_with_reschedule:
movl $_TIF_WORK_MASK,%edi
retint_check:
LOCKDEP_SYS_EXIT_IRQ
movl threadinfo_flags(%rcx),%edx
andl %edi,%edx
CFI_REMEMBER_STATE
jnz retint_careful
retint_swapgs:

retint_swapgs: /* return to user-space */
/*
* The iretq could re-enable interrupts:
*/
Expand All @@ -557,7 +561,7 @@ retint_swapgs:
swapgs
jmp restore_args

retint_restore_args:
retint_restore_args: /* return to kernel space */
cli
/*
* The iretq could re-enable interrupts:
Expand Down Expand Up @@ -866,26 +870,21 @@ error_sti:
movq ORIG_RAX(%rsp),%rsi /* get error code */
movq $-1,ORIG_RAX(%rsp)
call *%rax
/* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
error_exit:
movl %ebx,%eax
/* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
error_exit:
movl %ebx,%eax
RESTORE_REST
cli
TRACE_IRQS_OFF
GET_THREAD_INFO(%rcx)
testl %eax,%eax
jne retint_kernel
LOCKDEP_SYS_EXIT_IRQ
movl threadinfo_flags(%rcx),%edx
movl $_TIF_WORK_MASK,%edi
andl %edi,%edx
jnz retint_careful
/*
* The iret might restore flags:
*/
TRACE_IRQS_IRETQ
swapgs
RESTORE_ARGS 0,8,0
jmp iret_label
jmp retint_swapgs
CFI_ENDPROC

error_kernelspace:
Expand Down
7 changes: 7 additions & 0 deletions arch/x86/kernel/kprobes_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,12 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)

resume_execution(cur, regs, kcb);
regs->eflags |= kcb->kprobe_saved_eflags;
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
if (raw_irqs_disabled_flags(regs->eflags))
trace_hardirqs_off();
else
trace_hardirqs_on();
#endif

/*Restore back the original saved kprobes variables and continue. */
if (kcb->kprobe_status == KPROBE_REENTER) {
Expand Down Expand Up @@ -694,6 +700,7 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
MIN_STACK_SIZE(addr));
regs->eflags &= ~IF_MASK;
trace_hardirqs_off();
regs->eip = (unsigned long)(jp->entry);
return 1;
}
Expand Down
7 changes: 7 additions & 0 deletions arch/x86/kernel/kprobes_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ int __kprobes post_kprobe_handler(struct pt_regs *regs)

resume_execution(cur, regs, kcb);
regs->eflags |= kcb->kprobe_saved_rflags;
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
if (raw_irqs_disabled_flags(regs->eflags))
trace_hardirqs_off();
else
trace_hardirqs_on();
#endif

/* Restore the original saved kprobes variables and continue. */
if (kcb->kprobe_status == KPROBE_REENTER) {
Expand Down Expand Up @@ -684,6 +690,7 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
MIN_STACK_SIZE(addr));
regs->eflags &= ~IF_MASK;
trace_hardirqs_off();
regs->rip = (unsigned long)(jp->entry);
return 1;
}
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/lib/thunk_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
thunk trace_hardirqs_on_thunk,trace_hardirqs_on
thunk trace_hardirqs_off_thunk,trace_hardirqs_off
#endif

#ifdef CONFIG_DEBUG_LOCK_ALLOC
thunk lockdep_sys_exit_thunk,lockdep_sys_exit
#endif

/* SAVE_ARGS below is used only for the .cfi directives it contains. */
CFI_STARTPROC
Expand Down
24 changes: 21 additions & 3 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ static struct inode *alloc_inode(struct super_block *sb)
return NULL;
}

spin_lock_init(&inode->i_lock);
lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key);

mutex_init(&inode->i_mutex);
lockdep_set_class(&inode->i_mutex, &sb->s_type->i_mutex_key);

init_rwsem(&inode->i_alloc_sem);
lockdep_set_class(&inode->i_alloc_sem, &sb->s_type->i_alloc_sem_key);

mapping->a_ops = &empty_aops;
mapping->host = inode;
mapping->flags = 0;
Expand Down Expand Up @@ -190,16 +199,13 @@ void inode_init_once(struct inode *inode)
INIT_HLIST_NODE(&inode->i_hash);
INIT_LIST_HEAD(&inode->i_dentry);
INIT_LIST_HEAD(&inode->i_devices);
mutex_init(&inode->i_mutex);
init_rwsem(&inode->i_alloc_sem);
INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
rwlock_init(&inode->i_data.tree_lock);
spin_lock_init(&inode->i_data.i_mmap_lock);
INIT_LIST_HEAD(&inode->i_data.private_list);
spin_lock_init(&inode->i_data.private_lock);
INIT_RAW_PRIO_TREE_ROOT(&inode->i_data.i_mmap);
INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear);
spin_lock_init(&inode->i_lock);
i_size_ordered_init(inode);
#ifdef CONFIG_INOTIFY
INIT_LIST_HEAD(&inode->inotify_watches);
Expand Down Expand Up @@ -561,6 +567,18 @@ EXPORT_SYMBOL(new_inode);

void unlock_new_inode(struct inode *inode)
{
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct file_system_type *type = inode->i_sb->s_type;
/*
* ensure nobody is actually holding i_mutex
*/
mutex_destroy(&inode->i_mutex);
mutex_init(&inode->i_mutex);
if (inode->i_mode & S_IFDIR)
lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key);
else
lockdep_set_class(&inode->i_mutex, &type->i_mutex_key);
#endif
/*
* This is special! We do not need the spinlock
* when clearing I_LOCK, because we're guaranteed
Expand Down
9 changes: 9 additions & 0 deletions fs/jbd/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ static int start_this_handle(journal_t *journal, handle_t *handle)
return ret;
}

static struct lock_class_key jbd_handle_key;

/* Allocate a new handle. This should probably be in a slab... */
static handle_t *new_handle(int nblocks)
{
Expand All @@ -243,6 +245,8 @@ static handle_t *new_handle(int nblocks)
handle->h_buffer_credits = nblocks;
handle->h_ref = 1;

lockdep_init_map(&handle->h_lockdep_map, "jbd_handle", &jbd_handle_key, 0);

return handle;
}

Expand Down Expand Up @@ -286,6 +290,9 @@ handle_t *journal_start(journal_t *journal, int nblocks)
current->journal_info = NULL;
handle = ERR_PTR(err);
}

lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_);

return handle;
}

Expand Down Expand Up @@ -1411,6 +1418,8 @@ int journal_stop(handle_t *handle)
spin_unlock(&journal->j_state_lock);
}

lock_release(&handle->h_lockdep_map, 1, _THIS_IP_);

jbd_free_handle(handle);
return err;
}
Expand Down
13 changes: 13 additions & 0 deletions include/asm-x86/irqflags_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,17 @@ static inline int raw_irqs_disabled(void)
# define TRACE_IRQS_OFF
#endif

#ifdef CONFIG_DEBUG_LOCK_ALLOC
# define LOCKDEP_SYS_EXIT \
pushl %eax; \
pushl %ecx; \
pushl %edx; \
call lockdep_sys_exit; \
popl %edx; \
popl %ecx; \
popl %eax;
#else
# define LOCKDEP_SYS_EXIT
#endif

#endif
Loading

0 comments on commit 419217c

Please sign in to comment.