On Thu, Jun 18, 2020 at 7:38 AM Peter Xu <peterx@xxxxxxxxxx> 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. Linus