From owner-svn-src-all@freebsd.org Fri Dec 2 08:11:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3125C61C07; Fri, 2 Dec 2016 08:11:34 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-ua0-x241.google.com (mail-ua0-x241.google.com [IPv6:2607:f8b0:400c:c08::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B47661A59; Fri, 2 Dec 2016 08:11:34 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-ua0-x241.google.com with SMTP id 20so23916331uak.0; Fri, 02 Dec 2016 00:11:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fgWf/SQqnxAjOmJ95ecsj5sL7V653hdKW12szq2ax6g=; b=00rG8UgUx4z1nLPQdUbg/MNajpA7k9COe3hEyeVSDaVeLJplrNVcyz2FX0iqeenwpt f8oUaUD4Z40cUu4sMgDqpHiGZVcvzgy2p4aHeMAGnY9iSgwII6y383KBWqjFlG+JxknC 1E6+SXe+HoG3nYYrbHF9AKETj/XZ5Fq4UctnwlQnWkeJHu4NhibvIWP9sEfjb+nktgUM F1wDUcdH9B70qYGWX1E4T65j/fAUJ50O7CeCGfO6Dom3yZ5x1Z2kfsQgBBzfN8O4Odg4 dUz5LeuCdZCYLl6V3c2+mAWS/aDi+9UlrJXUUT4DeSwunz0Y/FhjVOoWz1On0dL7h6RN ZC/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fgWf/SQqnxAjOmJ95ecsj5sL7V653hdKW12szq2ax6g=; b=jdYMKMdekdlKCDMK1M9aLYYSTshgakQuz0/7Xn3sFhwzvKUDoke/cnY4en2VgOYcOm XMUHljd1RTME2wwtsOTEi012o1fo5NeQ18iCeoQtjf9N8B2zDbfz+MIojCDbNz5Q0h4F 2y52E/MmD8ZszoZb08SEmNxEVdEKv0+sCtsSzAerBW8OI5UKNx4SLkoeS25ue7UZfgbl +1Kv0+5nCiJ6xoqUJxE1DjeOG1fiZ2PfSuAVwANpCtDYkdBEUwZsocUUJGVF1TiSLGUo SJ2cexWIYf7wmVVs0iZ4DFHv/pBZEcd59APSYBuLxCHbfBCvzlYQ6kuHcbYZhn6KnwYh U/vQ== X-Gm-Message-State: AKaTC0163zXyi30NU0g8N+0Moaq5mKCQKdG3OmuioanSo/qrL64Ii6fH/o+TJjGp7pAoLj0Z3humUWBjCdKQ3w== X-Received: by 10.159.55.168 with SMTP id q37mr32967920uaq.63.1480666293502; Fri, 02 Dec 2016 00:11:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.5.198 with HTTP; Fri, 2 Dec 2016 00:11:32 -0800 (PST) In-Reply-To: <201612012108.uB1L8g19026075@repo.freebsd.org> References: <201612012108.uB1L8g19026075@repo.freebsd.org> From: Sepherosa Ziehau Date: Fri, 2 Dec 2016 16:11:32 +0800 Message-ID: Subject: Re: svn commit: r309372 - head/sys/sys To: Ryan Stone Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2016 08:11:35 -0000 peek_clear_sc is added to address the issue you mentioned. IMHO, this commit weakens the proper assertion. On Fri, Dec 2, 2016 at 5:08 AM, Ryan Stone wrote: > Author: rstone > Date: Thu Dec 1 21:08:42 2016 > New Revision: 309372 > URL: https://svnweb.freebsd.org/changeset/base/309372 > > Log: > Fix a false positive in a buf_ring assert > > buf_ring contains an assert that checks whether an item being > enqueued already exists on the ring. There is a subtle bug in > this assert. An item can be returned by a peek() function and > freed, and then the consumer thread can be preempted before > calling advance(). If this happens the item appears to still be > on the queue, but another thread may allocate the item from the > free pool and wind up trying to enqueue it again, causing the > assert to trigger incorrectly. > > Fix this by skipping the head of the consumer's portion of the > ring, as this index is what will be returned by peek(). > > Sponsored by: Dell EMC Isilon > MFC After: 1 week > Differential Revision: https://reviews.freebsd.org/D8685 > Reviewed by: hselasky > > Modified: > head/sys/sys/buf_ring.h > > Modified: head/sys/sys/buf_ring.h > ============================================================================== > --- head/sys/sys/buf_ring.h Thu Dec 1 20:36:48 2016 (r309371) > +++ head/sys/sys/buf_ring.h Thu Dec 1 21:08:42 2016 (r309372) > @@ -67,11 +67,13 @@ buf_ring_enqueue(struct buf_ring *br, vo > uint32_t prod_head, prod_next, cons_tail; > #ifdef DEBUG_BUFRING > int i; > - for (i = br->br_cons_head; i != br->br_prod_head; > - i = ((i + 1) & br->br_cons_mask)) > - if(br->br_ring[i] == buf) > - panic("buf=%p already enqueue at %d prod=%d cons=%d", > - buf, i, br->br_prod_tail, br->br_cons_tail); > + if (br->br_cons_head != br->br_prod_head) { > + for (i = (br->br_cons_head + 1) & br->br_cons_mask; i != br->br_prod_head; > + i = ((i + 1) & br->br_cons_mask)) > + if(br->br_ring[i] == buf) > + panic("buf=%p already enqueue at %d prod=%d cons=%d", > + buf, i, br->br_prod_tail, br->br_cons_tail); > + } > #endif > critical_enter(); > do { > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" -- Tomorrow Will Never Die