public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* cxgb3: Fix sparse warning and micro-optimize is_pure_response()
@ 2008-11-29  5:47 Roland Dreier
  2008-11-29  5:55 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Dreier @ 2008-11-29  5:47 UTC (permalink / raw)
  To: Divy Le Ray, Jeff Garzik; +Cc: netdev

The function is_pure_response() does "ntohl(var) & const" and then
essentially just tests whether the result is 0 or not; this can be done
more efficiently by computing "var & htonl(const)" instead and doing the
byte swap at compile time instead of run time.

This change slightly shrinks the compiled code; eg on x86-64 we save a
couple of bswapl instructions:

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8 (-8)
function                                     old     new   delta
t3_sge_intr_msix_napi                        544     536      -8

and this also has the pleasant side effect of fixing a sparse warning:

    drivers/net/cxgb3/sge.c:2313:15: warning: restricted degrades to integer

Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
 drivers/net/cxgb3/sge.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index c6480be..4181373 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -2308,7 +2308,7 @@ next_fl:
 
 static inline int is_pure_response(const struct rsp_desc *r)
 {
-	u32 n = ntohl(r->flags) & (F_RSPD_ASYNC_NOTIF | F_RSPD_IMM_DATA_VALID);
+	__be32 n = r->flags & htonl(F_RSPD_ASYNC_NOTIF | F_RSPD_IMM_DATA_VALID);
 
 	return (n | r->len_cq) == 0;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: cxgb3: Fix sparse warning and micro-optimize is_pure_response()
  2008-11-29  5:47 cxgb3: Fix sparse warning and micro-optimize is_pure_response() Roland Dreier
@ 2008-11-29  5:55 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-11-29  5:55 UTC (permalink / raw)
  To: rdreier; +Cc: divy, jeff, netdev

From: Roland Dreier <rdreier@cisco.com>
Date: Fri, 28 Nov 2008 21:47:03 -0800

> The function is_pure_response() does "ntohl(var) & const" and then
> essentially just tests whether the result is 0 or not; this can be done
> more efficiently by computing "var & htonl(const)" instead and doing the
> byte swap at compile time instead of run time.
> 
> This change slightly shrinks the compiled code; eg on x86-64 we save a
> couple of bswapl instructions:
> 
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8 (-8)
> function                                     old     new   delta
> t3_sge_intr_msix_napi                        544     536      -8
> 
> and this also has the pleasant side effect of fixing a sparse warning:
> 
>     drivers/net/cxgb3/sge.c:2313:15: warning: restricted degrades to integer
> 
> Signed-off-by: Roland Dreier <rolandd@cisco.com>

Applied, thanks Roland.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-29  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-29  5:47 cxgb3: Fix sparse warning and micro-optimize is_pure_response() Roland Dreier
2008-11-29  5:55 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox