From owner-freebsd-net@FreeBSD.ORG Sun Dec 15 20:47:09 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A27F89AA for ; Sun, 15 Dec 2013 20:47:09 +0000 (UTC) Received: from mail-qe0-x22c.google.com (mail-qe0-x22c.google.com [IPv6:2607:f8b0:400d:c02::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5FFCD10C9 for ; Sun, 15 Dec 2013 20:47:09 +0000 (UTC) Received: by mail-qe0-f44.google.com with SMTP id nd7so3322515qeb.31 for ; Sun, 15 Dec 2013 12:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=8wrtBR0u1GU6pgLkShBAUtVNnUmWPYxnByQVdGAd7qU=; b=wqQ0mcdTQWHsTcKiy7mQslUZkWTpwaQPSlcpaI+TweXpupBS1q4CYHsEkJOc4hb/tN HPjh7Ti5Q06qyeqcnfqnVnUMSjKLnx/SWS/+Et5Z5aPPxyd+83kdvylqqjCT2UUDMbVe /qhTUubv+Pq2z1NOZMC1vtiVFaxWv68GTggXyyMytkfi83JaR9JXx3VEemVZOW0ixuKn TSukx+CQav9F6esuCmuKabct/UtnVN4UcAT4j17rXG0xqd+VTWdeAAo0jbBV9qDJil9i XL3DsvnNEnuw5IWctdpA1gAhT3BZ2/XG4878AT4iLsJ2Pit+9OzXZKq2+AqewtqZU4Xj OSNQ== MIME-Version: 1.0 X-Received: by 10.49.17.232 with SMTP id r8mr26487666qed.74.1387140428618; Sun, 15 Dec 2013 12:47:08 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.53.200 with HTTP; Sun, 15 Dec 2013 12:47:08 -0800 (PST) In-Reply-To: References: Date: Sun, 15 Dec 2013 12:47:08 -0800 X-Google-Sender-Auth: U_sH3bjOT5bKzu3qpz6lbG6sr_A Message-ID: Subject: Re: buf_ring in HEAD is racy From: Adrian Chadd To: Ryan Stone Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Dec 2013 20:47:09 -0000 surely we can do this without critical enter/exit.. How's this implementation of single-reader multiple-writer compare to like, the dozens of other userland ones that are out there in the open source world? -a On 14 December 2013 22:41, Ryan Stone wrote: > On Sat, Dec 14, 2013 at 7:08 PM, Adrian Chadd wrote: >> Honestly, we could just do with a generic multi-writer, single-reader >> ring type that we can re-use for other things, rather than just mbufs. > > That is actually exactly what buf_ring is -- it deals with void *, not > struct mbuf *. > >> We could also have the code run in userland and do some very in-depth >> stress testing of it there rather than needing it to be in the kernel. > > For testing purposes this isn't very hard -- I did it yesterday while > debugging this problem. The one trick is that buf_ring uses > critical_enter/critical_exit to prevent livelock (which was woefully > undocumented in the code) so when I was testing I had to make sure > that I didn't have more threads than cores.