Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'xarray-6.6' of git://git.infradead.org/users/willy/xarray

Pull xarray fixes from Matthew Wilcox:

- Fix a bug encountered by people using bittorrent where they'd get
NULL pointer dereferences on page cache lookups when using XFS

- Two documentation fixes

* tag 'xarray-6.6' of git://git.infradead.org/users/willy/xarray:
idr: fix param name in idr_alloc_cyclic() doc
xarray: Document necessary flag in alloc functions
XArray: Do not return sibling entries from xa_load()

+92 -4
+18
include/linux/xarray.h
··· 856 856 * stores the index into the @id pointer, then stores the entry at 857 857 * that index. A concurrent lookup will not see an uninitialised @id. 858 858 * 859 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 860 + * in xa_init_flags(). 861 + * 859 862 * Context: Any context. Takes and releases the xa_lock. May sleep if 860 863 * the @gfp flags permit. 861 864 * Return: 0 on success, -ENOMEM if memory could not be allocated or ··· 889 886 * stores the index into the @id pointer, then stores the entry at 890 887 * that index. A concurrent lookup will not see an uninitialised @id. 891 888 * 889 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 890 + * in xa_init_flags(). 891 + * 892 892 * Context: Any context. Takes and releases the xa_lock while 893 893 * disabling softirqs. May sleep if the @gfp flags permit. 894 894 * Return: 0 on success, -ENOMEM if memory could not be allocated or ··· 921 915 * Finds an empty entry in @xa between @limit.min and @limit.max, 922 916 * stores the index into the @id pointer, then stores the entry at 923 917 * that index. A concurrent lookup will not see an uninitialised @id. 918 + * 919 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 920 + * in xa_init_flags(). 924 921 * 925 922 * Context: Process context. Takes and releases the xa_lock while 926 923 * disabling interrupts. May sleep if the @gfp flags permit. ··· 957 948 * that index. A concurrent lookup will not see an uninitialised @id. 958 949 * The search for an empty entry will start at @next and will wrap 959 950 * around if necessary. 951 + * 952 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 953 + * in xa_init_flags(). 960 954 * 961 955 * Context: Any context. Takes and releases the xa_lock. May sleep if 962 956 * the @gfp flags permit. ··· 995 983 * The search for an empty entry will start at @next and will wrap 996 984 * around if necessary. 997 985 * 986 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 987 + * in xa_init_flags(). 988 + * 998 989 * Context: Any context. Takes and releases the xa_lock while 999 990 * disabling softirqs. May sleep if the @gfp flags permit. 1000 991 * Return: 0 if the allocation succeeded without wrapping. 1 if the ··· 1031 1016 * that index. A concurrent lookup will not see an uninitialised @id. 1032 1017 * The search for an empty entry will start at @next and will wrap 1033 1018 * around if necessary. 1019 + * 1020 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 1021 + * in xa_init_flags(). 1034 1022 * 1035 1023 * Context: Process context. Takes and releases the xa_lock while 1036 1024 * disabling interrupts. May sleep if the @gfp flags permit.
+1 -1
lib/idr.c
··· 100 100 * @end: The maximum ID (exclusive). 101 101 * @gfp: Memory allocation flags. 102 102 * 103 - * Allocates an unused ID in the range specified by @nextid and @end. If 103 + * Allocates an unused ID in the range specified by @start and @end. If 104 104 * @end is <= 0, it is treated as one larger than %INT_MAX. This allows 105 105 * callers to use @start + N as @end as long as N is within integer range. 106 106 * The search for an unused ID will start at the last ID allocated and will
+7 -1
lib/xarray.c
··· 206 206 void *entry = xa_entry(xas->xa, node, offset); 207 207 208 208 xas->xa_node = node; 209 - if (xa_is_sibling(entry)) { 209 + while (xa_is_sibling(entry)) { 210 210 offset = xa_to_sibling(entry); 211 211 entry = xa_entry(xas->xa, node, offset); 212 212 if (node->shift && xa_is_node(entry)) ··· 1802 1802 * stores the index into the @id pointer, then stores the entry at 1803 1803 * that index. A concurrent lookup will not see an uninitialised @id. 1804 1804 * 1805 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 1806 + * in xa_init_flags(). 1807 + * 1805 1808 * Context: Any context. Expects xa_lock to be held on entry. May 1806 1809 * release and reacquire xa_lock if @gfp flags permit. 1807 1810 * Return: 0 on success, -ENOMEM if memory could not be allocated or ··· 1852 1849 * that index. A concurrent lookup will not see an uninitialised @id. 1853 1850 * The search for an empty entry will start at @next and will wrap 1854 1851 * around if necessary. 1852 + * 1853 + * Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set 1854 + * in xa_init_flags(). 1855 1855 * 1856 1856 * Context: Any context. Expects xa_lock to be held on entry. May 1857 1857 * release and reacquire xa_lock if @gfp flags permit.
+66 -2
tools/testing/radix-tree/multiorder.c
··· 159 159 item_kill_tree(xa); 160 160 } 161 161 162 - bool stop_iteration = false; 162 + bool stop_iteration; 163 163 164 164 static void *creator_func(void *ptr) 165 165 { ··· 201 201 pthread_t worker_thread[num_threads]; 202 202 int i; 203 203 204 + stop_iteration = false; 204 205 pthread_create(&worker_thread[0], NULL, &creator_func, xa); 205 206 for (i = 1; i < num_threads; i++) 206 207 pthread_create(&worker_thread[i], NULL, &iterator_func, xa); 208 + 209 + for (i = 0; i < num_threads; i++) 210 + pthread_join(worker_thread[i], NULL); 211 + 212 + item_kill_tree(xa); 213 + } 214 + 215 + static void *load_creator(void *ptr) 216 + { 217 + /* 'order' is set up to ensure we have sibling entries */ 218 + unsigned int order; 219 + struct radix_tree_root *tree = ptr; 220 + int i; 221 + 222 + rcu_register_thread(); 223 + item_insert_order(tree, 3 << RADIX_TREE_MAP_SHIFT, 0); 224 + item_insert_order(tree, 2 << RADIX_TREE_MAP_SHIFT, 0); 225 + for (i = 0; i < 10000; i++) { 226 + for (order = 1; order < RADIX_TREE_MAP_SHIFT; order++) { 227 + unsigned long index = (3 << RADIX_TREE_MAP_SHIFT) - 228 + (1 << order); 229 + item_insert_order(tree, index, order); 230 + item_delete_rcu(tree, index); 231 + } 232 + } 233 + rcu_unregister_thread(); 234 + 235 + stop_iteration = true; 236 + return NULL; 237 + } 238 + 239 + static void *load_worker(void *ptr) 240 + { 241 + unsigned long index = (3 << RADIX_TREE_MAP_SHIFT) - 1; 242 + 243 + rcu_register_thread(); 244 + while (!stop_iteration) { 245 + struct item *item = xa_load(ptr, index); 246 + assert(!xa_is_internal(item)); 247 + } 248 + rcu_unregister_thread(); 249 + 250 + return NULL; 251 + } 252 + 253 + static void load_race(struct xarray *xa) 254 + { 255 + const int num_threads = sysconf(_SC_NPROCESSORS_ONLN) * 4; 256 + pthread_t worker_thread[num_threads]; 257 + int i; 258 + 259 + stop_iteration = false; 260 + pthread_create(&worker_thread[0], NULL, &load_creator, xa); 261 + for (i = 1; i < num_threads; i++) 262 + pthread_create(&worker_thread[i], NULL, &load_worker, xa); 207 263 208 264 for (i = 0; i < num_threads; i++) 209 265 pthread_join(worker_thread[i], NULL); ··· 274 218 multiorder_iteration(&array); 275 219 multiorder_tagged_iteration(&array); 276 220 multiorder_iteration_race(&array); 221 + load_race(&array); 277 222 278 223 radix_tree_cpu_dead(0); 279 224 } 280 225 281 - int __weak main(void) 226 + int __weak main(int argc, char **argv) 282 227 { 228 + int opt; 229 + 230 + while ((opt = getopt(argc, argv, "ls:v")) != -1) { 231 + if (opt == 'v') 232 + test_verbose++; 233 + } 234 + 283 235 rcu_register_thread(); 284 236 radix_tree_init(); 285 237 multiorder_checks();