lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 15 Nov 2023 10:11:36 +0000
From:   "Russell King (Oracle)" <linux@...linux.org.uk>
To:     Gavin Shan <gshan@...hat.com>
Cc:     linux-pm@...r.kernel.org, loongarch@...ts.linux.dev,
        linux-acpi@...r.kernel.org, linux-arch@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-riscv@...ts.infradead.org, kvmarm@...ts.linux.dev,
        x86@...nel.org, linux-csky@...r.kernel.org,
        linux-doc@...r.kernel.org, linux-ia64@...r.kernel.org,
        linux-parisc@...r.kernel.org, Salil Mehta <salil.mehta@...wei.com>,
        Jean-Philippe Brucker <jean-philippe@...aro.org>,
        jianyong.wu@....com, justin.he@....com,
        James Morse <james.morse@....com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [PATCH RFC 11/22] drivers: base: remove unnecessary call to
 register_cpu_under_node()

On Mon, Nov 13, 2023 at 02:04:32PM +1000, Gavin Shan wrote:
> On 11/7/23 20:30, Russell King (Oracle) wrote:
> > Since "drivers: base: Move cpu_dev_init() after node_dev_init()", we
> > can remove some redundant code.
> > 
> > node_dev_init() will walk through the nodes calling register_one_node()
> > on each. This will trickle down to __register_one_node() which walks
> > all present CPUs, calling register_cpu_under_node() on each.
> > 
> > register_cpu_under_node() will call get_cpu_device(cpu) for each, which
> > will return NULL until the CPU is registered using register_cpu(). This
> > now happens _after_ node_dev_init().
> > 
> > Therefore, calling register_cpu_under_node() from __register_one_node()
> > becomes a no-op, and can be removed.
> > 
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> > ---
> >   drivers/base/node.c | 7 -------
> >   1 file changed, 7 deletions(-)
> > 
> 
> __register_one_node() can be called in memory hot add path either. In that path,
> a new NUMA node can be presented and becomes online. Does this become a problem
> after the logic of associating CPU with newly added NUMA node?

I guess this is where ordering matters.

As mentioned in the commit message, register_cpu_under_node() does
this:

        if (!node_online(nid))
                return 0;

        obj = get_cpu_device(cpu);
        if (!obj)
                return 0;

get_cpu_device() will return NULL if the CPU is not possible or is out
of range, or register_cpu() has not yet been called for this CPU, and
register_cpu() will call register_cpu_under_node().

I guess it is possible for a CPU it be present, but the node its
associated with would not be online, which means we end up with
register_cpu_under_node() returning on !node_online(nid) but we've
populated the CPU devices (thus get_cpu_device(cpu) would return
non-NULL).

Then when the numa node comes online, we do still need to call this
path, so this change is incorrect.

It came about trying to address Jonathan's comment for this patch:

https://lore.kernel.org/r/20230913163823.7880-7-james.morse@arm.com

I think my response to Jonathan is still correct - but didn't need
a code change. I'm dropping this patch.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ