Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp228774img; Wed, 27 Mar 2019 21:31:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaJQ3H8a99V5k67DO+jr4gYXYxmV76J8rD3FNI1s1I7oTaFP6RZlSpcECdpjrMid5dyygU X-Received: by 2002:a63:cc0e:: with SMTP id x14mr38654632pgf.159.1553747517072; Wed, 27 Mar 2019 21:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553747517; cv=none; d=google.com; s=arc-20160816; b=jdWLJ+IAYfzfSI4NlpiNgcAuCzU9yZH3QVCR5xqWGmYh5H1qZ6WUEuFYTxk6ym7vp7 9w8oKxioCGP0c0uB7EZHBovaTMg70zCNwwU8R/0Y2adQrYE7JhiW/rARmkNe8KuK0oTA +VFHI0aLyW+aTexuU/t8/A99LUFvlGXgNhYkKb00vvorbCnEeyOXO6ljK+xaI1UMLRKN ittA1Zuqs9GTsFm2zvQkMt3spQb/rcS/hhsr+m6R+FnPeqzYJYs9PZTx3LWgaeaFr0Vp bT5UNb+tY51T6gY5yTRKmxxqaJTJ6EmdIlt/EqJIVm5nGo7U1/Mt47nBqkfE/jm75E08 UCCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=D+/belK3ejYzZvvz9x7FiTI3PQoVx/Ow2x/QOwiUhUk=; b=IVoHR6tT3QSIk3Coh+buPYIWc7fD2E8JtL7isJ4Hu3ezRAfzTqBmBp7RN4gF2geKWJ ondx7hCYgHmEMM8QKkOEQ1vSnukvGLhuM78V1lEBiSKJEttz8FydCwcTvKg+HrO6WFUe HqlzsllPhFmJx8Ak6BMkNzHW+XMepHIJ3ySd8uLMqlqE21FtBzjd1cUm7LRgSVcav0/x OkZU56Zd3S4ncYvAQcRpihXR4e95HwXhfEa+Oi/EZqOtppK3mTbNQtzH6AX9eW2KHpAZ TmzOK1L2uFD9hVj/JWZY7o/6ni2W5CyqNvKynfjStb4WzkPydPx4BuGdYOi5IhK/VoMD Uxww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=omDPTgo0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v31si21479790plg.2.2019.03.27.21.31.41; Wed, 27 Mar 2019 21:31:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=omDPTgo0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726108AbfC1EbC (ORCPT + 99 others); Thu, 28 Mar 2019 00:31:02 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36354 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbfC1EbB (ORCPT ); Thu, 28 Mar 2019 00:31:01 -0400 Received: by mail-io1-f67.google.com with SMTP id f6so16080740iop.3; Wed, 27 Mar 2019 21:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=D+/belK3ejYzZvvz9x7FiTI3PQoVx/Ow2x/QOwiUhUk=; b=omDPTgo0Bk1VdYEtxiVyT0fGl3cTpcw+pFHUoXeuC3deY4aw65tO8CKlwcoHU2rVUL Sme/FH6oTQHzT4nKU5bvEQa3JG5vT/kM3kZx6/CW1U7ZcyohFJWsRuQ8JZJfL11D2G8C Lf45Sd5IRMllo+rcE6vnusYCjwsmYTqYKYgHQ1562VPx8fbR7beJDusyQFkYQtHjtzEH RXnGQYvJGRiBkPFVqtXnT/lfPcat2unIL8POgB5Cz0jcrj2HCMWEIBD3PQ1H8RWsJmYb DE0uyZxoDNsEYrYhPr5a6CG75OJa+z8qgNYc4LJE17ib9caekbNSke4XLV8UcTNHrQRA Al5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=D+/belK3ejYzZvvz9x7FiTI3PQoVx/Ow2x/QOwiUhUk=; b=E8vd6q5+EvADwVEeBdH1hGLWHPDHRdToElGdbEAKGpIA5YZC6OZfGHXQ5GqQJoUsQt EndaHcU4q07ZugQBuBfRzuvmBOdHA5YPrYeNw465GN1KEUCcqIfhE/JjXF7fPvYGn6En ak68GJ5H3cDcSuz+p/ig1/RuzT6E+wKjSoYG1dBAT5wNfHb4qJVg0uf7g0xzYOGKkran rlCHMN9sKH7gkfWpyy3bCb3dJLg7BhZ9+lTVPZp1PnSZgo/oGoCpjj01Wo3G1UWddlCf uWU41aKIZTTXlZOwEPGRdKRQT/FwwMTOOduwYB49VHlr0qJ4u15cINK8St+1kKwoWM46 jqIw== X-Gm-Message-State: APjAAAXQsx8WoyyO4SNqkfq0CPiSpXtZTLFUC3Ky+EfF8ALCOoBIF3Yc ESLemS7XpCwpoVWrJ3+izw89sK2I X-Received: by 2002:a5d:87d3:: with SMTP id q19mr27223875ios.29.1553747460974; Wed, 27 Mar 2019 21:31:00 -0700 (PDT) Received: from ubu-Virtual-Machine (66-188-57-61.dhcp.bycy.mi.charter.com. [66.188.57.61]) by smtp.gmail.com with ESMTPSA id u204sm1237526ita.33.2019.03.27.21.30.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Mar 2019 21:31:00 -0700 (PDT) Date: Thu, 28 Mar 2019 00:30:57 -0400 From: Kimberly Brown To: Stephen Hemminger Cc: Michael Kelley , Long Li , Sasha Levin , Stephen Hemminger , Dexuan Cui , KY Srinivasan , Haiyang Zhang , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 3/3] Drivers: hv: vmbus: Fix race condition with new ring_buffer_info mutex Message-ID: <20190328043057.GA2258@ubu-Virtual-Machine> References: <262046fa9e89d5f483ecd5972d86f4f9608dbcc3.1552592620.git.kimbrownkd@gmail.com> <20190314154533.17c8a362@shemminger-XPS-13-9360> <20190317014927.GA60356@ubu-Virtual-Machine> <20190320130619.07e49c97@shemminger-XPS-13-9360> <20190321034752.GA6828@ubu-Virtual-Machine> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 04:04:20PM +0000, Michael Kelley wrote: > From: Kimberly Brown Sent: Wednesday, March 20, 2019 8:48 PM > > > > > Adding more locks will solve the problem but it seems like overkill. > > > > > Why not either use a reference count or an RCU style access for the > > > > > ring buffer? > > > > > > > > I agree that a reference count or RCU could also solve this problem. > > > > Using mutex locks seemed like the most straightforward solution, but > > > > I'll certainly switch to a different approach if it's better! > > > > > > > > Are you concerned about the extra memory required for the mutex locks, > > > > read performance, or something else? > > > > > > Locks in control path are ok, but my concern is performance of the > > > data path which puts packets in/out of rings. To keep reasonable performance, > > > no additional locking should be added in those paths. > > > > > > So if data path is using RCU, can/should the control operations also > > > use it? > > Hi Stephen, Do you have any additional questions or suggestions for this race condition and the mutex locks? I think that your initial questions were addressed in the responses below. If there's anything else, please let me know! Thanks, Kim > > The data path doesn't use RCU to protect the ring buffers. > > My $.02: The mutex is obtained only in the sysfs path and the "delete > ringbuffers" path, neither of which is performance or concurrency sensitive. > There's no change to any path that reads or writes data from/to the ring > buffers. It seems like the mutex is the most straightforward solution to > preventing sysfs from accessing the ring buffer info while the memory is > being freed as part of "delete ringbuffers". > > Michael