On Mon, 12 Sep 2022 22:39:03 +0800 Dawei Li <set_pte_at@xxxxxxxxxxx> wrote: > Kdamond is implemented as a periodical split-merge pattern, which will > create and destroy regions possibly on high frequency(hundreds or even > thousands of per sec), depending on number of regions and aggregation > period. In that case, kmalloc and kfree could bring considerable overhead > to system, which can be improved by private kmem cache. > A dedicated slab cache should be faster and will also consume less memory, due to better packing into the underlying pages. So I redid the changelog thusly: : Kdamond is implemented as a periodical split-merge pattern, which will : create and destroy regions possibly at high frequency (hundreds or even : thousands of per sec), depending on the number of regions and aggregation : period. In that case, kmalloc and kfree could bring speed and space : overheads, which can be improved by using a private kmem cache. > +static int __init damon_init(void) > +{ > + damon_region_cache = kmem_cache_create("damon_region_cache", sizeof(struct damon_region), Should be able to use just damon_region_cache = KMEM_CACHE(damon_region, 0); here. Please test that and send along a fixup patch?