Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Mathieu Desnoyers <mathieu.desnoyers@...>
Cc: Jiri Olsa <jolsa@...>, Ingo Molnar <mingo@...>, Eric Dumazet <eric.dumazet@...>, Peter Zijlstra <a.p.zijlstra@...>, <netdev@...>, <linux-kernel@...>, <fbl@...>, <nhorman@...>, <davem@...>, <htejun@...>, <jarkao2@...>, <oleg@...>, <davidel@...>
Date: Tuesday, July 7, 2009 - 10:42 am

Mathieu Desnoyers a écrit :

RCU on this part is out of the question, as David already mentioned it.

It would be a regression for short lived tcp/udp sessions, and some workloads
use them a lot...

We gained about 20% performance between 2.6.26 and 2.6.31, carefuly removing
some atomic ops in network stack, adding RCU where it was sensible, but this
is a painful process, not something Jiri can use to fix bugs on legacy RedHat
kernels :) (We still are sorting out regressions)

To solve problem pointed by Jiri, we have to insert an smp_mb() at this point,
(not mentioning the other change in select() logic of course)

 static void sock_def_readable(struct sock *sk, int len)
 {
 	read_lock(&sk->sk_callback_lock);
+	smp_mb(); /* paired with opposite smp_mb() in sk poll logic */
 	if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
 		wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN |
 						POLLRDNORM | POLLRDBAND);
 	sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
 	read_unlock(&sk->sk_callback_lock);
 }

As about every incoming packet calls this path, we should be very careful not
slowing down stack if not necessary.

On x86 this extra smp_mb() is not needed, since previous call to read_lock()
already gives the full barrier for free.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHv5 0/2] net: fix race in the receive/select, Jiri Olsa, (Fri Jul 3, 4:12 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Fri Jul 3, 10:04 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Fri Jul 3, 11:40 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Fri Jul 3, 11:47 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Paul E. McKenney, (Fri Jul 3, 1:06 pm)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Fri Jul 3, 1:31 pm)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Tue Jul 7, 10:01 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Eric Dumazet, (Tue Jul 7, 10:42 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Tue Jul 7, 10:57 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Tue Jul 7, 11:04 am)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Tue Jul 7, 3:45 pm)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Tue Jul 7, 7:28 pm)
Re: [PATCHv5 2/2] memory barrier: adding smp_mb__after_lock, Mathieu Desnoyers, (Wed Jul 8, 12:34 am)