Commit 782f890
committed
mm/slub: free KFENCE objects in slab_free_hook()
When freeing an object that was allocated from KFENCE, we do that in the
slowpath __slab_free(), relying on the fact that KFENCE "slab" cannot be
the cpu slab, so the fastpath has to fallback to the slowpath.
This optimization doesn't help much though, because is_kfence_address()
is checked earlier anyway during the free hook processing or detached
freelist building. Thus we can simplify the code by making the
slab_free_hook() free the KFENCE object immediately, similarly to KASAN
quarantine.
In slab_free_hook() we can place kfence_free() above init processing, as
callers have been making sure to set init to false for KFENCE objects.
This simplifies slab_free(). This places it also above kasan_slab_free()
which is ok as that skips KFENCE objects anyway.
While at it also determine the init value in slab_free_freelist_hook()
outside of the loop.
This change will also make introducing per cpu array caches easier.
Tested-by: Marco Elver <elver@google.com>
Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>1 parent 284f17a commit 782f890
1 file changed
Lines changed: 10 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
2056 | | - | |
| 2056 | + | |
2057 | 2057 | | |
2058 | 2058 | | |
2059 | 2059 | | |
| |||
2071 | 2071 | | |
2072 | 2072 | | |
2073 | 2073 | | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
2074 | 2077 | | |
2075 | 2078 | | |
2076 | 2079 | | |
| |||
2100 | 2103 | | |
2101 | 2104 | | |
2102 | 2105 | | |
| 2106 | + | |
2103 | 2107 | | |
2104 | 2108 | | |
2105 | 2109 | | |
2106 | | - | |
| 2110 | + | |
2107 | 2111 | | |
2108 | 2112 | | |
2109 | 2113 | | |
2110 | 2114 | | |
2111 | 2115 | | |
2112 | 2116 | | |
| 2117 | + | |
| 2118 | + | |
2113 | 2119 | | |
2114 | 2120 | | |
2115 | 2121 | | |
2116 | 2122 | | |
2117 | 2123 | | |
2118 | | - | |
2119 | | - | |
| 2124 | + | |
2120 | 2125 | | |
2121 | 2126 | | |
2122 | 2127 | | |
| |||
4117 | 4122 | | |
4118 | 4123 | | |
4119 | 4124 | | |
4120 | | - | |
4121 | | - | |
4122 | | - | |
4123 | 4125 | | |
4124 | 4126 | | |
4125 | 4127 | | |
| |||
4304 | 4306 | | |
4305 | 4307 | | |
4306 | 4308 | | |
4307 | | - | |
4308 | | - | |
4309 | 4309 | | |
4310 | 4310 | | |
4311 | | - | |
4312 | | - | |
4313 | | - | |
| 4311 | + | |
4314 | 4312 | | |
4315 | 4313 | | |
4316 | 4314 | | |
| |||
0 commit comments