Re: [PATCH V2 2/3] sched/numa: Enhance vma scanning logic

From: Raghavendra K T
Date: Sat Feb 04 2023 - 13:18:53 EST


On 2/3/2023 4:57 PM, Peter Zijlstra wrote:
On Fri, Feb 03, 2023 at 12:15:48PM +0100, Peter Zijlstra wrote:

+static inline void vma_set_active_pid_bit(struct vm_area_struct *vma)
+{
+ unsigned int active_pid_bit;
+
+ if (vma->numab) {
+ active_pid_bit = current->pid % BITS_PER_LONG;
+ vma->numab->accessing_pids |= 1UL << active_pid_bit;
+ }
+}

Perhaps:

if (vma->numab)
__set_bit(current->pid % BITS_PER_LONG, &vma->numab->pids);

?

Or maybe even:

bit = current->pid % BITS_PER_LONG;
if (vma->numab && !__test_bit(bit, &vma->numab->pids))
__set_bit(bit, &vma->numab->pids);


The alternative to just taking the low n bits is to use:

hash_32(current->pid, BITS_PER_LONG)

That mixes things up a bit.

Good idea, when we have workloads that creates lesser number of threads
faster, current solution might have been simpler, but with thread creation that happens over period of time hash function mixes and avoids collision. will experiment with this option.