allocate page caches pages in round robin fasion
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Jesse Barnes
On a NUMA machine, page cache pages should be spread out across the system since they're generally global in nature and can eat up whole nodes worth of memory otherwise. This can end up hurting performance since jobs will have to make off node references for much or all of their non-file data.
The patch works by adding an
alloc_page_round_robinroutine that simply allocates on successive nodes each time its called, based on the value of a per-cpu variable modulo the number of nodes. The variable is per-cpu to avoid cacheline contention when many cpus try to do page cache allocations at
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
-Andi
Quoted 5 lines · Jesse Barnes
Quoted 5 lines
The patch works by adding an
alloc_page_round_robinroutine that simply allocates on successive nodes each time its called, based on the value of a per-cpu variable modulo the number of nodes. The variable is per-cpu to avoid cacheline contention when many cpus try to do page cache allocations at
Quoted 6 lines · Andi Kleen
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
If we're going to go that far, why not use a better coloring algorithm? IIRC linear_page_index(vma, vaddr) % MAX_NR_NODES has issues with various semiregular access patterns where others do not (most are relatively simple hash functions). This reminds me that getting the vma and vaddr accessible to the allocator helps with normal page coloring.
-- wli
Quoted 13 lines · Andi Kleen
Quoted 11 lines · Jesse Barnes
On a NUMA machine, page cache pages should be spread out across the system since they're generally global in nature and can eat up whole nodes worth of memory otherwise. This can end up hurting performance since jobs will have to make off node references for much or all of their non-file data.
The patch works by adding an
alloc_page_round_robinroutine that simply allocates on successive nodes each time its called, based on the value of a per-cpu variable modulo the number of nodes. The variable is per-cpu to avoid cacheline contention when many cpus try to do page cache allocations at
Quoted 6 lines
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
Well, that's one reason I didn't add an alloc_pages routine, but just a single page distributor. However, a multipage round robin routine would be useful in other cases, like for the slab allocator.
Jesse
Quoted 6 lines · Andi Kleen
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
That sounds like a good approach, care to show me exactly what you mean with a patch? :)
Thanks,
Jesse
Quoted 11 lines · Jesse Barnes
Quoted 6 lines · Andi Kleen
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
That sounds like a good approach, care to show me exactly what you mean with a
patch? :)
Make sure to have some sort of offset for the static interleaving that is random or semi-random for each inode, as we discussed on linux-mm last week. Otherwise you'll end up with pages for small files clustered on a few nodes, as the offset into the inode will never exceed some small value.
And even though I know Andi doesn't care for a dynamic counter, this last week I implemented a new MPOL_ROUNDROBIN using just such a counter. The only significant difference from MPOL_INTERLEAVE is the use of a per-task dynamic counter rather than an index based on offsets into a vma and/or inode. It seems to work quite well in my testing. My next step was going to be using this policy for tmpfs file allocations by default (overridable by mbind()). Does anyone think this idea has merit? If so I'll clean up the MPOL_ROUNDROBiN patch and post it, then follow it by a tmpfs patch sometime soon (I'm just beginning work on it).
Thanks,
Brent
Signature · 3 lines
Brent Casavant [email protected] Forget bright-eyed and Operating System Engineer http://www.sgi.com/ bushy-tailed; I'm red- Silicon Graphics, Inc. 44.8562N 93.1355W 860F eyed and bushy-haired.
Quoted 10 lines · Brent Casavant
Quoted 8 lines · Jesse Barnes
Quoted 6 lines · Andi Kleen
I don't like this approach using a dynamic counter. I think it would be better to add a new function that takes the vma and uses the offset into the inode for static interleaving (anonymous memory would still use the vma offset). This way you would have a good guarantee that the interleaving stays interleaved even when the system swaps pages in and out and you're less likely to get anomalies in the page distribution.
Quoted 3 lines
Quoted 3 lines
That sounds like a good approach, care to show me exactly what you mean with a
patch? :)
I put it on my todo list.
Quoted 3 lines
Make sure to have some sort of offset for the static interleaving that is random or semi-random for each inode, as we discussed on linux-mm last
inode number (possible with some bits of dev_t, although that is probably not needed)
-Andi