Extend the futex2 interface to be numa aware. When FUTEX2_NUMA is specified for a futex, the user value is extended to two words (of the same size). The first is the user value we all know, the second one will be the node to place this futex on. struct futex_numa_32 { u32 val; u32 node; }; When node is set to ~0, WAIT will set it to the current node_id such that WAKE knows where to find it. If userspace corrupts the node value between WAIT and WAKE, the futex will not be found and no wakeup will happen. When FUTEX2_NUMA is not set, the node is simply an extension of the hash, such that traditional futexes are still interleaved over the nodes. This is done to avoid having to have a separate !numa hash-table. [bigeasy: ensure to have at least hashsize of 4 in futex_init(), add pr_info() for size and allocation information. Cast the naddr math to void*]
Showing the changes to include/uapi (1 of 4 files). Show all
Unified · Split
| @@ -74,6 +74,13 @@ · 73 unmodified lines | |||
| 74 | /* do not use */ | 74 | /* do not use */ |
| 75 | #define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */ | 75 | #define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */ |
| 76 | 76 | ||
| 77 | /* | ||
| 78 | * When FUTEX2_NUMA doubles the futex word, the second word is a node value. | ||
| 79 | * The special value -1 indicates no-node. This is the same value as | ||
| 80 | * NUMA_NO_NODE, except that value is not ABI, this is. | ||
| 81 | */ | ||
| 82 | #define FUTEX_NO_NODE (-1) | ||
| 83 | |||
| 77 | /* | 84 | /* |
| 78 | * Max numbers of elements in a futex_waitv array | 85 | * Max numbers of elements in a futex_waitv array |
| 79 | */ | 86 | */ |