lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  1 Dec 2014 17:29:23 +0000
From:	Igor Mammedov <imammedo@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	pbonzini@...hat.com, kvm@...r.kernel.org
Subject: [PATCH 1/5] kvm: update_memslots: drop not needed check for the same number of pages

if number of pages haven't changed sorting algorithm
will do nothing, so there is no need to do extra check
to avoid entering sorting logic.

Signed-off-by: Igor Mammedov <imammedo@...hat.com>
---
 virt/kvm/kvm_main.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5b45330..407277b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -679,21 +679,19 @@ static void update_memslots(struct kvm_memslots *slots,
 	struct kvm_memory_slot *mslots = slots->memslots;
 
 	WARN_ON(mslots[i].id != id);
-	if (new->npages != mslots[i].npages) {
-		if (new->npages < mslots[i].npages) {
-			while (i < KVM_MEM_SLOTS_NUM - 1 &&
-			       new->npages < mslots[i + 1].npages) {
-				mslots[i] = mslots[i + 1];
-				slots->id_to_index[mslots[i].id] = i;
-				i++;
-			}
-		} else {
-			while (i > 0 &&
-			       new->npages > mslots[i - 1].npages) {
-				mslots[i] = mslots[i - 1];
-				slots->id_to_index[mslots[i].id] = i;
-				i--;
-			}
+	if (new->npages < mslots[i].npages) {
+		while (i < KVM_MEM_SLOTS_NUM - 1 &&
+		       new->npages < mslots[i + 1].npages) {
+			mslots[i] = mslots[i + 1];
+			slots->id_to_index[mslots[i].id] = i;
+			i++;
+		}
+	} else {
+		while (i > 0 &&
+		       new->npages > mslots[i - 1].npages) {
+			mslots[i] = mslots[i - 1];
+			slots->id_to_index[mslots[i].id] = i;
+			i--;
 		}
 	}
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ