* [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
@ 2023-11-03 15:13 Michael Roth
2023-11-03 15:30 ` Vlastimil Babka
0 siblings, 1 reply; 5+ messages in thread
From: Michael Roth @ 2023-11-03 15:13 UTC (permalink / raw)
To: linux-efi
Cc: x86, linux-coco, linux-mm, linux-kernel, Ard Biesheuvel,
Kirill A . Shutemov, Vlastimil Babka, Nikolay Borisov, stable,
Tom Lendacky, Paolo Bonzini
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.
Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
v2:
* Improve commit message terminology (Kirill)
---
drivers/firmware/efi/unaccepted_memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c
index 135278ddaf62..79fb687bb90f 100644
--- a/drivers/firmware/efi/unaccepted_memory.c
+++ b/drivers/firmware/efi/unaccepted_memory.c
@@ -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;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
2023-11-03 15:13 [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges Michael Roth
@ 2023-11-03 15:30 ` Vlastimil Babka
2023-11-08 11:21 ` Ard Biesheuvel
0 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka @ 2023-11-03 15:30 UTC (permalink / raw)
To: Michael Roth, linux-efi
Cc: x86, linux-coco, linux-mm, linux-kernel, Ard Biesheuvel,
Kirill A . Shutemov, Nikolay Borisov, stable, Tom Lendacky,
Paolo Bonzini
On 11/3/23 16:13, Michael Roth wrote:
> 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.
>
> Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
> Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
More justification for introducing a common ranges_overlap() helper somewhere :)
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> v2:
> * Improve commit message terminology (Kirill)
> ---
> drivers/firmware/efi/unaccepted_memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c
> index 135278ddaf62..79fb687bb90f 100644
> --- a/drivers/firmware/efi/unaccepted_memory.c
> +++ b/drivers/firmware/efi/unaccepted_memory.c
> @@ -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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
2023-11-03 15:30 ` Vlastimil Babka
@ 2023-11-08 11:21 ` Ard Biesheuvel
2023-11-28 11:25 ` Vlastimil Babka
0 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2023-11-08 11:21 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Michael Roth, linux-efi, x86, linux-coco, linux-mm, linux-kernel,
Kirill A . Shutemov, Nikolay Borisov, stable, Tom Lendacky,
Paolo Bonzini
On Fri, 3 Nov 2023 at 16:30, Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 11/3/23 16:13, Michael Roth wrote:
> > 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.
> >
> > Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
> > Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
> > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Signed-off-by: Michael Roth <michael.roth@amd.com>
>
> More justification for introducing a common ranges_overlap() helper somewhere :)
>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
>
Thanks, I'll take this as a fix.
> > ---
> > v2:
> > * Improve commit message terminology (Kirill)
> > ---
> > drivers/firmware/efi/unaccepted_memory.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c
> > index 135278ddaf62..79fb687bb90f 100644
> > --- a/drivers/firmware/efi/unaccepted_memory.c
> > +++ b/drivers/firmware/efi/unaccepted_memory.c
> > @@ -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;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
2023-11-08 11:21 ` Ard Biesheuvel
@ 2023-11-28 11:25 ` Vlastimil Babka
2023-11-28 11:50 ` Ard Biesheuvel
0 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka @ 2023-11-28 11:25 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Michael Roth, linux-efi, x86, linux-coco, linux-mm, linux-kernel,
Kirill A . Shutemov, Nikolay Borisov, stable, Tom Lendacky,
Paolo Bonzini
On 11/8/23 12:21, Ard Biesheuvel wrote:
> On Fri, 3 Nov 2023 at 16:30, Vlastimil Babka <vbabka@suse.cz> wrote:
>>
>> On 11/3/23 16:13, Michael Roth wrote:
>> > 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.
>> >
>> > Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
>> > Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
>> > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> > Signed-off-by: Michael Roth <michael.roth@amd.com>
>>
>> More justification for introducing a common ranges_overlap() helper somewhere :)
>>
>> Acked-by: Vlastimil Babka <vbabka@suse.cz>
>>
>
> Thanks, I'll take this as a fix.
Ping, can't see it in mainline nor -next?
>
>> > ---
>> > v2:
>> > * Improve commit message terminology (Kirill)
>> > ---
>> > drivers/firmware/efi/unaccepted_memory.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c
>> > index 135278ddaf62..79fb687bb90f 100644
>> > --- a/drivers/firmware/efi/unaccepted_memory.c
>> > +++ b/drivers/firmware/efi/unaccepted_memory.c
>> > @@ -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;
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
2023-11-28 11:25 ` Vlastimil Babka
@ 2023-11-28 11:50 ` Ard Biesheuvel
0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2023-11-28 11:50 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Michael Roth, linux-efi, x86, linux-coco, linux-mm, linux-kernel,
Kirill A . Shutemov, Nikolay Borisov, stable, Tom Lendacky,
Paolo Bonzini
On Tue, 28 Nov 2023 at 12:25, Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 11/8/23 12:21, Ard Biesheuvel wrote:
> > On Fri, 3 Nov 2023 at 16:30, Vlastimil Babka <vbabka@suse.cz> wrote:
> >>
> >> On 11/3/23 16:13, Michael Roth wrote:
> >> > 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.
> >> >
> >> > Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
> >> > Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
> >> > Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >> > Signed-off-by: Michael Roth <michael.roth@amd.com>
> >>
> >> More justification for introducing a common ranges_overlap() helper somewhere :)
> >>
> >> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> >>
> >
> > Thanks, I'll take this as a fix.
>
> Ping, can't see it in mainline nor -next?
>
Apologies - queued up now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-28 11:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03 15:13 [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges Michael Roth
2023-11-03 15:30 ` Vlastimil Babka
2023-11-08 11:21 ` Ard Biesheuvel
2023-11-28 11:25 ` Vlastimil Babka
2023-11-28 11:50 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).