Commit 284f17a
committed
mm/slub: handle bulk and single object freeing separately
Currently we have a single function slab_free() handling both single
object freeing and bulk freeing with necessary hooks, the latter case
requiring slab_free_freelist_hook(). It should be however better to
distinguish the two use cases for the following reasons:
- code simpler to follow for the single object case
- better code generation - although inlining should eliminate the
slab_free_freelist_hook() for single object freeing in case no
debugging options are enabled, it seems it's not perfect. When e.g.
KASAN is enabled, we're imposing additional unnecessary overhead for
single object freeing.
- preparation to add percpu array caches in near future
Therefore, simplify slab_free() for the single object case by dropping
unnecessary parameters and calling only slab_free_hook() instead of
slab_free_freelist_hook(). Rename the bulk variant to slab_free_bulk()
and adjust callers accordingly.
While at it, flip (and document) slab_free_hook() return value so that
it returns true when the freeing can proceed, which matches the logic of
slab_free_freelist_hook() and is not confusingly the opposite.
Additionally we can simplify a bit by changing the tail parameter of
do_slab_free() when freeing a single object - instead of NULL we can set
it equal to head.
bloat-o-meter shows small code reduction with a .config that has KASAN
etc disabled:
add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-118 (-118)
Function old new delta
kmem_cache_alloc_bulk 1203 1196 -7
kmem_cache_free 861 835 -26
__kmem_cache_free 741 704 -37
kmem_cache_free_bulk 911 863 -48
Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>1 parent 520a688 commit 284f17a
1 file changed
Lines changed: 35 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
2054 | 2057 | | |
2055 | | - | |
2056 | | - | |
| 2058 | + | |
| 2059 | + | |
2057 | 2060 | | |
2058 | 2061 | | |
2059 | 2062 | | |
| |||
2086 | 2089 | | |
2087 | 2090 | | |
2088 | 2091 | | |
2089 | | - | |
| 2092 | + | |
2090 | 2093 | | |
2091 | 2094 | | |
2092 | 2095 | | |
| |||
2096 | 2099 | | |
2097 | 2100 | | |
2098 | 2101 | | |
2099 | | - | |
| 2102 | + | |
2100 | 2103 | | |
2101 | 2104 | | |
2102 | 2105 | | |
| |||
2112 | 2115 | | |
2113 | 2116 | | |
2114 | 2117 | | |
2115 | | - | |
2116 | | - | |
| 2118 | + | |
| 2119 | + | |
2117 | 2120 | | |
2118 | 2121 | | |
2119 | 2122 | | |
| |||
2128 | 2131 | | |
2129 | 2132 | | |
2130 | 2133 | | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | 2134 | | |
2135 | 2135 | | |
2136 | 2136 | | |
| |||
4241 | 4241 | | |
4242 | 4242 | | |
4243 | 4243 | | |
4244 | | - | |
4245 | 4244 | | |
4246 | 4245 | | |
4247 | 4246 | | |
| |||
4260 | 4259 | | |
4261 | 4260 | | |
4262 | 4261 | | |
4263 | | - | |
| 4262 | + | |
4264 | 4263 | | |
4265 | 4264 | | |
4266 | 4265 | | |
4267 | 4266 | | |
4268 | 4267 | | |
4269 | 4268 | | |
4270 | | - | |
| 4269 | + | |
4271 | 4270 | | |
4272 | 4271 | | |
4273 | 4272 | | |
| |||
4284 | 4283 | | |
4285 | 4284 | | |
4286 | 4285 | | |
4287 | | - | |
| 4286 | + | |
4288 | 4287 | | |
4289 | 4288 | | |
4290 | 4289 | | |
| |||
4297 | 4296 | | |
4298 | 4297 | | |
4299 | 4298 | | |
4300 | | - | |
4301 | | - | |
4302 | | - | |
| 4299 | + | |
4303 | 4300 | | |
4304 | 4301 | | |
4305 | 4302 | | |
4306 | | - | |
4307 | | - | |
4308 | | - | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
4309 | 4320 | | |
4310 | 4321 | | |
4311 | 4322 | | |
| |||
4319 | 4330 | | |
4320 | 4331 | | |
4321 | 4332 | | |
4322 | | - | |
| 4333 | + | |
4323 | 4334 | | |
4324 | 4335 | | |
4325 | 4336 | | |
| |||
4363 | 4374 | | |
4364 | 4375 | | |
4365 | 4376 | | |
4366 | | - | |
| 4377 | + | |
4367 | 4378 | | |
4368 | 4379 | | |
4369 | 4380 | | |
| |||
4409 | 4420 | | |
4410 | 4421 | | |
4411 | 4422 | | |
4412 | | - | |
| 4423 | + | |
4413 | 4424 | | |
4414 | 4425 | | |
4415 | 4426 | | |
| |||
4526 | 4537 | | |
4527 | 4538 | | |
4528 | 4539 | | |
4529 | | - | |
4530 | | - | |
| 4540 | + | |
| 4541 | + | |
4531 | 4542 | | |
4532 | 4543 | | |
4533 | 4544 | | |
| |||
0 commit comments