From: John L. <mov...@us...> - 2002-01-17 03:54:23
|
Update of /cvsroot/oprofile/oprofile/module In directory usw-pr-cvs1:/tmp/cvs-serv3347/module Modified Files: compat22.h compat24.h op_rtc.c oprofile.c Log Message: x 2.2 build, rtc kernel/user, 2.2 NMI wake_up fix (maybe) Index: compat22.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/module/compat22.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- compat22.h 2002/01/17 03:21:40 1.2 +++ compat22.h 2002/01/17 03:54:17 1.3 @@ -29,9 +29,19 @@ #define take_mmap_sem(mm) down(&mm->mmap_sem) #define release_mmap_sem(mm) up(&mm->mmap_sem) #define MODULE_LICENSE(l) - +#define NEED_2_2_DENTRIES #define INC_USE_COUNT_MAYBE MOD_INC_USE_COUNT #define DEC_USE_COUNT_MAYBE MOD_DEC_USE_COUNT + +// FIXME: untested +static inline int wq_is_lockable(void) +{ + if (spin_trylock(&waitqueue_lock)) { + spin_unlock(&waitqueue_lock); + return 1; + } + return 0; +} extern int wind_dentries_2_2(struct dentry *dentry); extern uint do_path_hash_2_2(struct dentry *dentry); Index: compat24.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/module/compat24.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- compat24.h 2002/01/17 03:21:40 1.2 +++ compat24.h 2002/01/17 03:54:17 1.3 @@ -41,6 +41,9 @@ #define INC_USE_COUNT_MAYBE #define DEC_USE_COUNT_MAYBE +/* no global waitqueue spinlock in 2.4 */ +#define wq_is_lockable() (1) + /* 2.4.3 introduced rw mmap semaphore */ #if VAFTER(2,4,3) #define take_mmap_sem(mm) down_read(&mm->mmap_sem) Index: op_rtc.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/module/op_rtc.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- op_rtc.c 2002/01/17 03:21:40 1.7 +++ op_rtc.c 2002/01/17 03:54:17 1.8 @@ -16,6 +16,7 @@ #include <linux/ioport.h> #include <linux/mc146818rtc.h> +#include <asm/ptrace.h> #include "oprofile.h" @@ -49,6 +50,11 @@ uint cpu = op_cpu_id(); unsigned char intr_flags; unsigned long flags; + + int usermode = user_mode(regs); + if (((sysctl.kernel_only || sysctl.ctr[0].kernel) && usermode) + || (sysctl.ctr[0].user && !usermode)) + return; lock_rtc(flags); Index: oprofile.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/module/oprofile.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- oprofile.c 2002/01/17 03:21:40 1.34 +++ oprofile.c 2002/01/17 03:54:17 1.35 @@ -86,10 +86,6 @@ if (likely(!need_wakeup(cpu, data))) return; - // FIXME: verify this on 2.2 !!!! - - // FIXME: changes for RTC ? - /* locking rationale : * * other CPUs are not a race concern since we synch on oprof_wait->lock. @@ -112,8 +108,11 @@ * Note that we use oprof_ready as our flag for whether we have initiated a * wake-up. Once the wake-up is received, the flag is reset as well as * data->nextbuf, preventing multiple wakeups. + * + * On 2.2, a global waitqueue_lock is used, so we must check it's not held + * by the current CPU. This is done in a lossy way via spin_trylock() */ - if (likely(regs->eflags & IF_MASK)) { + if (likely(regs->eflags & IF_MASK) && wq_is_lockable()) { oprof_ready[cpu] = 1; wake_up(&oprof_wait); } |