linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Gregory Price <gourry@gourry.net>
To: David Hildenbrand <david@redhat.com>
Cc: Gregory Price <gourry@gourry.net>,
	linux-mm@kvack.org, linux-kernel@kvack.org, osalvador@suse.de,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	akpm@linux-foundation.org
Subject: Re: [PATCH] mm: add build-time option to set hotplug default type
Date: Fri, 20 Dec 2024 11:37:49 -0500	[thread overview]
Message-ID: <Z2WdXY1fvgrDkegw@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <3775fe9c-460e-4b31-9d5c-068a1f685513@redhat.com>

On Fri, Dec 20, 2024 at 05:04:42PM +0100, David Hildenbrand wrote:
> On 20.12.24 15:45, Gregory Price wrote:
> > +extern int memhp_default_type(void);
> > +extern void memhp_set_default_type(int online_type);
> 
> Please call these "default_online_type". Further keep the "mhp" terminology,
> it's more commonly used. We cannot rename the "memhp_default_state"
> parameter name unfortunately.

so
 mhp_default_online_type()
and
 mhp_set_default_online_type()

ack.

> > +config MEMHP_DEFAULT_TYPE
> > +       string
> > +       default "online" if MEMHP_DEFAULT_TYPE_NORMAL
> > +       default "online_movable" if MEMHP_DEFAULT_TYPE_MOVABLE
> > +       default "offline"
> > +
> 
> Could we get rid of CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE and simply have
> all three types as choices? normal/movable/offline?
>

Obviously doable, wasn't sure what the consensus was on changing or
removing build options, So I tried for the least disruptive.

summarizing:

- MEMORY_HOTPLUG_DEFAULT_ONLINE
+ MEMHP_DEFAULT_ONLINE_TYPE_OFFLINE
+ MEMHP_DEFAULT_ONLINE_TYPE_NORMAL
+ MEMHP_DEFAULT_ONLINE_TYPE_MOVABLE
+ MEMHP_DEFAULT_ONLINE_TYPE = (offline|online|movable)

> > +int memhp_default_type(void)
> > +{
> > +	int type;
> > +
> > +	if (mhp_default_online_type >= 0)
> > +		return mhp_default_online_type;
> > +
> > +	type = mhp_online_type_from_str(CONFIG_MEMHP_DEFAULT_TYPE);
> > +	if (type < 0)
> > +		type = MMOP_OFFLINE;
> 
> How could that ever happen?

It shouldn't unless someone does something silly like

MEMHP_DEFAULT_ONLINE_TYPE="i have no idea what i'm doing"

I just tend towards defensive programming.

> It's a bit weird that we are parsing strings
> when we can just decide that at compile-time using IS_ENABLED() etc?
> 

I tried to reuse the existing logic attached to the sysfs entry
controlling the same thing.

I wasn't sure how to deal with the fact that MEMHP_DEFAULT_ONLINE_TYPE
could be one of three values and did not think encoding 
   MMOP_OFFLINE/ONLINE/MOVABLE 
into the config was a good idea.

If you have another suggestion, I'm open


Will do the renames and rip out CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE and
submit a v2.

~Gregory


  reply	other threads:[~2024-12-20 16:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 14:45 Gregory Price
2024-12-20 14:59 ` David Hildenbrand
2024-12-20 15:17   ` Gregory Price
2024-12-20 15:56     ` David Hildenbrand
2024-12-20 16:04 ` David Hildenbrand
2024-12-20 16:37   ` Gregory Price [this message]
2024-12-20 18:25     ` David Hildenbrand
2024-12-20 18:36       ` Gregory Price
2024-12-20 18:25   ` Gregory Price
2024-12-20 18:26     ` 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=Z2WdXY1fvgrDkegw@gourry-fedora-PF4VCD3F \
    --to=gourry@gourry.net \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@kvack.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=rafael@kernel.org \
    /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