Re: [PATCH v2 09/11] mm/memcg, swap: store cgroup id in cluster table directly

YoungJun Park
2026-04-18T14:03:24Z

> + if (IS_ENABLED(CONFIG_MEMCG) && !memcg_table) {
> + swap_table_free(table);
> + return -ENOMEM;
> + }

Hi Kairui,

Nit:
(Just a readability nit. purely my preference, feel free to ignore.)
the checks around swap_memcg_table_alloc() reduce to two
equivalent forms of the same memcg success/failure question:

(!IS_ENABLED(CONFIG_MEMCG) || memcg_table) /* success */
(IS_ENABLED(CONFIG_MEMCG) && !memcg_table) /* failure */

A macro for the failure side would let the call sites read as plain
positive/negative:

#define SWAP_MEMCG_TABLE_ALLOC_FAILED(t) \
(IS_ENABLED(CONFIG_MEMCG) && !(t))

SWAP_MEMCG_TABLE_ALLOC_FAILED(memcg_table) /* failure */
!SWAP_MEMCG_TABLE_ALLOC_FAILED(memcg_table) /* success */

Equivalently, the same macro can be expressed by splitting on
CONFIG_MEMCG.

#ifdef CONFIG_MEMCG
#define SWAP_MEMCG_TABLE_ALLOC_FAILED(t) (!(t))
#else
#define SWAP_MEMCG_TABLE_ALLOC_FAILED(t) (0)
#endif

What do you think?

Thanks,
Youngjun Park