netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about synchronize_net() in AF_PACKET close()
@ 2014-09-09 21:44 Martin Kelly
  2014-09-09 22:00 ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Kelly @ 2014-09-09 21:44 UTC (permalink / raw)
  To: netdev; +Cc: Paul E. McKenney, Stephen Hemminger

Hi,

I have been reading the code in net/packet/af_packet.c in order to
optimize the runtime for raw socket close(). In certain cases, close()
can take a long time to return because of the synchronize_net()
overhead. In pursuit of speeding up close(), I have been testing a patch
that defers the socket buffer memory release via call_rcu() in order to
make close() return faster. However, I hit a tricky RCU question for
which I don't have the answer and wanted to know if any RCU/networking
experts could provide some guidance.

In net/packet/af_packet.c, I noticed the following few lines within
packet_release:

         synchronize_net();
         /*
          *      Now the socket is dead. No more input will appear.
          */
         sock_orphan(sk);
         sock->sk = NULL;

>From testing and code analysis, I have found that it appears to be safe
to move sock_orphan and sock->sk = NULL before the synchronize_net()
call like so:

         /*
          *      Now the socket is dead. No more input will appear.
          */
         sock_orphan(sk);
         sock->sk = NULL;
         synchronize_net();

Could some RCU and/or networking experts chime in about whether this a
safe operation? For all I know, there is some deep, fundamental reason
why those lines are in the order they are. On the other hand, perhaps
there is not.

Thanks,
Martin

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

end of thread, other threads:[~2014-09-17 18:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 21:44 Question about synchronize_net() in AF_PACKET close() Martin Kelly
2014-09-09 22:00 ` David Miller
2014-09-10 13:19   ` Marcelo Ricardo Leitner
2014-09-10 21:39     ` Martin Kelly
2014-09-10 21:37   ` Martin Kelly
2014-09-17 14:29     ` Martin Kelly
2014-09-17 14:54       ` Eric Dumazet
2014-09-17 17:04         ` Martin Kelly
2014-09-17 17:52           ` Eric Dumazet
2014-09-17 18:58             ` Martin Kelly

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).