From: Keith Busch <keith.busch@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Dave Hansen <dave.hansen@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Brice Goglin <Brice.Goglin@inria.fr>
Subject: Re: [PATCH] hmat: Register attributes for memory hot add
Date: Thu, 11 Apr 2019 09:00:57 -0600 [thread overview]
Message-ID: <20190411150057.GA7247@localhost.localdomain> (raw)
In-Reply-To: <CAJZ5v0gOuHSoMd6dnGKN5fW1xKF89b2ak0F4mo+07FBpFUCP6A@mail.gmail.com>
On Thu, Apr 11, 2019 at 04:42:45PM +0200, Rafael J. Wysocki wrote:
> On Tue, Apr 9, 2019 at 11:42 PM Keith Busch <keith.busch@intel.com> wrote:
> > -static __init void hmat_register_targets(void)
> > +static void hmat_register_targets(void)
> > {
> > struct memory_target *target;
> >
> > list_for_each_entry(target, &targets, node) {
> > + if (!node_online(pxm_to_node(target->memory_pxm)))
> > + continue;
> > +
> > hmat_register_target_initiators(target);
> > hmat_register_target_perf(target);
> > + target->registered = true;
> > }
> > }
> >
> > +static int hmat_callback(struct notifier_block *self,
> > + unsigned long action, void *arg)
> > +{
> > + struct memory_notify *mnb = arg;
> > + int pxm, nid = mnb->status_change_nid;
> > + struct memory_target *target;
> > +
> > + if (nid == NUMA_NO_NODE || action != MEM_ONLINE)
> > + return NOTIFY_OK;
> > +
> > + pxm = node_to_pxm(nid);
> > + target = find_mem_target(pxm);
> > + if (!target || target->registered)
> > + return NOTIFY_OK;
> > +
> > + hmat_register_target_initiators(target);
> > + hmat_register_target_perf(target);
> > + target->registered = true;
> > +
> > + return NOTIFY_OK;
> > +}
>
> This appears to assume that there will never be any races between the
> two functions above.
>
> It this guaranteed to be the case?
The hmat_init() will call this directly before registering the memory
notifier callback, so those two paths should be 'ok'.
I may have assumed memory notification callbacks were single threaded,
but after taking a quick look, I think I do need additional locking for
this to be safe. I'll get that fixed up, thanks for the catch.
prev parent reply other threads:[~2019-04-11 14:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 21:44 [PATCH] hmat: Register attributes for memory hot add Keith Busch
2019-04-10 11:07 ` Brice Goglin
2019-04-11 14:42 ` Rafael J. Wysocki
2019-04-11 15:00 ` Keith Busch [this message]
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=20190411150057.GA7247@localhost.localdomain \
--to=keith.busch@intel.com \
--cc=Brice.Goglin@inria.fr \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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;
as well as URLs for NNTP newsgroup(s).