Skip to contentSkip to conversation

efi/unaccepted: Fix off-by-one when checking for overlapping ranges

PATCH Superseded Michael Roth 2 participants 3 messages Nov 3, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/unaccepted: Fix off-by-one when checking for overlapping ranges

When a thread needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other threads overlap with its range. Due to an off-by-one in the range comparisons, a thread might falsely determine that an overlapping range is being accepted, leading to an unnecessary delay before it begins processing the range.

Fix the off-by-one in the range comparison to prevent this and slightly improve performance.

Fixes 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
---
 drivers/firmware/efi/unaccepted_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/unaccepted_memory.c +1 -1
index 135278ddaf62..79fb687bb90f 100644
@@ -100,7 +100,7 @@ void accept_memory(phys_addr_t start, phys_addr_t end)
 	 * overlap on physical address level.
 	 */
 	list_for_each_entry(entry, &accepting_list, list) {
-		if (entry->end < range.start)
+		if (entry->end <= range.start)
 			continue;
 		if (entry->start >= range.end)
 			continue;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Michael Roth

When a thread needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other threads overlap with its range. Due to an off-by-one in the range comparisons, a thread might falsely determine that an overlapping range is being accepted, leading to an unnecessary delay before it begins processing the range.

Maybe s/thread/task/g ?

Quoted 6 lines

Fix the off-by-one in the range comparison to prevent this and slightly improve performance.

Fixes 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")

Otherwise, looks good:

Quoted 1 line
Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#2 lore raw
Quoted 12 lines · Kirill A . Shutemov
Quoted 5 lines · Michael Roth

When a thread needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other threads overlap with its range. Due to an off-by-one in the range comparisons, a thread might falsely determine that an overlapping range is being accepted, leading to an unnecessary delay before it begins processing the range.

Maybe s/thread/task/g ?

Quoted 3 lines

Fix the off-by-one in the range comparison to prevent this and slightly improve performance.

Quoted 7 lines
Quoted 3 lines
Fixes 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")

Otherwise, looks good:

Thanks! Sending a v2 with suggested changes.

-Mike

Quoted 4 lines
Quoted 1 line
Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov