From owner-freebsd-current@FreeBSD.ORG Mon Aug 5 17:36:25 2013 Return-Path: Delivered-To: current@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 ESMTP id 5F3944B1; Mon, 5 Aug 2013 17:36:25 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com [IPv6:2a00:1450:4010:c03::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 45D9E2AB1; Mon, 5 Aug 2013 17:36:24 +0000 (UTC) Received: by mail-la0-f41.google.com with SMTP id ec20so2311991lab.28 for ; Mon, 05 Aug 2013 10:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=2rzT9Cecv/nAAHnMXSQ2bQxtOaPUdNq7iwzZrH2pVpQ=; b=l76mt1SMaPw/l3wWNi95/3Lt+IP+/kK07ID/9fhMJhC1ldi+EyzS2B7daf3tpDff+b q8zU8u957hmw/ryINMzjhXDB9men0kpa+vZSVDsCv7S4PdUPXg0ek6XcnzEykiFCcQB9 RQ8sr2tGfNJR65BgjPfQ0qWGUmNrp2J/vwESarQkhmLlAdgeS/rJhdeEhKqR00ykODEL pmp8moaoUct4+zFpmHe24hHOPwZakmxkSgEx4f+g51B1IqjKHdHNOSoEikB9MZCp0bHl VcyOhl75aAp+3DUaMbGfILQRb1imbvn5uOzJk64RK0WY6C2D4nMX2fWbNvzfap0ak/Mn yXcw== MIME-Version: 1.0 X-Received: by 10.112.11.20 with SMTP id m20mr1297788lbb.56.1375724182270; Mon, 05 Aug 2013 10:36:22 -0700 (PDT) Sender: rizzo.unipi@gmail.com Received: by 10.114.200.165 with HTTP; Mon, 5 Aug 2013 10:36:22 -0700 (PDT) In-Reply-To: References: <20130805082307.GA35162@onelab2.iet.unipi.it> <2034715395.855.1375714772487.JavaMail.root@daemoninthecloset.org> <51FFDD1E.1000206@FreeBSD.org> Date: Mon, 5 Aug 2013 19:36:22 +0200 X-Google-Sender-Auth: bRXHtflqCqaEThiVs5xN7NeSKLw Message-ID: Subject: Re: [net] protecting interfaces from races between control and data ? From: Luigi Rizzo To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Giuseppe Lettieri , net@freebsd.org, Bryan Venteicher , Navdeep Parhar , current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2013 17:36:25 -0000 On Mon, Aug 5, 2013 at 7:17 PM, Adrian Chadd wrote: > I'm travelling back to San Jose today; poke me tomorrow and I'll brain > dump what I did in ath(4) and the lessons learnt. > > The TL;DR version - you don't want to grab an extra lock in the > read/write paths as that slows things down. Reuse the same per-queue > TX/RX lock and have: > > * a reset flag that is set when something is resetting; that says to > the queue "don't bother processing anything, just dive out"; > * 'i am doing Tx / Rx' flags per queue that is set at the start of > TX/RX servicing and finishes at the end; that way the reset code knows > if there's something pending; > * have the reset path grab each lock, set the 'reset' flag on each, > then walk each queue again and make sure they're all marked as 'not > doing TX/RX'. At that point the reset can occur, then the flag cna be > cleared, then TX/RX can resume. > so this is slightly different from what Bryan suggested (and you endorsed) before, as in that case there was a single 'reset' flag IFF_DRV_RUNNING protected by the 'core' lock, then a nested round on all tx and rx locks to make sure that all customers have seen it. In both cases the tx and rx paths only need the per-queue lock. As i see it, having a per-queue reset flag removes the need for nesting core + queue locks, but since this is only in the control path perhaps it is not a big deal (and is better to have a single place to look at to tell whether or not we should bail out). cheers luigi