lkml.org 
[lkml]   [2020]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 07/25] mm/csky: Use mm_fault_accounting()
On Thu, Jun 18, 2020 at 10:15:50AM -0700, Linus Torvalds wrote:
> On Thu, Jun 18, 2020 at 7:38 AM Peter Xu <peterx@redhat.com> wrote:
> >
> > GUP needs the per-task accounting, but not the perf events. We can do that by
> > slightly changing the new approach into:
> >
> > bool major = (ret & VM_FAULT_MAJOR) || (flags & FAULT_FLAG_TRIED);
> >
> > if (major)
> > current->maj_flt++;
> > else
> > current->min_flt++;
> >
> > if (!regs)
> > return ret;
> >
> > if (major)
> > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
> > else
> > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
>
> Ack, I think this is the right thing to do.
>
> No normal situation will ever notice the difference, with remote
> accesses being as rare and specialized as they are. But being able to
> remote the otherwise unused 'tsk' parameter sounds like the right
> thing to do too.
>
> It might be worth adding a comment about why.
>
> Also, honestly, how about we remove the 'major' variable entirely, and
> instead make the code be something like
>
> unsigned long *flt;
> int event_type;
> ...
>
> /* Major fault */
> if ((ret & VM_FAULT_MAJOR) || (flags & FAULT_FLAG_TRIED)) {
> flt = &current->maj_flt;
> event_type = PERF_COUNT_SW_PAGE_FAULTS_MAJ;
> } else {
> flt = &current->min_flt;
> event_type = PERF_COUNT_SW_PAGE_FAULTS_MIN;
> }
> *flt++;
> if (regs)
> perf_sw_event(event_type, 1, regs, address);
>
> instead. Less source code duplication, and I bet it improves code
> generation too.

Will do. Thanks!

--
Peter Xu

\
 
 \ /
  Last update: 2020-06-18 23:24    [W:0.086 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site