From: Nathan Lynch <nathanl@linux.ibm.com>
To: Scott Cheloha <cheloha@linux.ibm.com>
Cc: Nathan Fontenont <ndfont@gmail.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Rick Lindsley <ricklind@linux.vnet.ibm.com>
Subject: Re: [PATCH] powerpc/drmem: cache LMBs in xarray to accelerate lookup
Date: Fri, 21 Feb 2020 12:11:32 -0600 [thread overview]
Message-ID: <8736b3u7xn.fsf@linux.ibm.com> (raw)
In-Reply-To: <20200128221113.17158-1-cheloha@linux.ibm.com>
Hi Scott, I've owed you a follow-up on this for a couple weeks, sorry.
Beyond the issue of whether to remove the drmem_info->lmbs array, there
are some other things to address.
Scott Cheloha <cheloha@linux.ibm.com> writes:
> diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
> index 3d76e1c388c2..a37cbe794cdd 100644
> --- a/arch/powerpc/include/asm/drmem.h
> +++ b/arch/powerpc/include/asm/drmem.h
> @@ -88,6 +88,9 @@ static inline bool drmem_lmb_reserved(struct drmem_lmb *lmb)
> return lmb->flags & DRMEM_LMB_RESERVED;
> }
>
> +struct drmem_lmb *drmem_find_lmb_by_base_addr(unsigned long);
> +struct drmem_lmb *drmem_find_lmb_by_drc_index(unsigned long);
Need identifiers for the function arguments here. checkpatch warns about
this. Also drc_index conventionally is handled as u32 in this code.
> +struct drmem_lmb *drmem_find_lmb_by_base_addr(unsigned long base_addr)
> +{
> + return xa_load(&drmem_lmb_base_addr, base_addr);
> +}
> +
> +struct drmem_lmb *drmem_find_lmb_by_drc_index(unsigned long drc_index)
> +{
> + return xa_load(&drmem_lmb_drc_index, drc_index);
> +}
> +
> +static int drmem_lmb_cache_for_lookup(struct drmem_lmb *lmb)
This is called only from __init functions, so it should be __init as well.
> +{
> + void *ret;
> +
> + ret = xa_store(&drmem_lmb_base_addr, lmb->base_addr, lmb, GFP_KERNEL);
> + if (xa_err(ret))
> + return xa_err(ret);
> +
> + ret = xa_store(&drmem_lmb_drc_index, lmb->drc_index, lmb, GFP_KERNEL);
> + if (xa_err(ret))
> + return xa_err(ret);
> +
> + return 0;
> +}
> +
> static u32 drmem_lmb_flags(struct drmem_lmb *lmb)
> {
> /*
> @@ -364,6 +392,8 @@ static void __init init_drmem_v1_lmbs(const __be32 *prop)
>
> for_each_drmem_lmb(lmb) {
> read_drconf_v1_cell(lmb, &prop);
> + if (drmem_lmb_cache_for_lookup(lmb) != 0)
> + return;
> lmb_set_nid(lmb);
> }
Failing to record an lmb in the caches shouldn't be cause for silently
aborting this initialization. Future lookups against the caches (should
the system even boot) may fail, but the drmem_lmbs will still be
initialized correctly.
I'd say just ignore (or perhaps log once) xa_store() failures as long as
this code only runs at boot.
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index 50d68d21ddcc..23684d44549f 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -958,27 +958,21 @@ early_param("topology_updates", early_topology_updates);
> static int hot_add_drconf_scn_to_nid(unsigned long scn_addr)
> {
> struct drmem_lmb *lmb;
> - unsigned long lmb_size;
> - int nid = NUMA_NO_NODE;
> -
> - lmb_size = drmem_lmb_size();
> -
> - for_each_drmem_lmb(lmb) {
> - /* skip this block if it is reserved or not assigned to
> - * this partition */
> - if ((lmb->flags & DRCONF_MEM_RESERVED)
> - || !(lmb->flags & DRCONF_MEM_ASSIGNED))
> - continue;
>
> - if ((scn_addr < lmb->base_addr)
> - || (scn_addr >= (lmb->base_addr + lmb_size)))
> - continue;
> + lmb = drmem_find_lmb_by_base_addr(scn_addr);
> + if (lmb == NULL)
> + return NUMA_NO_NODE;
>
> - nid = of_drconf_to_nid_single(lmb);
> - break;
> - }
> + /*
> + * We can't use it if it is reserved or not assigned to
> + * this partition.
> + */
> + if (lmb->flags & DRCONF_MEM_RESERVED)
> + return NUMA_NO_NODE;
> + if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
> + return NUMA_NO_NODE;
>
> - return nid;
> + return of_drconf_to_nid_single(lmb);
> }
>
> /*
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index c126b94d1943..29bd19831a9a 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -222,17 +222,10 @@ static int get_lmb_range(u32 drc_index, int n_lmbs,
> struct drmem_lmb **start_lmb,
> struct drmem_lmb **end_lmb)
> {
> - struct drmem_lmb *lmb, *start, *end;
> + struct drmem_lmb *start, *end;
> struct drmem_lmb *last_lmb;
>
> - start = NULL;
> - for_each_drmem_lmb(lmb) {
> - if (lmb->drc_index == drc_index) {
> - start = lmb;
> - break;
> - }
> - }
> -
> + start = drmem_find_lmb_by_drc_index(drc_index);
> if (!start)
> return -EINVAL;
The changes to hot_add_drconf_scn_to_nid() and get_lmb_range() look
correct to me.
next prev parent reply other threads:[~2020-02-21 18:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 22:11 [PATCH] powerpc/drmem: cache LMBs in xarray to accelerate lookup Scott Cheloha
2020-01-28 23:56 ` Nathan Lynch
2020-01-29 18:10 ` Scott Cheloha
2020-01-30 16:09 ` Fontenot, Nathan
2020-02-03 20:13 ` Scott Cheloha
2020-02-05 14:33 ` Fontenot, Nathan
2020-02-04 16:19 ` Scott Cheloha
2020-02-21 17:29 ` pseries: accelerate drmem and simplify hotplug with xarrays Scott Cheloha
2020-02-21 17:29 ` [PATCH v2 1/2] powerpc/drmem: accelerate memory_add_physaddr_to_nid() with LMB xarray Scott Cheloha
2020-02-21 20:02 ` Nathan Lynch
2020-07-22 23:00 ` Anton Blanchard
2020-02-21 17:29 ` [PATCH v2 2/2] pseries/hotplug-memory: leverage xarray API to simplify code Scott Cheloha
2020-02-21 20:03 ` Nathan Lynch
2020-02-21 18:11 ` Nathan Lynch [this message]
2020-02-21 18:28 ` [PATCH] powerpc/drmem: cache LMBs in xarray to accelerate lookup Nathan Lynch
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=8736b3u7xn.fsf@linux.ibm.com \
--to=nathanl@linux.ibm.com \
--cc=cheloha@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ndfont@gmail.com \
--cc=ricklind@linux.vnet.ibm.com \
/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).