diff mbox series

mm, compaction: Use free lists to quickly locate a migration target -fix

Message ID 20190109111344.GU31517@techsingularity.net (mailing list archive)
State New, archived
Headers show
Series mm, compaction: Use free lists to quickly locate a migration target -fix | expand

Commit Message

Mel Gorman Jan. 9, 2019, 11:13 a.m. UTC
Full compaction of a node passes in negative orders which can lead to array
boundary issues. While it could be addressed in the control flow of the
primary loop, it would be fragile so explicitly check for the condition.
This is a fix for the mmotm patch
broken-out/mm-compaction-use-free-lists-to-quickly-locate-a-migration-target.patch

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 mm/compaction.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andrew Morton Jan. 9, 2019, 7:27 p.m. UTC | #1
On Wed, 9 Jan 2019 11:13:44 +0000 Mel Gorman <mgorman@techsingularity.net> wrote:

> Full compaction of a node passes in negative orders which can lead to array
> boundary issues. While it could be addressed in the control flow of the
> primary loop, it would be fragile so explicitly check for the condition.
> This is a fix for the mmotm patch
> broken-out/mm-compaction-use-free-lists-to-quickly-locate-a-migration-target.patch
> 
> ...
>
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1206,6 +1206,10 @@ fast_isolate_freepages(struct compact_control *cc)
>  	bool scan_start = false;
>  	int order;
>  
> +	/* Full compaction passes in a negative order */
> +	if (order <= 0)
> +		return cc->free_pfn;
> +
>  	/*
>  	 * If starting the scan, use a deeper search and use the highest
>  	 * PFN found if a suitable one is not found.

`order' is uninitialized.
Mel Gorman Jan. 9, 2019, 9:26 p.m. UTC | #2
On Wed, Jan 09, 2019 at 11:27:31AM -0800, Andrew Morton wrote:
> On Wed, 9 Jan 2019 11:13:44 +0000 Mel Gorman <mgorman@techsingularity.net> wrote:
> 
> > Full compaction of a node passes in negative orders which can lead to array
> > boundary issues. While it could be addressed in the control flow of the
> > primary loop, it would be fragile so explicitly check for the condition.
> > This is a fix for the mmotm patch
> > broken-out/mm-compaction-use-free-lists-to-quickly-locate-a-migration-target.patch
> > 
> > ...
> >
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -1206,6 +1206,10 @@ fast_isolate_freepages(struct compact_control *cc)
> >  	bool scan_start = false;
> >  	int order;
> >  
> > +	/* Full compaction passes in a negative order */
> > +	if (order <= 0)
> > +		return cc->free_pfn;
> > +
> >  	/*
> >  	 * If starting the scan, use a deeper search and use the highest
> >  	 * PFN found if a suitable one is not found.
> 
> `order' is uninitialized.

Twice I managed to send out the wrong one :(

---8<---
mm, compaction: Use free lists to quickly locate a migration target -fix

Full compaction of a node passes in negative orders which can lead to array
boundary issues. While it could be addressed in the control flow of the
primary loop, it would be fragile so explicitly check for the condition.
This is a fix for the mmotm patch
broken-out/mm-compaction-use-free-lists-to-quickly-locate-a-migration-target.patch

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 mm/compaction.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/compaction.c b/mm/compaction.c
index 9438f0564ed5..4b46ae96cc1b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1206,6 +1206,10 @@ fast_isolate_freepages(struct compact_control *cc)
 	bool scan_start = false;
 	int order;
 
+	/* Full compaction passes in a negative order */
+	if (cc->order <= 0)
+		return cc->free_pfn;
+
 	/*
 	 * If starting the scan, use a deeper search and use the highest
 	 * PFN found if a suitable one is not found.
diff mbox series

Patch

diff --git a/mm/compaction.c b/mm/compaction.c
index 9438f0564ed5..167ad0f5c2fe 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1206,6 +1206,10 @@  fast_isolate_freepages(struct compact_control *cc)
 	bool scan_start = false;
 	int order;
 
+	/* Full compaction passes in a negative order */
+	if (order <= 0)
+		return cc->free_pfn;
+
 	/*
 	 * If starting the scan, use a deeper search and use the highest
 	 * PFN found if a suitable one is not found.