--- zzzz-none-000/linux-2.6.28.10/arch/mips/mm/fault.c 2009-05-02 18:54:43.000000000 +0000 +++ fusiv-7390-686/linux-2.6.28.10/arch/mips/mm/fault.c 2014-01-08 16:27:17.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 @@ -25,6 +27,12 @@ #include #include #include /* For VMALLOC_END */ +#if defined(CONFIG_AVM_POWER) +#include +#endif/*--- #if defined(CONFIG_AVM_SPOWERIMPLE_PROFILING) ---*/ +#if defined(CONFIG_AVM_SIMPLE_PROFILING) +#include +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ /* * This routine handles page faults. It determines the address, @@ -41,8 +49,12 @@ siginfo_t info; int fault; +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_enter_irqcontext((unsigned int)regs->cp0_epc); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ + 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,7 +115,19 @@ * make sure we exit gracefully rather than endlessly redo * the fault. */ +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, (unsigned int)regs->cp0_epc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_get(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ fault = handle_mm_fault(mm, vma, address, write); +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_put(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, (unsigned int)regs->cp0_epc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) goto out_of_memory; @@ -131,8 +155,8 @@ if (user_mode(regs)) { 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", @@ -187,15 +211,15 @@ up_read(&mm->mmap_sem); /* Kernel mode? Handle exceptions or die */ - if (!user_mode(regs)) + if (!user_mode(regs)) { 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 +227,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; @@ -229,24 +254,28 @@ 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)) { 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)) { + 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)) { 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)) { goto no_context; + } return; } }