efi/unaccepted: Fix off-by-one when checking for overlapping ranges
Subsystems (2)
PATCH v2 1/1 efi/unaccepted: Fix off-by-one when checking for overlapping ranges
When a task needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task 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.
---
v2:
* Improve commit message terminology (Kirill)
--- drivers/firmware/efi/unaccepted_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/unaccepted_memory.c +1 -1
@@ -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
Quoted 6 lines · Michael Roth
When a task needs to accept memory it will scan the
accepting_listto see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task might falsely determine that an overlapping range is being accepted, leading to an unnecessary delay before it begins processing the range.
Quoted 7 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")Link https://lore.kernel.org/linux-mm/[email protected]/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6 open hereReviewed-by Kirill A. Shutemov <[email protected]>Signed-off-by Michael Roth <[email protected]>
More justification for introducing a common ranges_overlap() helper somewhere :)
Quoted 20 lines
---
v2:
* Improve commit message terminology (Kirill)--- drivers/firmware/efi/unaccepted_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/efi/unaccepted_memory.c +1
-1@@ -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 ;
Ard Biesheuvel
maintainerQuoted 11 lines · Vlastimil Babka
Quoted 9 lines · Michael Roth
When a task needs to accept memory it will scan the
accepting_listto see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task 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.
Quoted 9 lines
Quoted 4 lines
Fixes 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")Link https://lore.kernel.org/linux-mm/[email protected]/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6 open hereReviewed-by Kirill A. Shutemov <[email protected]>Signed-off-by Michael Roth <[email protected]>More justification for introducing a common
ranges_overlap()helper somewhere :)Acked-by Vlastimil Babka <[email protected]>
Thanks, I'll take this as a fix.
Quoted 21 lines
Quoted 20 lines
---
v2:
* Improve commit message terminology (Kirill)--- drivers/firmware/efi/unaccepted_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/efi/unaccepted_memory.c +1
-1@@ -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 ;
Quoted 17 lines · Ard Biesheuvel
Quoted 16 lines · Vlastimil Babka
Quoted 13 lines · Michael Roth
When a task needs to accept memory it will scan the
accepting_listto see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task 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")Link https://lore.kernel.org/linux-mm/[email protected]/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6 open hereReviewed-by Kirill A. Shutemov <[email protected]>Signed-off-by Michael Roth <[email protected]>
Quoted 6 lines
Quoted 4 lines
More justification for introducing a common
ranges_overlap()helper somewhere :)Acked-by Vlastimil Babka <[email protected]>Thanks, I'll take this as a fix.
Ping, can't see it in mainline nor -next?
Quoted 23 lines
Quoted 22 lines
Quoted 21 lines
---
v2:
* Improve commit message terminology (Kirill)--- drivers/firmware/efi/unaccepted_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/efi/unaccepted_memory.c +1
-1@@ -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 ;
Ard Biesheuvel
maintainerQuoted 19 lines · Vlastimil Babka
Quoted 17 lines · Ard Biesheuvel
Quoted 16 lines · Vlastimil Babka
Quoted 13 lines · Michael Roth
When a task needs to accept memory it will scan the
accepting_listto see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task 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")Link https://lore.kernel.org/linux-mm/[email protected]/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6 open hereReviewed-by Kirill A. Shutemov <[email protected]>Signed-off-by Michael Roth <[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
More justification for introducing a common
ranges_overlap()helper somewhere :)Acked-by Vlastimil Babka <[email protected]>Thanks, I'll take this as a fix.
Ping, can't see it in mainline nor -next?
Apologies - queued up now.