Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1315624 > unrolled thread

[PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

Started byWilly Tarreau <w@1wt.eu>
First post2016-01-23 16:00 +0100
Last post2016-01-23 20:10 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in  test_pages_in_a_zone() Willy Tarreau <w@1wt.eu> - 2016-01-23 16:00 +0100
    Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing  sections in test_pages_in_a_zone() Ben Hutchings <ben@decadent.org.uk> - 2016-01-23 19:20 +0100
      Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone() Willy Tarreau <w@1wt.eu> - 2016-01-23 19:40 +0100
        Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone() Willy Tarreau <w@1wt.eu> - 2016-01-23 20:10 +0100

#1315624 — [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

FromWilly Tarreau <w@1wt.eu>
Date2016-01-23 16:00 +0100
Subject[PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
Message-ID<qU7Ps-48H-11@gated-at.bofh.it>
2.6.32-longterm review patch.  If anyone has any objections, please let me know.

------------------

From: Andrew Banman <abanman@sgi.com>

commit 5f0f2887f4de9508dcf438deab28f1de8070c271 upstream.

test_pages_in_a_zone() does not account for the possibility of missing
sections in the given pfn range.  pfn_valid_within always returns 1 when
CONFIG_HOLES_IN_ZONE is not set, allowing invalid pfns from missing
sections to pass the test, leading to a kernel oops.

Wrap an additional pfn loop with PAGES_PER_SECTION granularity to check
for missing sections before proceeding into the zone-check code.

This also prevents a crash from offlining memory devices with missing
sections.  Despite this, it may be a good idea to keep the related patch
'[PATCH 3/3] drivers: memory: prohibit offlining of memory blocks with
missing sections' because missing sections in a memory block may lead to
other problems not covered by the scope of this fix.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Alex Thorlton <athorlton@sgi.com>
Cc: Russ Anderson <rja@sgi.com>
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Greg KH <greg@kroah.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
(cherry picked from commit 17f6a291c98199d7ce15a850ce5f548ceef628bc)
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 mm/memory_hotplug.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index f4be464..de19654 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -601,23 +601,30 @@ int is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages)
  */
 static int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn)
 {
-	unsigned long pfn;
+	unsigned long pfn, sec_end_pfn;
 	struct zone *zone = NULL;
 	struct page *page;
 	int i;
-	for (pfn = start_pfn;
+	for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn);
 	     pfn < end_pfn;
-	     pfn += MAX_ORDER_NR_PAGES) {
-		i = 0;
-		/* This is just a CONFIG_HOLES_IN_ZONE check.*/
-		while ((i < MAX_ORDER_NR_PAGES) && !pfn_valid_within(pfn + i))
-			i++;
-		if (i == MAX_ORDER_NR_PAGES)
+	     pfn = sec_end_pfn + 1, sec_end_pfn += PAGES_PER_SECTION) {
+		/* Make sure the memory section is present first */
+		if (!present_section_nr(pfn_to_section_nr(pfn)))
 			continue;
-		page = pfn_to_page(pfn + i);
-		if (zone && page_zone(page) != zone)
-			return 0;
-		zone = page_zone(page);
+		for (; pfn < sec_end_pfn && pfn < end_pfn;
+		     pfn += MAX_ORDER_NR_PAGES) {
+			i = 0;
+			/* This is just a CONFIG_HOLES_IN_ZONE check.*/
+			while ((i < MAX_ORDER_NR_PAGES) &&
+				!pfn_valid_within(pfn + i))
+				i++;
+			if (i == MAX_ORDER_NR_PAGES)
+				continue;
+			page = pfn_to_page(pfn + i);
+			if (zone && page_zone(page) != zone)
+				return 0;
+			zone = page_zone(page);
+		}
 	}
 	return 1;
 }
-- 
1.7.12.2.21.g234cd45.dirty

[toc] | [next] | [standalone]


#1315717 — Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

FromBen Hutchings <ben@decadent.org.uk>
Date2016-01-23 19:20 +0100
SubjectRe: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
Message-ID<qUaX0-6Bi-7@gated-at.bofh.it>
In reply to#1315624

[Multipart message — attachments visible in raw view] — view raw

On Sat, 2016-01-23 at 15:13 +0100, Willy Tarreau wrote:
> 2.6.32-longterm review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Andrew Banman <abanman@sgi.com>
> 
> commit 5f0f2887f4de9508dcf438deab28f1de8070c271 upstream.
[...]
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index f4be464..de19654 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -601,23 +601,30 @@ int is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages)
>   */
>  static int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn)
>  {
> -	unsigned long pfn;
> +	unsigned long pfn, sec_end_pfn;
>  	struct zone *zone = NULL;
>  	struct page *page;
>  	int i;
> -	for (pfn = start_pfn;
> +	for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn);
[...]

SECTION_ALIGN_UP() is not defined in 2.6.32; it was added by commit
a539f3533b78.

Ben.

-- 
Ben Hutchings
Life is what happens to you while you're busy making other plans.
                                                               - John Lennon

[toc] | [prev] | [next] | [standalone]


#1315723 — Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

FromWilly Tarreau <w@1wt.eu>
Date2016-01-23 19:40 +0100
SubjectRe: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
Message-ID<qUbgm-6Lf-1@gated-at.bofh.it>
In reply to#1315717
On Sat, Jan 23, 2016 at 06:13:59PM +0000, Ben Hutchings wrote:
> SECTION_ALIGN_UP() is not defined in 2.6.32; it was added by commit
> a539f3533b78.

... which means my build config was incomplete this time. I'll
refresh it to be sure it covers more of the code :-/

I'll backport the patch above, it's small enough.

Thanks Ben,
Willy

[toc] | [prev] | [next] | [standalone]


#1315729 — Re: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

FromWilly Tarreau <w@1wt.eu>
Date2016-01-23 20:10 +0100
SubjectRe: [PATCH 2.6.32 40/42] mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
Message-ID<qUbJo-7g7-3@gated-at.bofh.it>
In reply to#1315723
On Sat, Jan 23, 2016 at 07:29:54PM +0100, Willy Tarreau wrote:
> On Sat, Jan 23, 2016 at 06:13:59PM +0000, Ben Hutchings wrote:
> > SECTION_ALIGN_UP() is not defined in 2.6.32; it was added by commit
> > a539f3533b78.
> 
> ... which means my build config was incomplete this time. I'll
> refresh it to be sure it covers more of the code :-/
> 
> I'll backport the patch above, it's small enough.

Just wanted to confirm that allmodconfig passes with this one now.

Have a nice week-end,
Willy

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web