linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Michael Roth <michael.roth@amd.com>, linux-efi@vger.kernel.org
Cc: x86@kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Nikolay Borisov <nik.borisov@suse.com>,
	stable@kernel.org, Tom Lendacky <thomas.lendacky@amd.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges
Date: Fri, 3 Nov 2023 16:30:01 +0100	[thread overview]
Message-ID: <30ff0335-3d9c-7d54-85d0-5898320f4e1f@suse.cz> (raw)
In-Reply-To: <20231103151354.110636-1-michael.roth@amd.com>

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;



  reply	other threads:[~2023-11-03 15:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 15:13 Michael Roth
2023-11-03 15:30 ` Vlastimil Babka [this message]
2023-11-08 11:21   ` Ard Biesheuvel
2023-11-28 11:25     ` Vlastimil Babka
2023-11-28 11:50       ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30ff0335-3d9c-7d54-85d0-5898320f4e1f@suse.cz \
    --to=vbabka@suse.cz \
    --cc=ardb@kernel.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=michael.roth@amd.com \
    --cc=nik.borisov@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=stable@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox