Skip to contentSkip to conversation

mm, memory_hotplug: __offline_pages fix wrong locking

PATCH In review Michal Hocko 3 participants 3 messages Jan 15, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm, memory_hotplug: __offline_pages fix wrong locking

From: Michal Hocko <[email protected]>

Jan has noticed that we do double unlock on some failure paths when offlining a page range. This is indeed the case when test_pages_in_a_zone respp. start_isolate_page_range fail. This was an omission when forward porting the debugging patch from an older kernel.

Fix the issue by dropping mem_hotplug_done from the failure condition and keeping the single unlock in the catch all failure path.

Fixes 7960509329c2 ("mm, memory_hotplug: print reason for the offlining failure")
---
 mm/memory_hotplug.c | 2 --
 1 file changed, 2 deletions(-)
mm/memory_hotplug.c +0 -2
index b9a667d36c55..faeeaccc5fae 100644
@@ -1576,7 +1576,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
 	   we assume this for now. .*/
 	if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start,
 				  &valid_end)) {
-		mem_hotplug_done();
 		ret = -EINVAL;
 		reason = "multizone range";
 		goto failed_removal;
@@ -1591,7 +1590,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
 				       MIGRATE_MOVABLE,
 				       SKIP_HWPOISON | REPORT_FAILURE);
 	if (ret) {
-		mem_hotplug_done();
 		reason = "failure to isolate range";
 		goto failed_removal;
 	}
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Jan has noticed that we do double unlock on some failure paths when offlining a page range. This is indeed the case when test_pages_in_a_zone respp. start_isolate_page_range fail. This was an omission when forward porting the debugging patch from an older kernel.

Quoted 6 lines

Fix the issue by dropping mem_hotplug_done from the failure condition and keeping the single unlock in the catch all failure path.

Fixes 7960509329c2 ("mm, memory_hotplug: print reason for the offlining failure")

Uhmf, I overlooked that while reviewing the patch.

Thanks

Signature · 2 lines
Oscar Salvador
SUSE L3
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Michal Hocko
Quoted 7 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Jan has noticed that we do double unlock on some failure paths when offlining a page range. This is indeed the case when test_pages_in_a_zone respp. start_isolate_page_range fail. This was an omission when forward porting the debugging patch from an older kernel.

Quoted 6 lines

Fix the issue by dropping mem_hotplug_done from the failure condition and keeping the single unlock in the catch all failure path.

Fixes 7960509329c2 ("mm, memory_hotplug: print reason for the offlining failure")

The patch looks good to me so feel free to add:

Also it fixes the test that previously crashed for me so you can add:

Honza

Quoted 27 lines
---
 mm/memory_hotplug.c | 2 --
 1 file changed, 2 deletions(-)
mm/memory_hotplug.c +0 -2
index b9a667d36c55..faeeaccc5fae 100644
@@ -1576,7 +1576,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
 	   we assume this for now. .*/
 	if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start,
 				  &valid_end)) {
-		mem_hotplug_done();
 		ret = -EINVAL;
 		reason = "multizone range";
 		goto failed_removal;
@@ -1591,7 +1590,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
 				       MIGRATE_MOVABLE,
 				       SKIP_HWPOISON | REPORT_FAILURE);
 	if (ret) {
-		mem_hotplug_done();
 		reason = "failure to isolate range";
 		goto failed_removal;
 	}
Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR