Commit 062eacf
mm: vmalloc: remove a global vmap_blocks xarray
A global vmap_blocks-xarray array can be contented under heavy usage of
the vm_map_ram()/vm_unmap_ram() APIs. The lock_stat shows that a
"vmap_blocks.xa_lock" lock is a second in a top-list when it comes to
contentions:
<snip>
----------------------------------------
class name con-bounces contentions ...
----------------------------------------
vmap_area_lock: 2554079 2554276 ...
--------------
vmap_area_lock 1297948 [<00000000dd41cbaa>] alloc_vmap_area+0x1c7/0x910
vmap_area_lock 1256330 [<000000009d927bf3>] free_vmap_block+0x4a/0xe0
vmap_area_lock 1 [<00000000c95c05a7>] find_vm_area+0x16/0x70
--------------
vmap_area_lock 1738590 [<00000000dd41cbaa>] alloc_vmap_area+0x1c7/0x910
vmap_area_lock 815688 [<000000009d927bf3>] free_vmap_block+0x4a/0xe0
vmap_area_lock 1 [<00000000c1d619d7>] __get_vm_area_node+0xd2/0x170
vmap_blocks.xa_lock: 862689 862698 ...
-------------------
vmap_blocks.xa_lock 378418 [<00000000625a5626>] vm_map_ram+0x359/0x4a0
vmap_blocks.xa_lock 484280 [<00000000caa2ef03>] xa_erase+0xe/0x30
-------------------
vmap_blocks.xa_lock 576226 [<00000000caa2ef03>] xa_erase+0xe/0x30
vmap_blocks.xa_lock 286472 [<00000000625a5626>] vm_map_ram+0x359/0x4a0
...
<snip>
that is a result of running vm_map_ram()/vm_unmap_ram() in
a loop. The test creates 64(on 64 CPUs system) threads and
each one maps/unmaps 1 page.
After this change the "xa_lock" can be considered as a noise
in the same test condition:
<snip>
...
&xa->xa_lock#1: 10333 10394 ...
--------------
&xa->xa_lock#1 5349 [<00000000bbbc9751>] xa_erase+0xe/0x30
&xa->xa_lock#1 5045 [<0000000018def45d>] vm_map_ram+0x3a4/0x4f0
--------------
&xa->xa_lock#1 7326 [<0000000018def45d>] vm_map_ram+0x3a4/0x4f0
&xa->xa_lock#1 3068 [<00000000bbbc9751>] xa_erase+0xe/0x30
...
<snip>
Running the test_vmalloc.sh run_test_mask=1024 nr_threads=64 nr_pages=5
shows around ~8 percent of throughput improvement of vm_map_ram() and
vm_unmap_ram() APIs.
This patch does not fix vmap_area_lock/free_vmap_area_lock and
purge_vmap_area_lock bottle-necks, it is rather a separate rework.
Link: https://lkml.kernel.org/r/20230330190639.431589-1-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
Reviewed-by: Baoquan He <bhe@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 62f31bd commit 062eacf
1 file changed
+63
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1915 | 1915 | | |
1916 | 1916 | | |
1917 | 1917 | | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
1918 | 1925 | | |
1919 | 1926 | | |
1920 | 1927 | | |
| |||
1932 | 1939 | | |
1933 | 1940 | | |
1934 | 1941 | | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
1938 | 1976 | | |
1939 | | - | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
1940 | 1984 | | |
1941 | 1985 | | |
1942 | 1986 | | |
| |||
1974 | 2018 | | |
1975 | 2019 | | |
1976 | 2020 | | |
| 2021 | + | |
1977 | 2022 | | |
1978 | 2023 | | |
1979 | 2024 | | |
| |||
2007 | 2052 | | |
2008 | 2053 | | |
2009 | 2054 | | |
| 2055 | + | |
2010 | 2056 | | |
2011 | | - | |
| 2057 | + | |
2012 | 2058 | | |
2013 | 2059 | | |
2014 | 2060 | | |
| |||
2026 | 2072 | | |
2027 | 2073 | | |
2028 | 2074 | | |
| 2075 | + | |
2029 | 2076 | | |
2030 | | - | |
| 2077 | + | |
| 2078 | + | |
2031 | 2079 | | |
2032 | 2080 | | |
2033 | 2081 | | |
| |||
2139 | 2187 | | |
2140 | 2188 | | |
2141 | 2189 | | |
| 2190 | + | |
2142 | 2191 | | |
2143 | 2192 | | |
2144 | 2193 | | |
| |||
2147 | 2196 | | |
2148 | 2197 | | |
2149 | 2198 | | |
2150 | | - | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
2151 | 2203 | | |
2152 | 2204 | | |
2153 | 2205 | | |
| |||
3525 | 3577 | | |
3526 | 3578 | | |
3527 | 3579 | | |
| 3580 | + | |
3528 | 3581 | | |
3529 | 3582 | | |
3530 | 3583 | | |
| |||
3543 | 3596 | | |
3544 | 3597 | | |
3545 | 3598 | | |
3546 | | - | |
| 3599 | + | |
| 3600 | + | |
3547 | 3601 | | |
3548 | 3602 | | |
3549 | 3603 | | |
| |||
4337 | 4391 | | |
4338 | 4392 | | |
4339 | 4393 | | |
| 4394 | + | |
4340 | 4395 | | |
4341 | 4396 | | |
4342 | 4397 | | |
| |||
0 commit comments