linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	cgel.zte@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, chiminghao <chi.minghao@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] mm: Use BUG_ON instead of if condition followed by BUG
Date: Wed, 24 Nov 2021 21:29:11 -0800	[thread overview]
Message-ID: <6e2f8421-b8b7-c8ec-7a2a-646efb134bbe@nvidia.com> (raw)
In-Reply-To: <YZ8Dz/85n1Dogy87@casper.infradead.org>

On 11/24/21 19:32, Matthew Wilcox wrote:
> On Wed, Nov 24, 2021 at 02:45:59PM -0800, John Hubbard wrote:
>> @@ -2201,13 +2201,12 @@ static int __ref try_remove_memory(u64 start, u64 size)
>> */
>> void __remove_memory(u64 start, u64 size)
>> {
>> -
>> +       int ret = try_remove_memory(start, size);
>> /*
>> * trigger BUG() if some memory is not offlined prior to calling this
>> * function
>> */
>> -       if (try_remove_memory(start, size))
>> -               BUG();
>> +       BUG_ON(ret);
>> }
> 
> I'd rather leave it the way it is.  I don't see why the version you
> propose is better.


In isolation, it's *not* better. It's only potentially useful in the
context of "code plus tools". That is to say, if the coccinelle change
request were rejected, then this provides a way forward that is not
worse than the existing code, and also works around the warning.


> 
>> ...and by the way, while going to type that, I immediately stumbled upon
>> another pre-existing case of this sort of thing, in try_remove_memory(),
>> which does this:
>>
>> static int __ref try_remove_memory(u64 start, u64 size)
>> {
>> 	struct vmem_altmap mhp_altmap = {};
>> 	struct vmem_altmap *altmap = NULL;
>> 	unsigned long nr_vmemmap_pages;
>> 	int rc = 0, nid = NUMA_NO_NODE;
>>
>> 	BUG_ON(check_hotplug_memory_range(start, size));
> 
> That needs to be fixed.


Yes it does. :) I pointed it out in hopes that Chiminghao might be inspired
to go find and fix some of these.


thanks,
-- 
John Hubbard
NVIDIA


  reply	other threads:[~2021-11-25  5:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  3:08 cgel.zte
2021-11-24 11:10 ` David Hildenbrand
2021-11-24 13:23 ` Matthew Wilcox
2021-11-24 22:27   ` Andrew Morton
2021-11-24 22:45     ` John Hubbard
2021-11-25  3:32       ` Matthew Wilcox
2021-11-25  5:29         ` John Hubbard [this message]
2021-11-25  0:00   ` Matthew Wilcox
2021-11-27 18:05     ` Julia Lawall

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=6e2f8421-b8b7-c8ec-7a2a-646efb134bbe@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgel.zte@gmail.com \
    --cc=chi.minghao@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    --cc=zealci@zte.com.cn \
    /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