[v3,2/6] mm/numa: Skip NUMA_NO_NODE and online nodes in numa_map_to_online_node()
diff mbox series

Message ID 157954697957.2239526.17206272633668977957.stgit@dwillia2-desk3.amr.corp.intel.com
State Superseded
Headers show
Series
  • Memory Hierarchy: Enable target node lookups for reserved memory
Related show

Commit Message

Dan Williams Jan. 20, 2020, 7:02 p.m. UTC
Update numa_map_to_online_node() to stop falling back to numa node 0
when the input is NUMA_NO_NODE. Also, skip the lookup if @node is
online. This makes the routine compatible with other arch node mapping
routines.

Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/157401275716.43284.13185549705765009174.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 mm/mempolicy.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Aneesh Kumar K.V Jan. 21, 2020, 1:36 a.m. UTC | #1
Dan Williams <dan.j.williams@intel.com> writes:

> Update numa_map_to_online_node() to stop falling back to numa node 0
> when the input is NUMA_NO_NODE. Also, skip the lookup if @node is
> online. This makes the routine compatible with other arch node mapping
> routines.
>
> Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Link: https://lore.kernel.org/r/157401275716.43284.13185549705765009174.stgit@dwillia2-desk3.amr.corp.intel.com
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  mm/mempolicy.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 4cff069279f6..30d76db718bf 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -137,8 +137,8 @@ int numa_map_to_online_node(int node)
>  {
>  	int min_node;
>  
> -	if (node == NUMA_NO_NODE)
> -		node = 0;
> +	if (node == NUMA_NO_NODE || node_online(node))
> +		return node;
>  
>  	min_node = node;
>  	if (!node_online(node)) {


The above if condition will always be true?

-aneesh
Dan Williams Jan. 21, 2020, 3:09 a.m. UTC | #2
On Mon, Jan 20, 2020 at 5:36 PM Aneesh Kumar K.V
<aneesh.kumar@linux.ibm.com> wrote:
>
> Dan Williams <dan.j.williams@intel.com> writes:
>
> > Update numa_map_to_online_node() to stop falling back to numa node 0
> > when the input is NUMA_NO_NODE. Also, skip the lookup if @node is
> > online. This makes the routine compatible with other arch node mapping
> > routines.
> >
> > Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> > Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> > Link: https://lore.kernel.org/r/157401275716.43284.13185549705765009174.stgit@dwillia2-desk3.amr.corp.intel.com
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > ---
> >  mm/mempolicy.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> > index 4cff069279f6..30d76db718bf 100644
> > --- a/mm/mempolicy.c
> > +++ b/mm/mempolicy.c
> > @@ -137,8 +137,8 @@ int numa_map_to_online_node(int node)
> >  {
> >       int min_node;
> >
> > -     if (node == NUMA_NO_NODE)
> > -             node = 0;
> > +     if (node == NUMA_NO_NODE || node_online(node))
> > +             return node;
> >
> >       min_node = node;
> >       if (!node_online(node)) {
>
>
> The above if condition will always be true?

No, not for the node_offline case, and that's typically what callers
are passing.
>
> -aneesh

Patch
diff mbox series

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 4cff069279f6..30d76db718bf 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -137,8 +137,8 @@  int numa_map_to_online_node(int node)
 {
 	int min_node;
 
-	if (node == NUMA_NO_NODE)
-		node = 0;
+	if (node == NUMA_NO_NODE || node_online(node))
+		return node;
 
 	min_node = node;
 	if (!node_online(node)) {