On 2/3/2023 5:05 PM, Peter Zijlstra wrote:
On Wed, Feb 01, 2023 at 01:32:22PM +0530, Raghavendra K T wrote:
2) Maintain duplicate list of accessing PIDs to keep track of history of access. and switch/reset. use OR operation during iteration
Two lists of PIDs maintained. At regular interval old list is reset and we make current list as old list
At any point of time tracking of PIDs accessing VMA is determined by ORing list1 and list2
accessing_pids_list1 <- current list
accessing_pids_list2 <- old list
( I'm not sure why you think this part of the email doesn't need to be
nicely wrapped at 76 chars.. )
Sorry.. copy pasted from my "idea" notes then word wrap fooled me..
This seems simple enough to me and can be trivially extended to N if
needed.
> The typical implementation would looks something like:
unsigned long pids[N];
unsigned int pid_idx;
set:
unsigned long *pids = numab->pids + pid_idx;
if (!__test_bit(bit, pids))
__set_bit(bit, pids);
test:
unsigned long pids = 0;
for (int i = 0; i < N; i++)
pids |= numab->pids[i];
return __test_bit(bit, &pids);
rotate:
idx = READ_ONCE(numab->pid_idx);
WRITE_ONCE(numab->pid_idx, (idx + 1) % N);
numab->pids[idx] = 0;
Note the actual rotate can be simplified to ^1 for N:=2.
Thanks good idea. This will be very helpful when we want to
differentiate accessing PIDs in more granular way. Perhaps we can go
with N=2 and stick to below simplification of your code above?
something like:
unsigned long pids[2]
// Assume pids[1] has latest detail always
set:
if (!__test_bit(bit, pids[1])
__set_bit(bit, pids[1])
test:
unsigned long pids = pids[0] | pids[1];
return __test_bit(bit, &pids);
rotate:
pids[0] = pids[1];
pids[1] = 0;