Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755282AbZKCTuk (ORCPT ); Tue, 3 Nov 2009 14:50:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755186AbZKCTuj (ORCPT ); Tue, 3 Nov 2009 14:50:39 -0500 Received: from mail-ew0-f207.google.com ([209.85.219.207]:36488 "EHLO mail-ew0-f207.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755010AbZKCTui (ORCPT ); Tue, 3 Nov 2009 14:50:38 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; b=fOWHehz5Uaf9w5IwMwb3+nFzMM4ObKX9uaG6s6rjsU/Lyo4UwsGKn0U6ewh/vTJARK wG7tHbh4YcdKG6uw1kz1ZRhl4naAvFlQhUwxKAJS8uRWdcDfEDX7vFF7MyrC8kl4TCTM TP4FPYUOFit21QiHcpFb7XGi5jGhDE5CD2ygs= Message-ID: <4AF0898D.5000704@gmail.com> Date: Tue, 03 Nov 2009 14:50:37 -0500 From: Gregory Haskins User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Eric Dumazet CC: "Michael S. Tsirkin" , netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@elte.hu, linux-mm@kvack.org, akpm@linux-foundation.org, hpa@zytor.com, Rusty Russell , s.hetze@linux-ag.com, "Paul E. McKenney" Subject: Re: [PATCHv7 3/3] vhost_net: a kernel-level virtio server References: <20091103172422.GD5591@redhat.com> <4AF0708B.4020406@gmail.com> <4AF07199.2020601@gmail.com> <4AF072EE.9020202@gmail.com> <4AF07BB7.1020802@gmail.com> In-Reply-To: <4AF07BB7.1020802@gmail.com> X-Enigmail-Version: 0.96.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEE35B5FA56BFEDFC91950F1D" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2922 Lines: 90 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigEE35B5FA56BFEDFC91950F1D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Eric Dumazet wrote: > Gregory Haskins a =E9crit : >> Gregory Haskins wrote: >>> Eric Dumazet wrote: >>>> Michael S. Tsirkin a =E9crit : >>>> using rcu_dereference() and mutex_lock() at the same time seems wron= g, I suspect >>>> that your use of RCU is not correct. >>>> >>>> 1) rcu_dereference() should be done inside a read_rcu_lock() section= , and >>>> we are not allowed to sleep in such a section. >>>> (Quoting Documentation/RCU/whatisRCU.txt : >>>> It is illegal to block while in an RCU read-side critical secti= on, ) >>>> >>>> 2) mutex_lock() can sleep (ie block) >>>> >>> Michael, >>> I warned you that this needed better documentation ;) >>> >>> Eric, >>> I think I flagged this once before, but Michael convinced me that i= t >>> was indeed "ok", if but perhaps a bit unconventional. I will try to >>> find the thread. >>> >>> Kind Regards, >>> -Greg >>> >> Here it is: >> >> http://lkml.org/lkml/2009/8/12/173 >> >=20 > Yes, this doesnt convince me at all, and could be a precedent for a wro= ng RCU use. > People wanting to use RCU do a grep on kernel sources to find how to co= rrectly > use RCU. >=20 > Michael, please use existing locking/barrier mechanisms, and not preten= d to use RCU. Yes, I would tend to agree with you. In fact, I think I suggested that a normal barrier should be used instead of abusing rcu_dereference(). But as far as his code is concerned, I think it technically works properly, and that was my main point. Also note that the usage rcu_dereference+mutex_lock() are not necessarily broken, per se: it could be an srcu-based critical section created by the caller, for instance. It would be perfectly legal to sleep on the mutex if that were the case. To me, the bigger issue is that the rcu_dereference() without any apparent hint of a corresponding RSCS is simply confusing as a reviewer. smp_rmb() (or whatever is proper in this case) is probably more appropriate. Kind Regards, -Greg --------------enigEE35B5FA56BFEDFC91950F1D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrwiY4ACgkQP5K2CMvXmqE4kACggLbxMKmUbWxvGmiXUR8MiQ7N rO4AnRYDdV3qH7rc0Roiavyzg1QagQTY =ZPHq -----END PGP SIGNATURE----- --------------enigEE35B5FA56BFEDFC91950F1D-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/