From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> To: Dan Williams <dan.j.williams@intel.com>, linux-nvdimm@lists.01.org Cc: Michal Hocko <mhocko@suse.com>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, peterz@infradead.org, dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 13/16] acpi/mm: Up-level "map to online node" functionality Date: Mon, 11 Nov 2019 17:00:38 +0530 [thread overview] Message-ID: <87v9rq8xb5.fsf@linux.ibm.com> (raw) In-Reply-To: <157309906694.1582359.4777838043061104635.stgit@dwillia2-desk3.amr.corp.intel.com> Dan Williams <dan.j.williams@intel.com> writes: > The acpi_map_pxm_to_online_node() helper is used to find the closest > online node to a given proximity domain. This is used to map devices in > a proximity domain with no online memory or cpus to the closest online > node and populate a device's 'numa_node' property. The numa_node > property allows applications to be migrated "close" to a resource. > > In preparation for providing a generic facility to optionally map an > address range to its closest online node, or the node the range would > represent were it to be onlined (target_node), up-level the core of > acpi_map_pxm_to_online_node() to a generic mm/numa helper. > > Cc: Michal Hocko <mhocko@suse.com> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > drivers/acpi/numa.c | 41 ----------------------------------------- > include/linux/acpi.h | 23 ++++++++++++++++++++++- > include/linux/numa.h | 2 ++ > mm/mempolicy.c | 30 ++++++++++++++++++++++++++++++ > 4 files changed, 54 insertions(+), 42 deletions(-) > > diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c > index eadbf90e65d1..47b4969d9b93 100644 > --- a/drivers/acpi/numa.c > +++ b/drivers/acpi/numa.c > @@ -72,47 +72,6 @@ int acpi_map_pxm_to_node(int pxm) > } > EXPORT_SYMBOL(acpi_map_pxm_to_node); > > -/** > - * acpi_map_pxm_to_online_node - Map proximity ID to online node > - * @pxm: ACPI proximity ID > - * > - * This is similar to acpi_map_pxm_to_node(), but always returns an online > - * node. When the mapped node from a given proximity ID is offline, it > - * looks up the node distance table and returns the nearest online node. > - * > - * ACPI device drivers, which are called after the NUMA initialization has > - * completed in the kernel, can call this interface to obtain their device > - * NUMA topology from ACPI tables. Such drivers do not have to deal with > - * offline nodes. A node may be offline when a device proximity ID is > - * unique, SRAT memory entry does not exist, or NUMA is disabled, ex. > - * "numa=off" on x86. > - */ > -int acpi_map_pxm_to_online_node(int pxm) > -{ > - int node, min_node; > - > - node = acpi_map_pxm_to_node(pxm); > - > - if (node == NUMA_NO_NODE) > - node = 0; > - > - min_node = node; > - if (!node_online(node)) { > - int min_dist = INT_MAX, dist, n; > - > - for_each_online_node(n) { > - dist = node_distance(node, n); > - if (dist < min_dist) { > - min_dist = dist; > - min_node = n; > - } > - } > - } > - > - return min_node; > -} > -EXPORT_SYMBOL(acpi_map_pxm_to_online_node); > - > static void __init > acpi_table_print_srat_entry(struct acpi_subtable_header *header) > { > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 8b4e516bac00..aeedd09f2f71 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -401,9 +401,30 @@ extern void acpi_osi_setup(char *str); > extern bool acpi_osi_is_win8(void); > > #ifdef CONFIG_ACPI_NUMA > -int acpi_map_pxm_to_online_node(int pxm); > int acpi_map_pxm_to_node(int pxm); > int acpi_get_node(acpi_handle handle); > + > +/** > + * acpi_map_pxm_to_online_node - Map proximity ID to online node > + * @pxm: ACPI proximity ID > + * > + * This is similar to acpi_map_pxm_to_node(), but always returns an online > + * node. When the mapped node from a given proximity ID is offline, it > + * looks up the node distance table and returns the nearest online node. > + * > + * ACPI device drivers, which are called after the NUMA initialization has > + * completed in the kernel, can call this interface to obtain their device > + * NUMA topology from ACPI tables. Such drivers do not have to deal with > + * offline nodes. A node may be offline when a device proximity ID is > + * unique, SRAT memory entry does not exist, or NUMA is disabled, ex. > + * "numa=off" on x86. > + */ > +static inline int acpi_map_pxm_to_online_node(int pxm) > +{ > + int node = acpi_map_pxm_to_node(pxm); > + > + return numa_map_to_online_node(node); > +} > #else > static inline int acpi_map_pxm_to_online_node(int pxm) > { > diff --git a/include/linux/numa.h b/include/linux/numa.h > index 110b0e5d0fb0..4fd80f42be43 100644 > --- a/include/linux/numa.h > +++ b/include/linux/numa.h > @@ -13,4 +13,6 @@ > > #define NUMA_NO_NODE (-1) > > +int numa_map_to_online_node(int node); > + > #endif /* _LINUX_NUMA_H */ > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 4ae967bcf954..e2d8dd21ce9d 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -127,6 +127,36 @@ static struct mempolicy default_policy = { > > static struct mempolicy preferred_node_policy[MAX_NUMNODES]; > > +/** > + * numa_map_to_online_node - Find closest online node > + * @nid: Node id to start the search > + * > + * Lookup the next closest node by distance if @nid is not online. > + */ > +int numa_map_to_online_node(int node) > +{ > + int min_node; > + > + if (node == NUMA_NO_NODE) > + node = 0; The ppc64 variant papr_scm_node return the NUMA_NO_NODE in this case. Most of the mm helpers can handle with that value . So instead of forcing node = 0, let the subsystem decide what to do with the NUMA_NO_NODE value.? > + > + min_node = node; > + if (!node_online(node)) { > + int min_dist = INT_MAX, dist, n; > + > + for_each_online_node(n) { > + dist = node_distance(node, n); > + if (dist < min_dist) { > + min_dist = dist; > + min_node = n; > + } > + } > + } > + > + return min_node; > +} > +EXPORT_SYMBOL_GPL(numa_map_to_online_node); > + > struct mempolicy *get_task_policy(struct task_struct *p) > { > struct mempolicy *pol = p->mempolicy; Can we also switch papr_scm_node to numa_map_to_online_node()? -aneesh _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> To: Dan Williams <dan.j.williams@intel.com>, linux-nvdimm@lists.01.org Cc: Michal Hocko <mhocko@suse.com>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, peterz@infradead.org, dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 13/16] acpi/mm: Up-level "map to online node" functionality Date: Mon, 11 Nov 2019 17:00:38 +0530 [thread overview] Message-ID: <87v9rq8xb5.fsf@linux.ibm.com> (raw) In-Reply-To: <157309906694.1582359.4777838043061104635.stgit@dwillia2-desk3.amr.corp.intel.com> Dan Williams <dan.j.williams@intel.com> writes: > The acpi_map_pxm_to_online_node() helper is used to find the closest > online node to a given proximity domain. This is used to map devices in > a proximity domain with no online memory or cpus to the closest online > node and populate a device's 'numa_node' property. The numa_node > property allows applications to be migrated "close" to a resource. > > In preparation for providing a generic facility to optionally map an > address range to its closest online node, or the node the range would > represent were it to be onlined (target_node), up-level the core of > acpi_map_pxm_to_online_node() to a generic mm/numa helper. > > Cc: Michal Hocko <mhocko@suse.com> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> > --- > drivers/acpi/numa.c | 41 ----------------------------------------- > include/linux/acpi.h | 23 ++++++++++++++++++++++- > include/linux/numa.h | 2 ++ > mm/mempolicy.c | 30 ++++++++++++++++++++++++++++++ > 4 files changed, 54 insertions(+), 42 deletions(-) > > diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c > index eadbf90e65d1..47b4969d9b93 100644 > --- a/drivers/acpi/numa.c > +++ b/drivers/acpi/numa.c > @@ -72,47 +72,6 @@ int acpi_map_pxm_to_node(int pxm) > } > EXPORT_SYMBOL(acpi_map_pxm_to_node); > > -/** > - * acpi_map_pxm_to_online_node - Map proximity ID to online node > - * @pxm: ACPI proximity ID > - * > - * This is similar to acpi_map_pxm_to_node(), but always returns an online > - * node. When the mapped node from a given proximity ID is offline, it > - * looks up the node distance table and returns the nearest online node. > - * > - * ACPI device drivers, which are called after the NUMA initialization has > - * completed in the kernel, can call this interface to obtain their device > - * NUMA topology from ACPI tables. Such drivers do not have to deal with > - * offline nodes. A node may be offline when a device proximity ID is > - * unique, SRAT memory entry does not exist, or NUMA is disabled, ex. > - * "numa=off" on x86. > - */ > -int acpi_map_pxm_to_online_node(int pxm) > -{ > - int node, min_node; > - > - node = acpi_map_pxm_to_node(pxm); > - > - if (node == NUMA_NO_NODE) > - node = 0; > - > - min_node = node; > - if (!node_online(node)) { > - int min_dist = INT_MAX, dist, n; > - > - for_each_online_node(n) { > - dist = node_distance(node, n); > - if (dist < min_dist) { > - min_dist = dist; > - min_node = n; > - } > - } > - } > - > - return min_node; > -} > -EXPORT_SYMBOL(acpi_map_pxm_to_online_node); > - > static void __init > acpi_table_print_srat_entry(struct acpi_subtable_header *header) > { > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 8b4e516bac00..aeedd09f2f71 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -401,9 +401,30 @@ extern void acpi_osi_setup(char *str); > extern bool acpi_osi_is_win8(void); > > #ifdef CONFIG_ACPI_NUMA > -int acpi_map_pxm_to_online_node(int pxm); > int acpi_map_pxm_to_node(int pxm); > int acpi_get_node(acpi_handle handle); > + > +/** > + * acpi_map_pxm_to_online_node - Map proximity ID to online node > + * @pxm: ACPI proximity ID > + * > + * This is similar to acpi_map_pxm_to_node(), but always returns an online > + * node. When the mapped node from a given proximity ID is offline, it > + * looks up the node distance table and returns the nearest online node. > + * > + * ACPI device drivers, which are called after the NUMA initialization has > + * completed in the kernel, can call this interface to obtain their device > + * NUMA topology from ACPI tables. Such drivers do not have to deal with > + * offline nodes. A node may be offline when a device proximity ID is > + * unique, SRAT memory entry does not exist, or NUMA is disabled, ex. > + * "numa=off" on x86. > + */ > +static inline int acpi_map_pxm_to_online_node(int pxm) > +{ > + int node = acpi_map_pxm_to_node(pxm); > + > + return numa_map_to_online_node(node); > +} > #else > static inline int acpi_map_pxm_to_online_node(int pxm) > { > diff --git a/include/linux/numa.h b/include/linux/numa.h > index 110b0e5d0fb0..4fd80f42be43 100644 > --- a/include/linux/numa.h > +++ b/include/linux/numa.h > @@ -13,4 +13,6 @@ > > #define NUMA_NO_NODE (-1) > > +int numa_map_to_online_node(int node); > + > #endif /* _LINUX_NUMA_H */ > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 4ae967bcf954..e2d8dd21ce9d 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -127,6 +127,36 @@ static struct mempolicy default_policy = { > > static struct mempolicy preferred_node_policy[MAX_NUMNODES]; > > +/** > + * numa_map_to_online_node - Find closest online node > + * @nid: Node id to start the search > + * > + * Lookup the next closest node by distance if @nid is not online. > + */ > +int numa_map_to_online_node(int node) > +{ > + int min_node; > + > + if (node == NUMA_NO_NODE) > + node = 0; The ppc64 variant papr_scm_node return the NUMA_NO_NODE in this case. Most of the mm helpers can handle with that value . So instead of forcing node = 0, let the subsystem decide what to do with the NUMA_NO_NODE value.? > + > + min_node = node; > + if (!node_online(node)) { > + int min_dist = INT_MAX, dist, n; > + > + for_each_online_node(n) { > + dist = node_distance(node, n); > + if (dist < min_dist) { > + min_dist = dist; > + min_node = n; > + } > + } > + } > + > + return min_node; > +} > +EXPORT_SYMBOL_GPL(numa_map_to_online_node); > + > struct mempolicy *get_task_policy(struct task_struct *p) > { > struct mempolicy *pol = p->mempolicy; Can we also switch papr_scm_node to numa_map_to_online_node()? -aneesh
next prev parent reply other threads:[~2019-11-11 11:39 UTC|newest] Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-07 3:56 [PATCH 00/16] Memory Hierarchy: Enable target node lookups for reserved memory Dan Williams 2019-11-07 3:56 ` Dan Williams 2019-11-07 3:56 ` [PATCH 01/16] libnvdimm: Move attribute groups to device type Dan Williams 2019-11-07 3:56 ` Dan Williams 2019-11-12 11:28 ` Aneesh Kumar K.V 2019-11-12 11:28 ` Aneesh Kumar K.V 2019-11-07 3:56 ` [PATCH 02/16] libnvdimm: Move region attribute group definition Dan Williams 2019-11-07 3:56 ` Dan Williams 2019-11-12 11:29 ` Aneesh Kumar K.V 2019-11-12 11:29 ` Aneesh Kumar K.V 2019-11-07 3:56 ` [PATCH 03/16] libnvdimm: Move nd_device_attribute_group to device_type Dan Williams 2019-11-07 3:56 ` Dan Williams 2019-11-12 11:30 ` Aneesh Kumar K.V 2019-11-12 11:30 ` Aneesh Kumar K.V 2019-11-07 3:56 ` [PATCH 04/16] libnvdimm: Move nd_numa_attribute_group " Dan Williams 2019-11-07 3:56 ` Dan Williams 2019-11-12 9:22 ` Aneesh Kumar K.V 2019-11-12 9:22 ` Aneesh Kumar K.V 2019-11-13 1:26 ` Dan Williams 2019-11-13 1:26 ` Dan Williams 2019-11-13 1:26 ` Dan Williams 2019-11-13 6:02 ` Aneesh Kumar K.V 2019-11-13 6:02 ` Aneesh Kumar K.V 2019-11-13 6:14 ` Dan Williams 2019-11-13 6:14 ` Dan Williams 2019-11-13 6:14 ` Dan Williams 2019-11-07 3:57 ` [PATCH 05/16] libnvdimm: Move nd_region_attribute_group " Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:45 ` Aneesh Kumar K.V 2019-11-12 11:45 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 06/16] libnvdimm: Move nd_mapping_attribute_group " Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:45 ` Aneesh Kumar K.V 2019-11-12 11:45 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 07/16] libnvdimm: Move nvdimm_attribute_group " Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:48 ` Aneesh Kumar K.V 2019-11-12 11:48 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 08/16] libnvdimm: Move nvdimm_bus_attribute_group " Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:48 ` Aneesh Kumar K.V 2019-11-12 11:48 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 09/16] dax: Create a dax device_type Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:49 ` Aneesh Kumar K.V 2019-11-12 11:49 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 10/16] dax: Simplify root read-only definition for the 'resource' attribute Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:49 ` Aneesh Kumar K.V 2019-11-12 11:49 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 11/16] libnvdimm: " Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:50 ` Aneesh Kumar K.V 2019-11-12 11:50 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 12/16] dax: Add numa_node to the default device-dax attributes Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-12 11:50 ` Aneesh Kumar K.V 2019-11-12 11:50 ` Aneesh Kumar K.V 2019-11-07 3:57 ` [PATCH 13/16] acpi/mm: Up-level "map to online node" functionality Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-11 11:30 ` Aneesh Kumar K.V [this message] 2019-11-11 11:30 ` Aneesh Kumar K.V 2019-11-11 23:38 ` Dan Williams 2019-11-11 23:38 ` Dan Williams 2019-11-11 23:38 ` Dan Williams 2019-11-07 3:57 ` [PATCH 14/16] x86/numa: Provide a range-to-target_node lookup facility Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-07 3:57 ` [PATCH 15/16] libnvdimm/e820: Drop the wrapper around memory_add_physaddr_to_nid Dan Williams 2019-11-07 3:57 ` Dan Williams 2019-11-07 3:58 ` [PATCH 16/16] libnvdimm/e820: Retrieve and populate correct 'target_node' info Dan Williams 2019-11-07 3:58 ` Dan Williams 2019-11-09 5:02 ` kbuild test robot 2019-11-09 5:02 ` kbuild test robot 2019-11-09 5:02 ` kbuild test robot 2019-11-12 11:42 ` [PATCH 00/16] Memory Hierarchy: Enable target node lookups for reserved memory Aneesh Kumar K.V 2019-11-12 11:42 ` Aneesh Kumar K.V 2019-11-12 19:37 ` Dan Williams 2019-11-12 19:37 ` Dan Williams 2019-11-12 19:37 ` Dan Williams
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=87v9rq8xb5.fsf@linux.ibm.com \ --to=aneesh.kumar@linux.ibm.com \ --cc=dan.j.williams@intel.com \ --cc=dave.hansen@linux.intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nvdimm@lists.01.org \ --cc=mhocko@suse.com \ --cc=peterz@infradead.org \ --cc=rjw@rjwysocki.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.