netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: updating dst lastusage is an unlikely event.
@ 2017-10-24 10:37 Paolo Abeni
  2017-10-24 10:39 ` Paolo Abeni
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Abeni @ 2017-10-24 10:37 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Wei Wang, Martin KaFai Lau

Since commit 0da4af00b2ed ("ipv6: only update __use and lastusetime
once per jiffy at most"), updating the dst lastuse field is an
unlikely action: it happens at most once per jiffy, out of
potentially millions of calls per second.

Mark explicitly the code as such, and let the compiler generate
better code.

Note: gcc 7.2 and several older versions do actually generate
different - better - code when the unlikely() hint is in place,
avoid jump in the fast path and keeping better code locality.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 include/net/dst.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index d70b33dc2332..0744a9630eed 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -257,7 +257,7 @@ static inline void dst_hold(struct dst_entry *dst)
 
 static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
 {
-	if (time != dst->lastuse) {
+	if (unlikely(time != dst->lastuse)) {
 		dst->__use++;
 		dst->lastuse = time;
 	}
-- 
2.13.6

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

* Re: [PATCH net-next 1/2] net: updating dst lastusage is an unlikely event.
  2017-10-24 10:37 [PATCH net-next 1/2] net: updating dst lastusage is an unlikely event Paolo Abeni
@ 2017-10-24 10:39 ` Paolo Abeni
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2017-10-24 10:39 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Wei Wang, Martin KaFai Lau

On Tue, 2017-10-24 at 12:37 +0200, Paolo Abeni wrote:
> Since commit 0da4af00b2ed ("ipv6: only update __use and lastusetime
> once per jiffy at most"), updating the dst lastuse field is an
> unlikely action: it happens at most once per jiffy, out of
> potentially millions of calls per second.
> 
> Mark explicitly the code as such, and let the compiler generate
> better code.
> 
> Note: gcc 7.2 and several older versions do actually generate
> different - better - code when the unlikely() hint is in place,
> avoid jump in the fast path and keeping better code locality.
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Oops, I placed a bad subject prefix here, please ignore. I'll resend
soon with a proper one.

Sorry for the noise,

Paolo 

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

end of thread, other threads:[~2017-10-24 10:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 10:37 [PATCH net-next 1/2] net: updating dst lastusage is an unlikely event Paolo Abeni
2017-10-24 10:39 ` Paolo Abeni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).