Re: [PATCH] mm/migrate: Fix NULL movable_ops if CONFIG_ZSMALLOC=m

From: Matthew Wilcox
Date: Sat Aug 16 2025 - 12:24:02 EST


On Sat, Aug 16, 2025 at 12:54:52PM +0200, David Hildenbrand wrote:
> +++ b/mm/balloon_compaction.c
> @@ -256,8 +256,10 @@ const struct movable_operations balloon_mops = {
> static int __init balloon_init(void)
> {
> - movable_ops[MOVABLE_BALLOON] = &balloon_mops;
> - return 0;
> + int rc;
> +
> + rc = register_movable_ops(&balloon_mops, PGTY_offline);
> + return rc;

Using 'rc' as the name of this variable is an anti-pattern. All it
tells you is "this is the return value". Calling it 'err' is far
better because now we know it's an error number (or zero for success,
of course).

It seems to be a particularly IBM derived antipattern ;-)
Some internal style guide, perhaps?

> +void unregister_movable_ops(const struct movable_operations *ops, enum pagetype type)
> +{
> + switch (type) {
> + case PGTY_offline:
> + WARN_ON_ONCE(offline_movable_ops != ops);
> + offline_movable_ops = NULL;
> + break;
> + case PGTY_zsmalloc:
> + WARN_ON_ONCE(zsmalloc_movable_ops != ops);
> + zsmalloc_movable_ops = NULL;
> + break;

This might be a bit excessive ... just passing the pagetype and not
having the sanity checks should be enough for the tiny number of users
this interface will have.