From owner-freebsd-net@FreeBSD.ORG Sun Dec 15 06:41:40 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 39D83480; Sun, 15 Dec 2013 06:41:40 +0000 (UTC) Received: from mail-ob0-x22d.google.com (mail-ob0-x22d.google.com [IPv6:2607:f8b0:4003:c01::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EA4701E27; Sun, 15 Dec 2013 06:41:39 +0000 (UTC) Received: by mail-ob0-f173.google.com with SMTP id gq1so3595268obb.4 for ; Sat, 14 Dec 2013 22:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2bK2hJGTglF2kVuY03nUv/Z7+anDWk4U53ZlzL5VMeY=; b=QBLoUrCjtsikj2GsiiYYQQDe3arIKgnoWkajAHQMFvrwGKuvABew42W2wnLiTEDK+S wkI3yRZlfXJAMRcK2XvTPwqQclhJy5BtrBOYS9Mlyp+b6++pIt+3mr1pezYHLUOIdtrI 9RlL0PFW+LM6Nq0kGVop/ePOhXVOxu6faN+YXuYb9P6TY7MhOuWIoKObz2SLM8kKeSxd 9W4xbyh94S50bc7/OLh+pPMhmtioK8FwK9WJruWYETFDPCUee9syN2is1XW6Up/1WAvi 7h1armg+c1H9T1Jtdg0Ggo03XsKwc9h/rKLtCOfDjIGn8nVgJbacwoab/d2xWYFTVdHo aN4g== MIME-Version: 1.0 X-Received: by 10.182.241.8 with SMTP id we8mr1967382obc.62.1387089699319; Sat, 14 Dec 2013 22:41:39 -0800 (PST) Received: by 10.76.158.225 with HTTP; Sat, 14 Dec 2013 22:41:39 -0800 (PST) In-Reply-To: References: Date: Sun, 15 Dec 2013 01:41:39 -0500 Message-ID: Subject: Re: buf_ring in HEAD is racy From: Ryan Stone To: Adrian Chadd 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 06:41:40 -0000 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.