[PATCH v3 3/5] nvme: add the NVME_ENABLE_MULTIPATH_PARAM config option
Caleb Sander Mateos
csander at purestorage.com
Mon Mar 31 16:55:50 PDT 2025
On Mon, Mar 31, 2025 at 7:29 AM John Meneghini <jmeneghi at redhat.com> wrote:
>
> On 3/28/25 3:49 PM, Caleb Sander Mateos wrote:
> >> bool multipath = true;
> >> +#ifdef CONFIG_NVME_ENABLE_MULTIPATH_PARAM
> >> module_param(multipath, bool, 0444);
> >> MODULE_PARM_DESC(multipath,
> >> "turn on native support for multiple controllers per subsystem");
> >> +#endif
> > If CONFIG_NVME_ENABLE_MULTIPATH_PARAM is disabled, could you #define
> > multipath false in place of the global variable? That would allow the
> > compiler to optimize out the multipath checks and the resulting dead
> > code.
>
> If we #define multipath to be false that would permanently disable the multipath code
> when CONFIG_NVME_ENABLE_MULTIPATH_PARAM=n, and this is not what we want. The purpose
> of CONFIG_NVME_ENABLE_MULTIPATH_PARAM=n is to simply remove the core_nvme.multipath
> parameter from the kernel so the user no longer has the ability to change
> the bool multipath variable. We want multipath to be true.
Sorry, I just meant to #define multipath to a constant. I mixed up the
boolean value. If CONFIG_NVME_MULTIPATH is set, of course it should be
true, not false. If CONFIG_NVME_MULTIPATH is not set, multipath is
already defined as false.
My point was just that the compiler will pessimistically assume a
global variable with extern visibility could be written from some
other translation unit at any time. But
CONFIG_NVME_ENABLE_MULTIPATH_PARAM removes the only way for the global
variable to change at runtime, so it can just be a constant.
Best,
Caleb
More information about the Linux-nvme
mailing list