linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
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 19:02:49 +0200	[thread overview]
Message-ID: <e06f23d9-adcf-4d0a-8ba1-bda6d4b483b1@redhat.com> (raw)
In-Reply-To: <aKCwjCJTEhX4Q6wW@casper.infradead.org>

On 16.08.25 18:23, Matthew Wilcox wrote:
> 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).

I know, we all have our things to complain about. Some about Cc: above 
--, others about the name of error variables :P

$ git grep "int rc" | wc -l
12730
$ git grep "int ret" | wc -l
80386
$ git grep "int error" | wc -l
4349
$ git grep "int err " | wc -l
6117

> 
> It seems to be a particularly IBM derived antipattern ;-)

Careful miser :D

> Some internal style guide, perhaps?

Kernel-internal style guide maybe ;)

> 
>> +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.

Yeah, no strong opinion, this was a 3 minute hack.

-- 
Cheers

David / dhildenb



  reply	other threads:[~2025-08-16 17:02 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
2025-08-16 17:02           ` David Hildenbrand [this message]
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=e06f23d9-adcf-4d0a-8ba1-bda6d4b483b1@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --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=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).