linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
@ 2021-02-26 20:17 Palmer Dabbelt
  2021-02-26 20:17 ` [PATCH 2/2] topology: Guard " Palmer Dabbelt
  2021-02-26 20:37 ` [PATCH 1/2] mm: Guard a use of " Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2021-02-26 20:17 UTC (permalink / raw)
  To: akpm, atishp
  Cc: peterz, srikar, valentin.schneider, vbabka, mpe, Palmer Dabbelt,
	linux-kernel, linux-mm, kernel-team

From: Palmer Dabbelt <palmerdabbelt@google.com>

This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
right thing to do here, as without CONFIG_NUMA there will never be any
large node distances on non-NUMA systems.

I expected this to manifest as a link failure under (!CONFIG_NUMA &&
CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
think the reference is just getting pruned before it's checked, but I
didn't get that from reading the code so I'm worried I'm missing
something.

Either way, this is necessary to guard the definition of
node_reclaim_distance with CONFIG_NUMA.

Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
---
 mm/khugepaged.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index a7d6cb912b05..b1bf191c3a54 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
 	for (i = 0; i < MAX_NUMNODES; i++) {
 		if (!khugepaged_node_load[i])
 			continue;
+#ifdef CONFIG_NUMA
 		if (node_distance(nid, i) > node_reclaim_distance)
 			return true;
+#endif
 	}
 	return false;
 }
-- 
2.30.1.766.gb4fecdf3b7-goog



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] topology: Guard node_reclaim_distance with CONFIFG_NUMA
  2021-02-26 20:17 [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA Palmer Dabbelt
@ 2021-02-26 20:17 ` Palmer Dabbelt
  2021-02-26 20:37 ` [PATCH 1/2] mm: Guard a use of " Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2021-02-26 20:17 UTC (permalink / raw)
  To: akpm, atishp
  Cc: peterz, srikar, valentin.schneider, vbabka, mpe, Palmer Dabbelt,
	linux-kernel, linux-mm, kernel-team

From: Palmer Dabbelt <palmerdabbelt@google.com>

This is only defined (and useful) for CONFIG_NUMA, but isn't
conditionally declared.  This makes users a bit more of a headache to
track down.

Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
---
 include/linux/topology.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/topology.h b/include/linux/topology.h
index 7634cd737061..15f02281bdf0 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -73,7 +73,9 @@ int arch_update_cpu_topology(void);
  * *improves* if allowed to reclaim memory and load balance tasks
  * between NUMA nodes 2-hops apart.
  */
+#ifdef CONFIG_NUMA
 extern int __read_mostly node_reclaim_distance;
+#endif
 
 #ifndef PENALTY_FOR_NODE_WITH_CPUS
 #define PENALTY_FOR_NODE_WITH_CPUS	(1)
-- 
2.30.1.766.gb4fecdf3b7-goog



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
  2021-02-26 20:17 [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA Palmer Dabbelt
  2021-02-26 20:17 ` [PATCH 2/2] topology: Guard " Palmer Dabbelt
@ 2021-02-26 20:37 ` Andrew Morton
  2021-02-27  1:31   ` Hugh Dickins
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2021-02-26 20:37 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: atishp, peterz, srikar, valentin.schneider, vbabka, mpe,
	Palmer Dabbelt, linux-kernel, linux-mm, kernel-team,
	Kirill A. Shutemov

On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt <palmer@dabbelt.com> wrote:

> From: Palmer Dabbelt <palmerdabbelt@google.com>
> 
> This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
> right thing to do here, as without CONFIG_NUMA there will never be any
> large node distances on non-NUMA systems.
> 
> I expected this to manifest as a link failure under (!CONFIG_NUMA &&
> CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
> think the reference is just getting pruned before it's checked, but I
> didn't get that from reading the code so I'm worried I'm missing
> something.
> 
> Either way, this is necessary to guard the definition of
> node_reclaim_distance with CONFIG_NUMA.
> 
> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
> ---
>  mm/khugepaged.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index a7d6cb912b05..b1bf191c3a54 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
>  	for (i = 0; i < MAX_NUMNODES; i++) {
>  		if (!khugepaged_node_load[i])
>  			continue;
> +#ifdef CONFIG_NUMA
>  		if (node_distance(nid, i) > node_reclaim_distance)
>  			return true;
> +#endif
>  	}
>  	return false;
>  }

This makes the entire loop a no-op.  Perhaps Kirill can help take a
look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
  2021-02-26 20:37 ` [PATCH 1/2] mm: Guard a use of " Andrew Morton
@ 2021-02-27  1:31   ` Hugh Dickins
  2021-02-27  3:05     ` Palmer Dabbelt
  0 siblings, 1 reply; 7+ messages in thread
From: Hugh Dickins @ 2021-02-27  1:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Palmer Dabbelt, atishp, peterz, srikar, valentin.schneider,
	vbabka, mpe, Palmer Dabbelt, linux-kernel, linux-mm, kernel-team,
	Kirill A. Shutemov

On Fri, 26 Feb 2021, Andrew Morton wrote:
> On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt <palmer@dabbelt.com> wrote:
> > From: Palmer Dabbelt <palmerdabbelt@google.com>
> > 
> > This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
> > right thing to do here, as without CONFIG_NUMA there will never be any
> > large node distances on non-NUMA systems.
> > 
> > I expected this to manifest as a link failure under (!CONFIG_NUMA &&
> > CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
> > think the reference is just getting pruned before it's checked, but I
> > didn't get that from reading the code so I'm worried I'm missing
> > something.
> > 
> > Either way, this is necessary to guard the definition of
> > node_reclaim_distance with CONFIG_NUMA.
> > 
> > Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
> > ---
> >  mm/khugepaged.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index a7d6cb912b05..b1bf191c3a54 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
> >  	for (i = 0; i < MAX_NUMNODES; i++) {
> >  		if (!khugepaged_node_load[i])
> >  			continue;
> > +#ifdef CONFIG_NUMA
> >  		if (node_distance(nid, i) > node_reclaim_distance)
> >  			return true;
> > +#endif
> >  	}
> >  	return false;
> >  }
> 
> This makes the entire loop a no-op.  Perhaps Kirill can help take a
> look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n?

First lines of khugepaged_scan_abort() say
	if (!node_reclaim_mode)
		return false;

And include/linux/swap.h says
#ifdef CONFIG_NUMA
extern int node_reclaim_mode;
extern int sysctl_min_unmapped_ratio;
extern int sysctl_min_slab_ratio;
#else
#define node_reclaim_mode 0
#endif

So, no need for an #ifdef CONFIG_NUMA inside khugepaged_scan_abort().

Hugh


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
  2021-02-27  1:31   ` Hugh Dickins
@ 2021-02-27  3:05     ` Palmer Dabbelt
  2021-02-27  3:41       ` Hugh Dickins
  0 siblings, 1 reply; 7+ messages in thread
From: Palmer Dabbelt @ 2021-02-27  3:05 UTC (permalink / raw)
  To: hughd
  Cc: akpm, atishp, peterz, srikar, valentin.schneider, vbabka, mpe,
	linux-kernel, linux-mm, kernel-team, kirill.shutemov

On Fri, 26 Feb 2021 17:31:40 PST (-0800), hughd@google.com wrote:
> On Fri, 26 Feb 2021, Andrew Morton wrote:
>> On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt <palmer@dabbelt.com> wrote:
>> > From: Palmer Dabbelt <palmerdabbelt@google.com>
>> >
>> > This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
>> > right thing to do here, as without CONFIG_NUMA there will never be any
>> > large node distances on non-NUMA systems.
>> >
>> > I expected this to manifest as a link failure under (!CONFIG_NUMA &&
>> > CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
>> > think the reference is just getting pruned before it's checked, but I
>> > didn't get that from reading the code so I'm worried I'm missing
>> > something.
>> >
>> > Either way, this is necessary to guard the definition of
>> > node_reclaim_distance with CONFIG_NUMA.
>> >
>> > Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
>> > ---
>> >  mm/khugepaged.c | 2 ++
>> >  1 file changed, 2 insertions(+)
>> >
>> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> > index a7d6cb912b05..b1bf191c3a54 100644
>> > --- a/mm/khugepaged.c
>> > +++ b/mm/khugepaged.c
>> > @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
>> >  	for (i = 0; i < MAX_NUMNODES; i++) {
>> >  		if (!khugepaged_node_load[i])
>> >  			continue;
>> > +#ifdef CONFIG_NUMA
>> >  		if (node_distance(nid, i) > node_reclaim_distance)
>> >  			return true;
>> > +#endif
>> >  	}
>> >  	return false;
>> >  }
>>
>> This makes the entire loop a no-op.  Perhaps Kirill can help take a
>> look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n?
>
> First lines of khugepaged_scan_abort() say
> 	if (!node_reclaim_mode)
> 		return false;
>
> And include/linux/swap.h says
> #ifdef CONFIG_NUMA
> extern int node_reclaim_mode;
> extern int sysctl_min_unmapped_ratio;
> extern int sysctl_min_slab_ratio;
> #else
> #define node_reclaim_mode 0
> #endif
>
> So, no need for an #ifdef CONFIG_NUMA inside khugepaged_scan_abort().

Ah, thanks, I hadn't seen that.  That certainly explains the lack of an 
undefined reference.

That said: do we generally rely on DCE to prune references to undefined 
symbols?  This particular one seems like it'd get reliably deleted, but it 
seems like a fragile thing to do in general.  This kind of stuff would 
certainly make some code easier to write, though.

I don't really care all that much, though, as I was just sending this along due 
to some build failure report from a user that I couldn't reproduce.  It looked 
like they had some out-of-tree stuff, so in this case I'm fine on fixing this 
being their problem.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
  2021-02-27  3:05     ` Palmer Dabbelt
@ 2021-02-27  3:41       ` Hugh Dickins
  2021-02-27  4:14         ` Palmer Dabbelt
  0 siblings, 1 reply; 7+ messages in thread
From: Hugh Dickins @ 2021-02-27  3:41 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: hughd, akpm, atishp, peterz, srikar, valentin.schneider, vbabka,
	mpe, linux-kernel, linux-mm, kernel-team, kirill.shutemov

On Fri, 26 Feb 2021, Palmer Dabbelt wrote:
> On Fri, 26 Feb 2021 17:31:40 PST (-0800), hughd@google.com wrote:
> > On Fri, 26 Feb 2021, Andrew Morton wrote:
> > > On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt <palmer@dabbelt.com>
> > > wrote:
> > > > From: Palmer Dabbelt <palmerdabbelt@google.com>
> > > >
> > > > This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
> > > > right thing to do here, as without CONFIG_NUMA there will never be any
> > > > large node distances on non-NUMA systems.
> > > >
> > > > I expected this to manifest as a link failure under (!CONFIG_NUMA &&
> > > > CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
> > > > think the reference is just getting pruned before it's checked, but I
> > > > didn't get that from reading the code so I'm worried I'm missing
> > > > something.
> > > >
> > > > Either way, this is necessary to guard the definition of
> > > > node_reclaim_distance with CONFIG_NUMA.
> > > >
> > > > Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
> > > > ---
> > > >  mm/khugepaged.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > > > index a7d6cb912b05..b1bf191c3a54 100644
> > > > --- a/mm/khugepaged.c
> > > > +++ b/mm/khugepaged.c
> > > > @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
> > > >  	for (i = 0; i < MAX_NUMNODES; i++) {
> > > >  		if (!khugepaged_node_load[i])
> > > >  			continue;
> > > > +#ifdef CONFIG_NUMA
> > > >  		if (node_distance(nid, i) > node_reclaim_distance)
> > > >  			return true;
> > > > +#endif
> > > >  	}
> > > >  	return false;
> > > >  }
> > > 
> > > This makes the entire loop a no-op.  Perhaps Kirill can help take a
> > > look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n?
> > 
> > First lines of khugepaged_scan_abort() say
> > 	if (!node_reclaim_mode)
> > 		return false;
> > 
> > And include/linux/swap.h says
> > #ifdef CONFIG_NUMA
> > extern int node_reclaim_mode;
> > extern int sysctl_min_unmapped_ratio;
> > extern int sysctl_min_slab_ratio;
> > #else
> > #define node_reclaim_mode 0
> > #endif
> > 
> > So, no need for an #ifdef CONFIG_NUMA inside khugepaged_scan_abort().
> 
> Ah, thanks, I hadn't seen that.  That certainly explains the lack of an
> undefined reference.
> 
> That said: do we generally rely on DCE to prune references to undefined
> symbols?  This particular one seems like it'd get reliably deleted, but it
> seems like a fragile thing to do in general.  This kind of stuff would
> certainly make some code easier to write, though.

Yes, the kernel build very much depends on the optimizer eliminating
dead code, in many many places.  We do prefer to keep the #ifdefs to
the header files as much as possible.

> 
> I don't really care all that much, though, as I was just sending this along
> due to some build failure report from a user that I couldn't reproduce.  It
> looked like they had some out-of-tree stuff, so in this case I'm fine on
> fixing this being their problem.

I didn't see your 2/2 at the time; but wouldn't be surprised if that
needs 1/2, to avoid an error on undeclared node_reclaim_distance before
the optimizer comes into play.  If so, best just to drop 2/2 too.

Hugh


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA
  2021-02-27  3:41       ` Hugh Dickins
@ 2021-02-27  4:14         ` Palmer Dabbelt
  0 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2021-02-27  4:14 UTC (permalink / raw)
  To: hughd
  Cc: hughd, akpm, atishp, peterz, srikar, valentin.schneider, vbabka,
	mpe, linux-kernel, linux-mm, kernel-team, kirill.shutemov

On Fri, 26 Feb 2021 19:41:40 PST (-0800), hughd@google.com wrote:
> On Fri, 26 Feb 2021, Palmer Dabbelt wrote:
>> On Fri, 26 Feb 2021 17:31:40 PST (-0800), hughd@google.com wrote:
>> > On Fri, 26 Feb 2021, Andrew Morton wrote:
>> > > On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt <palmer@dabbelt.com>
>> > > wrote:
>> > > > From: Palmer Dabbelt <palmerdabbelt@google.com>
>> > > >
>> > > > This is only useful under CONFIG_NUMA.  IIUC skipping the check is the
>> > > > right thing to do here, as without CONFIG_NUMA there will never be any
>> > > > large node distances on non-NUMA systems.
>> > > >
>> > > > I expected this to manifest as a link failure under (!CONFIG_NUMA &&
>> > > > CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that.  I
>> > > > think the reference is just getting pruned before it's checked, but I
>> > > > didn't get that from reading the code so I'm worried I'm missing
>> > > > something.
>> > > >
>> > > > Either way, this is necessary to guard the definition of
>> > > > node_reclaim_distance with CONFIG_NUMA.
>> > > >
>> > > > Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
>> > > > ---
>> > > >  mm/khugepaged.c | 2 ++
>> > > >  1 file changed, 2 insertions(+)
>> > > >
>> > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> > > > index a7d6cb912b05..b1bf191c3a54 100644
>> > > > --- a/mm/khugepaged.c
>> > > > +++ b/mm/khugepaged.c
>> > > > @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid)
>> > > >  	for (i = 0; i < MAX_NUMNODES; i++) {
>> > > >  		if (!khugepaged_node_load[i])
>> > > >  			continue;
>> > > > +#ifdef CONFIG_NUMA
>> > > >  		if (node_distance(nid, i) > node_reclaim_distance)
>> > > >  			return true;
>> > > > +#endif
>> > > >  	}
>> > > >  	return false;
>> > > >  }
>> > >
>> > > This makes the entire loop a no-op.  Perhaps Kirill can help take a
>> > > look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n?
>> >
>> > First lines of khugepaged_scan_abort() say
>> > 	if (!node_reclaim_mode)
>> > 		return false;
>> >
>> > And include/linux/swap.h says
>> > #ifdef CONFIG_NUMA
>> > extern int node_reclaim_mode;
>> > extern int sysctl_min_unmapped_ratio;
>> > extern int sysctl_min_slab_ratio;
>> > #else
>> > #define node_reclaim_mode 0
>> > #endif
>> >
>> > So, no need for an #ifdef CONFIG_NUMA inside khugepaged_scan_abort().
>>
>> Ah, thanks, I hadn't seen that.  That certainly explains the lack of an
>> undefined reference.
>>
>> That said: do we generally rely on DCE to prune references to undefined
>> symbols?  This particular one seems like it'd get reliably deleted, but it
>> seems like a fragile thing to do in general.  This kind of stuff would
>> certainly make some code easier to write, though.
>
> Yes, the kernel build very much depends on the optimizer eliminating
> dead code, in many many places.  We do prefer to keep the #ifdefs to
> the header files as much as possible.

OK, makes sense.  Thanks!

>> I don't really care all that much, though, as I was just sending this along
>> due to some build failure report from a user that I couldn't reproduce.  It
>> looked like they had some out-of-tree stuff, so in this case I'm fine on
>> fixing this being their problem.
>
> I didn't see your 2/2 at the time; but wouldn't be surprised if that
> needs 1/2, to avoid an error on undeclared node_reclaim_distance before
> the optimizer comes into play.  If so, best just to drop 2/2 too.

Ya, definitely.  Sorry for the noise!


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-27  4:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 20:17 [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA Palmer Dabbelt
2021-02-26 20:17 ` [PATCH 2/2] topology: Guard " Palmer Dabbelt
2021-02-26 20:37 ` [PATCH 1/2] mm: Guard a use of " Andrew Morton
2021-02-27  1:31   ` Hugh Dickins
2021-02-27  3:05     ` Palmer Dabbelt
2021-02-27  3:41       ` Hugh Dickins
2021-02-27  4:14         ` Palmer Dabbelt

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).