mirror of
https://github.com/torvalds/linux.git
synced 2026-09-28 20:12:01 +02:00
KVM: Don't pre-reserve xarray entries when storing empty/NULL attributes
Skip the xarray reservation loop when clearing all memory attributes, as storing NULL only erases the entry and never needs to allocate, so no reservation (and no cleanup of a failed one) is required in that case. Suggested-by: Sean Christopherson <seanjc@google.com> Cc: David Ballesteros <davimaba.v@proton.me> Signed-off-by: Zeng Chi <zengchi@kylinos.cn> Link: https://patch.msgid.link/20260921102442.1232375-1-zeng_chi911@163.com [sean: split to separate patch] Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
382e5d514b
commit
119e9db233
|
|
@ -2593,9 +2593,10 @@ static int kvm_vm_set_mem_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
|
|||
|
||||
/*
|
||||
* Reserve memory ahead of time to avoid having to deal with failures
|
||||
* partway through setting the new attributes.
|
||||
* partway through setting the new attributes. Storing NULL never
|
||||
* allocates, so no reservations are needed when clearing.
|
||||
*/
|
||||
for (i = start; i < end; i++) {
|
||||
for (i = start; entry && i < end; i++) {
|
||||
r = xa_reserve(&kvm->mem_attr_array, i, GFP_KERNEL_ACCOUNT);
|
||||
if (r)
|
||||
goto out_unlock;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user