Skip to contentSkip to conversation

kvmppc: optimize find first bit

PATCH In review [email protected] 2 participants 3 messages Oct 10, 2008 – Oct 13, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 kvmppc: optimize find first bit

From: Christian Ehrhardt <[email protected]>

Since we use a unsigned long here anyway we can use the optimized __ffs.

---

[diffstat]

[diff]

arch/powerpc/kvm/booke_guest.c +1 -1
@@ -227,7 +227,7 @@
 	unsigned long *pending = &vcpu->arch.pending_exceptions;
 	unsigned int priority;
 
-	priority = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
+	priority = __ffs(*pending);
 	while (priority <= BOOKE_MAX_INTERRUPT) {
 		if (kvmppc_can_deliver_interrupt_by_prio(vcpu, priority)) {
 			kvmppc_clear_exception_by_prio(pending, priority);
#1 lore raw
Quoted 3 lines · On Fri, 2008-10-10 at 12:59 +0200, [email protected] wrote:

From: Christian Ehrhardt <[email protected]>

Since we use a unsigned long here anyway we can use the optimized __ffs.

Looks good.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#2 lore raw

PATCH 3/3 kvmppc: optimize find first bit

In reply to [email protected]

From: Christian Ehrhardt <[email protected]>

Since we use a unsigned long here anyway we can use the optimized __ffs.

---

[diffstat]

 booke_guest.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[diff]

arch/powerpc/kvm/booke_guest.c +1 -1
@@ -180,7 +180,7 @@
 	unsigned int prio;
 	u32 mask;
 
-	prio = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
+	prio = __ffs(*pending);
 	while (prio <= BOOKE_MAX_INTERRUPT) {
 		if (kvmppc_can_deliver_interrupt_by_prio(vcpu, prio, &mask)) {
 			kvmppc_clear_exception_by_prio(pending, prio);