Re: linux-next: manual merge of the slab tree with the mm tree

From: Catalin Marinas
Date: Mon Jun 19 2023 - 08:16:50 EST


On Mon, Jun 19, 2023 at 02:03:30PM +1000, Stephen Rothwell wrote:
> diff --cc mm/slab_common.c
> index 43c008165f56,90ecaface410..000000000000
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@@ -892,24 -876,17 +890,24 @@@ new_kmalloc_cache(int idx, enum kmalloc
> flags |= SLAB_CACHE_DMA;
> }
>
> + if (minalign > ARCH_KMALLOC_MINALIGN) {
> + aligned_size = ALIGN(aligned_size, minalign);
> + aligned_idx = __kmalloc_index(aligned_size, false);
> + }
> +
> + /*
> + * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for
> + * KMALLOC_NORMAL caches.
> + */
> + if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL))
> + flags |= SLAB_NO_MERGE;
> +
> - kmalloc_caches[type][idx] = create_kmalloc_cache(
> - kmalloc_info[idx].name[type],
> - kmalloc_info[idx].size, flags, 0,
> - kmalloc_info[idx].size);
> + if (!kmalloc_caches[type][aligned_idx])
> + kmalloc_caches[type][aligned_idx] = create_kmalloc_cache(
> + kmalloc_info[aligned_idx].name[type],
> + aligned_size, flags);
> + if (idx != aligned_idx)
> + kmalloc_caches[type][idx] = kmalloc_caches[type][aligned_idx];
> -
> - /*
> - * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for
> - * KMALLOC_NORMAL caches.
> - */
> - if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL))
> - kmalloc_caches[type][idx]->refcount = -1;
> }
>
> /*

Thanks Stephen. The resolution looks fine to me.

--
Catalin