diff mbox

arch: sparc: kernel: smp_64.c: Optimization of the Code

Message ID 1401659298-18067-1-git-send-email-rickard_strandqvist@spectrumdigital.se
State Rejected
Delegated to: David Miller
Headers show

Commit Message

Rickard Strandqvist June 1, 2014, 9:48 p.m. UTC
From what I know, AND is faster then modulo.
Not sure if this is worth changing though.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 arch/sparc/kernel/smp_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller June 2, 2014, 1:52 a.m. UTC | #1
From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Date: Sun,  1 Jun 2014 23:48:18 +0200

> From what I know, AND is faster then modulo.
> Not sure if this is worth changing though.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>

This code came from the IA-64 arch code, so you probably want to
fix either both or neither.

I'd say neither, this is not a performance critical path and the
intent is clearer when expressed as a modulus.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 745a363..921d924 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -179,7 +179,7 @@  static inline long get_delta (long *rt, long *master)
 
 	/* average best_t0 and best_t1 without overflow: */
 	tcenter = (best_t0/2 + best_t1/2);
-	if (best_t0 % 2 + best_t1 % 2 == 2)
+	if ((best_t0 & 1) + (best_t1 & 1) == 2)
 		tcenter++;
 	return tcenter - best_tm;
 }