lkml.org 
[lkml]   [2020]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 23/25] mm/unicore32: Use mm_fault_accounting()
    Date
    Use the new mm_fault_accounting() helper for page fault accounting.

    Avoid doing page fault accounting multiple times if the page fault is retried.
    Also, the perf events for page faults will be accounted too when the config has
    CONFIG_PERF_EVENTS defined.

    CC: Guan Xuetao <gxt@pku.edu.cn>
    Signed-off-by: Peter Xu <peterx@redhat.com>
    ---
    arch/unicore32/mm/fault.c | 15 +++++++--------
    1 file changed, 7 insertions(+), 8 deletions(-)

    diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
    index 3022104aa613..240b38e81ed6 100644
    --- a/arch/unicore32/mm/fault.c
    +++ b/arch/unicore32/mm/fault.c
    @@ -201,7 +201,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
    struct task_struct *tsk;
    struct mm_struct *mm;
    int sig, code;
    - vm_fault_t fault;
    + vm_fault_t fault, major = 0;
    unsigned int flags = FAULT_FLAG_DEFAULT;

    tsk = current;
    @@ -245,6 +245,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
    }

    fault = __do_pf(mm, addr, fsr, flags, tsk);
    + major |= fault & VM_FAULT_MAJOR;

    /* If we need to retry but a fatal signal is pending, handle the
    * signal first. We do not need to release the mmap_sem because
    @@ -254,10 +255,6 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
    return 0;

    if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) {
    - if (fault & VM_FAULT_MAJOR)
    - tsk->maj_flt++;
    - else
    - tsk->min_flt++;
    if (fault & VM_FAULT_RETRY) {
    flags |= FAULT_FLAG_TRIED;
    goto retry;
    @@ -267,11 +264,13 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
    up_read(&mm->mmap_sem);

    /*
    - * Handle the "normal" case first - VM_FAULT_MAJOR
    + * Handle the "normal" case first
    */
    - if (likely(!(fault &
    - (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
    + if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP |
    + VM_FAULT_BADACCESS)))) {
    + mm_fault_accounting(tsk, regs, addr, major);
    return 0;
    + }

    /*
    * If we are in kernel mode at this point, we
    --
    2.26.2
    \
     
     \ /
      Last update: 2020-06-16 00:24    [W:3.717 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site