[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200618212430.GO76766@xz-x1>
Date: Thu, 18 Jun 2020 17:24:30 -0400
From: Peter Xu <peterx@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Guo Ren <guoren@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Gerald Schaefer <gerald.schaefer@...ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrea Arcangeli <aarcange@...hat.com>,
linux-csky@...r.kernel.org
Subject: Re: [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@...hat.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 = ¤t->maj_flt;
> event_type = PERF_COUNT_SW_PAGE_FAULTS_MAJ;
> } else {
> flt = ¤t->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
Powered by blists - more mailing lists