Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp293840img; Wed, 20 Mar 2019 20:48:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqx++E83TY+WJAKJeDkVP7Tr1f82tTJm1M8JOYLzlRXALvQsO1pebLIyzjtvOVLk2fG2+bsd X-Received: by 2002:a62:a50c:: with SMTP id v12mr1344951pfm.206.1553140130836; Wed, 20 Mar 2019 20:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553140130; cv=none; d=google.com; s=arc-20160816; b=eCC1A8+kLARZnm8xOGnTguLzLSN4EztRZ7y0UysUueWz/ABPOFZ+PMOKkHK2GCr0Yu yxTYbSvF/Hiyi/2cvbCCPRApcteSkhXp2pI4OA0SqhjEkd8ENrWJmtZjn5uLUH9Wn+s/ iyCndPEGMzjh83t1kHyQOJWaLCDQwu7PbwKX285Tocby86tnt7xbwlOA+dMMND7fbqBb YSMPW/63mVk3ZA2S9oFs7iu9I33ScGCuqNNWzgnLzBTEi0F4AjKJKwG8TYBK1Vf6w0Bx TFMgTrMwl4nbtZjrY3U6ntQAcZzWwdrt6SYyGppiBzo7yzzymySWYxZ0u1TKJqzPq/sn kjsg== 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=560gdLQ9K5QkP6bOTK3jGWQLe35SKY2rQO0/WiF1Ojw=; b=zwZodBM+FXJlCUpIgtwiOX6wB1WMY4Hy/ErtSMTb30ZLXcJ2phaPlBHNCoFT5ChnNO mQT+fxGewqkxBntXp+dRMiGrmZwQkQqP2IcerugjZ3eeHm/ulk3BKkPIR/I6pTwLEMrj nz093nhAQ3JRiE0xGGRRqArjxvgTxSxUYKEeW7WNNJE0IFy/dWxqJLAX1/sk3x2IJP5P DuMEGOMJlwfwDVRZb5nU2lu3HNxfAQFTv0LLKl+nJgizaR7GdWrt1a3105fTtXcm/A0r LG3quOBQblp4QZErhVsJbxfAlKA4u1/jYDyVR+6UkpPbZEZTubN4IkpQ03J6rpRBkPPw WVtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iSL34AFw; 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 d12si3451811pgt.59.2019.03.20.20.48.35; Wed, 20 Mar 2019 20:48:50 -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=iSL34AFw; 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 S1727664AbfCUDr4 (ORCPT + 99 others); Wed, 20 Mar 2019 23:47:56 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36620 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbfCUDr4 (ORCPT ); Wed, 20 Mar 2019 23:47:56 -0400 Received: by mail-io1-f67.google.com with SMTP id f6so4143487iop.3; Wed, 20 Mar 2019 20:47:56 -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=560gdLQ9K5QkP6bOTK3jGWQLe35SKY2rQO0/WiF1Ojw=; b=iSL34AFw9dzFRe4U5h4Cg1pgYHWt1iO+0VStGQe1xYQMTiH+hB36qbyuCSYspOc3To 40IDsIBikJFCYCjFSHYF0q25eJknBWCWeHmlkTab1HPfqkSQY9HkQPWdZDUuQdh+McEs vcvkWjcD/W2rlX2C16Rcs3fY3Mt9xfWN1Usrq9Yr3PZycMc0gKlJ73A72+nnhS47hpoz pYeJwlapZdPQ+OcIDhXDY8hq7ZjDk350OLVDYapXNeC5NT9RlDzEBMvpCuyqehQtrHYi YX0JWOSQFT6mB5khmyVW79izoAWBrfeXN4JmKC+weAmGHuidSh1NL+8XLR/ceo26iBUV OLxQ== 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=560gdLQ9K5QkP6bOTK3jGWQLe35SKY2rQO0/WiF1Ojw=; b=OD8++Aeb9vG8ZdGxHuK6aqeiaKum6j7I4A+/smfy6IuylCzY1/VLDCmTQcvpz53ydE bTl+wl4kTFSnbRYtPJIsuwvtpZYKhh4Gkf2YGApNMXhBdCHmFlUWfgtFH6THTL1MpJWr OkZlH5X5CBtKmNuZ0+HK3obnZGw1//UuGtTYEyP1Dy/sQNAbYEXlsLKa3y5t3fMRdgGl mU094M9Hwmuk6qt9Zxk2dnaBNdnCm5IkoHTN1S6L2e4aBOVD6wccc+bToM0/hDuHzPue FwOX1tznnx0u8RT4GghR3ZCq1AGYXtiTHMXRI0I3GX+O9Y7qP9nP5SG+LFr7J4/XZQME 4CDA== X-Gm-Message-State: APjAAAVY7+FCic00MsQ2RXkRJxbWJ07nOf0wbLK00wPX53FnizPk/ZpD c1h3MpR7H0WqbJ7pmEYrokY= X-Received: by 2002:a5d:8049:: with SMTP id b9mr1166774ior.302.1553140075547; Wed, 20 Mar 2019 20:47:55 -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 v18sm2092974ita.21.2019.03.20.20.47.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Mar 2019 20:47:54 -0700 (PDT) Date: Wed, 20 Mar 2019 23:47:52 -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: <20190321034752.GA6828@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190320130619.07e49c97@shemminger-XPS-13-9360> 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 Wed, Mar 20, 2019 at 01:06:19PM -0700, Stephen Hemminger wrote: > On Sat, 16 Mar 2019 21:49:28 -0400 > Kimberly Brown wrote: > > > On Thu, Mar 14, 2019 at 03:45:33PM -0700, Stephen Hemminger wrote: > > > On Thu, 14 Mar 2019 13:05:15 -0700 > > > "Kimberly Brown" wrote: > > > > > > > Fix a race condition that can result in a ring buffer pointer being set > > > > to null while a "_show" function is reading the ring buffer's data. This > > > > problem was discussed here: > > > > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.org > > > > %2Flkml%2F2018%2F10%2F18%2F779&data=02%7C01%7Csthemmin%40microsoft.com > > > > %7C1d7557d667b741bdbb6008d6a8b8620f%7C72f988bf86f141af91ab2d7cd011db47%7C1 > > > > %7C0%7C636881907217609564&sdata=1bUbLaxsODANM7lCBR8lxyYajNpufuwUW%2FOl > > > > vtGu2hU%3D&reserved=0 > > > > > > > > To fix the race condition, add a new mutex lock to the > > > > "hv_ring_buffer_info" struct. Add a new function, > > > > "hv_ringbuffer_pre_init()", where a channel's inbound and outbound > > > > ring_buffer_info mutex locks are initialized. > > > > > > > > ... snip ... > > > > > > 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? The data path doesn't use RCU to protect the ring buffers.