continue;
                }
 
-               /* Do not scan the VMA if task has not accessed */
-               if (!vma_is_accessed(vma)) {
-                       trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_PID_INACTIVE);
-                       continue;
-               }
-
-               /*
-                * RESET access PIDs regularly for old VMAs. Resetting after checking
-                * vma for recent access to avoid clearing PID info before access..
-                */
+               /* RESET access PIDs regularly for old VMAs. */
                if (mm->numa_scan_seq &&
                                time_after(jiffies, vma->numab_state->pids_active_reset)) {
                        vma->numab_state->pids_active_reset = vma->numab_state->pids_active_reset +
                        vma->numab_state->pids_active[1] = 0;
                }
 
+               /* Do not scan the VMA if task has not accessed */
+               if (!vma_is_accessed(vma)) {
+                       trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_PID_INACTIVE);
+                       continue;
+               }
+
                do {
                        start = max(start, vma->vm_start);
                        end = ALIGN(start + (pages << PAGE_SHIFT), HPAGE_SIZE);