--- zzzz-none-000/linux-2.6.28.10/arch/mips/mm/fault.c 2009-05-02 18:54:43.000000000 +0000 +++ puma5-6360-529/linux-2.6.28.10/arch/mips/mm/fault.c 2011-04-04 13:20:30.000000000 +0000 @@ -7,6 +7,7 @@ */ #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include /* For unblank_screen() */ #include +#include #include #include @@ -41,8 +43,10 @@ siginfo_t info; int fault; + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->cp0_epc, 0x1000); + current->pg_faults++; #if 0 - printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", raw_smp_processor_id(), + printk(KERN_INFO "Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", raw_smp_processor_id(), current->comm, current->pid, field, address, write, field, regs->cp0_epc); #endif @@ -103,6 +107,7 @@ * make sure we exit gracefully rather than endlessly redo * the fault. */ + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1001); fault = handle_mm_fault(mm, vma, address, write); if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) @@ -117,6 +122,8 @@ tsk->min_flt++; up_read(&mm->mmap_sem); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1001); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); return; /* @@ -129,10 +136,11 @@ bad_area_nosemaphore: /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->cp0_epc, 0x1002); tsk->thread.cp0_badvaddr = address; tsk->thread.error_code = write; -#if 0 - printk("do_page_fault() #2: sending SIGSEGV to %s for " +#if 1 + printk(KERN_INFO "do_page_fault() #2: sending SIGSEGV to %s for " "invalid %s\n%0*lx (epc == %0*lx, ra == %0*lx)\n", tsk->comm, write ? "write access to" : "read access from", @@ -145,13 +153,18 @@ /* info.si_code has been set above */ info.si_addr = (void __user *) address; force_sig_info(SIGSEGV, &info, tsk); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1002); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); return; } no_context: /* Are we prepared to handle this kernel fault? */ if (fixup_exception(regs)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->cp0_epc, 0x1003); current->thread.cp0_baduaddr = address; + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1003); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); return; } @@ -166,6 +179,7 @@ raw_smp_processor_id(), field, address, field, regs->cp0_epc, field, regs->regs[31]); die("Oops", regs); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); /* * We ran out of memory, or some other thing happened to us that made @@ -184,18 +198,20 @@ goto no_context; do_sigbus: + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->cp0_epc, 0x1004); up_read(&mm->mmap_sem); /* Kernel mode? Handle exceptions or die */ - if (!user_mode(regs)) + if (!user_mode(regs)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1004); goto no_context; - else + } else { /* * Send a sigbus, regardless of whether we were in kernel * or user mode. */ -#if 0 - printk("do_page_fault() #3: sending SIGBUS to %s for " +#if 1 + printk(KERN_INFO "do_page_fault() #3: sending SIGBUS to %s for " "invalid %s\n%0*lx (epc == %0*lx, ra == %0*lx)\n", tsk->comm, write ? "write access to" : "read access from", @@ -203,6 +219,7 @@ field, (unsigned long) regs->cp0_epc, field, (unsigned long) regs->regs[31]); #endif + } tsk->thread.cp0_badvaddr = address; info.si_signo = SIGBUS; info.si_errno = 0; @@ -210,6 +227,8 @@ info.si_addr = (void __user *) address; force_sig_info(SIGBUS, &info, tsk); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1004); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); return; vmalloc_fault: { @@ -225,28 +244,40 @@ pud_t *pud, *pud_k; pmd_t *pmd, *pmd_k; pte_t *pte_k; + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->cp0_epc, 0x1005); pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset; pgd_k = init_mm.pgd + offset; - if (!pgd_present(*pgd_k)) + if (!pgd_present(*pgd_k)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1005); goto no_context; + } set_pgd(pgd, *pgd_k); pud = pud_offset(pgd, address); pud_k = pud_offset(pgd_k, address); - if (!pud_present(*pud_k)) - goto no_context; + if (!pud_present(*pud_k)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1005); + goto no_context; + } pmd = pmd_offset(pud, address); pmd_k = pmd_offset(pud_k, address); - if (!pmd_present(*pmd_k)) + if (!pmd_present(*pmd_k)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1005); goto no_context; + } set_pmd(pmd, *pmd_k); pte_k = pte_offset_kernel(pmd_k, address); - if (!pte_present(*pte_k)) + if (!pte_present(*pte_k)) { + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1005); goto no_context; + } + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1005); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); return; } + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, 0x1000); }