Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp766003ybb; Thu, 28 Mar 2019 11:44:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqw908JYOXn+Sc8I5LqbhTulTNb7/myJmFt/PVHvrwhjfoUVJdb4DUtBoarNloLbkNleYYq7 X-Received: by 2002:a63:1b1e:: with SMTP id b30mr42185781pgb.180.1553798653571; Thu, 28 Mar 2019 11:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553798653; cv=none; d=google.com; s=arc-20160816; b=z1NP+6p6T+psJlqYQZIds5lmH+wvHYAitb2xR7LngbxRvBOuTb2UYuQyiQ1sIg1dKb 80raq6Rchgrqh1ub9GrtbiqHu1riiVPN7MjW+0LYl6DrELvKJb6MJiyl2h/X8P9uwf8H wHjj/ZB7hJSU1xg2+rio6JAozpxoCs6WL1Si12wrC6zJczpKn8NogQGV4x1yr+2zurZ2 BoRNQWhomFic/Z0rwlAt+fH62VBe6Ze/AT+ThedRnK/Bye0X/cdWbHvEyvMgmO9h4Ktv U14RBvU/8KPxo0JvfPYJdukJi2Hqp5oRpJKPYQfLRVvCRyAl7mZsT7bveg5n7Wvr5hGm hzTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Rv3xOx06ONzKcqZs5Vl4PEhFLYUziQzUKeg/lcUkaFg=; b=rMGBDTFcivET+rFLemsmMHD9ck2CoqfJ0zJNgrXjdCestIHwmbBNOI4Trq6jZtyulW EEEIcThgAKFecTbtfmzvdK/OE3QdUHi0rhfUEyI4IGC/Wl6Ha2HV1sHTs0U+o7dLOjXO ZD6+UIikY5ye2RYU8tN9jVhTS8ZUeqklGEooRAfcuew1naDiKCLc40cgl4LC85dv+nnw v4lNYG0V+HVS0av4IkeiKHwFbhsG6eXhAPIaN3blc497XWeM4AexQfrYxsblHf813xEB 0GFzWhpgvgcvyf2ZRl2+3HP43kU/xs2CrkRo+JtQeapGBoM+O2/UYSIPXFb1Qz/VSXNG RQbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=ClF61nAn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l37si9680272plb.173.2019.03.28.11.43.57; Thu, 28 Mar 2019 11:44:13 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=ClF61nAn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbfC1Sm5 (ORCPT + 99 others); Thu, 28 Mar 2019 14:42:57 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46786 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbfC1Sm5 (ORCPT ); Thu, 28 Mar 2019 14:42:57 -0400 Received: by mail-pf1-f196.google.com with SMTP id 9so11730661pfj.13 for ; Thu, 28 Mar 2019 11:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rv3xOx06ONzKcqZs5Vl4PEhFLYUziQzUKeg/lcUkaFg=; b=ClF61nAn6JlYF+ABRyLt4Q61GZXPIwMEVSXO/n9HVR/1x5MjQFAWKH+SS89+m4fiW5 nXUjiJH2iwC+RrQevjfz3vA3HttX4aN1OY7eG52ewZbj6LHmCOPXfX73NX7d1x0rQN8k guStPH/EFj0xK8qJ0eW+b9ePGpUsQqK4S6I7hugLgEusn2iE07mO17MfZOnHgNtnLhQR THRzUUuG8dVMVMVpyUU4/Jx7bIgbH2INpgstJ3zZX4SN12B9vpcepxvNiKyKYsLXEE2Q OGfCfahytXVLBvod52rZBHSoT/a6ZAc9U8WVgPj78yKPBv43SquvTsLKia0T/Bsra2SC FEqw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rv3xOx06ONzKcqZs5Vl4PEhFLYUziQzUKeg/lcUkaFg=; b=LfRw7e4a1xHxUuOIWZxIDqvNJLxgIIaUFKFR3xzvySF+tDc1UA7k3mBCL0Jry0qb8u 6kfSq1+lg+xmyAge+T2Y4U3qMnvFKgZB68+Ypt05so5sMO/hN9FEwBI8H7D5OZP079r1 Ch+byeWbmllBUfGaIWqfd56oihnbtmTE7dVSE7WplSc6OMzi+kfRg0hD8KQM0DfJbeVt AJ95taLNT4cEfHl2DkRz4bt3PKwtCOJvmbrQf06L2rXwyaV1/gEHkM2vJKXEAVR/l2tL enqa9tC0EI6tONBt4oN+yeD030MYFH3wuFl7lLpAGikDY9+4wrF45qU6sjh74zBVwoZQ UBsg== X-Gm-Message-State: APjAAAXjpv0t3hvjWnp9bohRCoGDWw/BSEW0AgcjcK5JKyv70sZNpNST NSfMMFQzwdpbBUEpmpB8DhNigQ== X-Received: by 2002:a63:c00a:: with SMTP id h10mr41632938pgg.272.1553798576742; Thu, 28 Mar 2019 11:42:56 -0700 (PDT) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id i64sm37086434pfb.112.2019.03.28.11.42.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 11:42:56 -0700 (PDT) Date: Thu, 28 Mar 2019 11:42:52 -0700 From: Stephen Hemminger To: Kimberly Brown 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: <20190328114252.141bbcd5@shemminger-XPS-13-9360> In-Reply-To: <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> <20190328043057.GA2258@ubu-Virtual-Machine> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Mar 2019 00:30:57 -0400 Kimberly Brown wrote: > 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 I have no problems with the patch you did. My discussion was more around the general issues with ringbuffers being detached from the device. Not sure if it was even a good design choice but that is something that is hard to fix now.