All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: David Hildenbrand <david@redhat.com>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Zi Yan <ziy@nvidia.com>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Harry Yoo <harry.yoo@oracle.com>,
	linux-kernel@vger.kernel.org, Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] mm/migrate: Fix NULL movable_ops if CONFIG_ZSMALLOC=m
Date: Sat, 16 Aug 2025 17:23:40 +0100	[thread overview]
Message-ID: <aKCwjCJTEhX4Q6wW@casper.infradead.org> (raw)
In-Reply-To: <9db98f7f-b90f-464b-ae7f-e94ac523bc28@redhat.com>

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.



  reply	other threads:[~2025-08-16 16:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15  9:05 [PATCH] mm/migrate: Fix NULL movable_ops if CONFIG_ZSMALLOC=m Huacai Chen
2025-08-15 20:57 ` Zi Yan
2025-08-16  0:57 ` kernel test robot
2025-08-16  7:22 ` David Hildenbrand
2025-08-16  8:57   ` Huacai Chen
2025-08-16  9:01     ` David Hildenbrand
2025-08-16 10:54       ` David Hildenbrand
2025-08-16 16:23         ` Matthew Wilcox [this message]
2025-08-16 17:02           ` David Hildenbrand
2025-08-16 17:04             ` David Hildenbrand
2025-08-17  1:37             ` Huacai Chen
2025-08-17  8:04               ` David Hildenbrand
2025-08-17  8:34                 ` Huacai Chen
2025-08-16 17:13         ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aKCwjCJTEhX4Q6wW@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=david@redhat.com \
    --cc=harry.yoo@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=minchan@kernel.org \
    --cc=mst@redhat.com \
    --cc=senozhatsky@chromium.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.