Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp852475imc; Sat, 16 Mar 2019 18:51:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSy9Gu8qpy0rc/eI9nkDebZeSfpjKiQJYuP8BtPqDPowC47QsV+CM8/ADISLvrKo8eOgqc X-Received: by 2002:a17:902:e00d:: with SMTP id ca13mr12446935plb.206.1552787464796; Sat, 16 Mar 2019 18:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552787464; cv=none; d=google.com; s=arc-20160816; b=E1/JvivKXhBjr+Z0v7cG4kqq+zWLPTzZkWJxY+yRy+4cbFEtcSrHjmblU9+XeQnIPZ as/XrtaCJ2fqSB7dRJNzU47fklWU3ohe7OtYcUjc+htREKjWfMl9Uc1Jay6ecNEoCJz0 wmTgi6nl7rMRSPUb18HNw8RU+cLz1qYcMajTE9sVQc/XwZGs4UfZJKkLEpUYNrI5dQPv VanYjj+4pyuBvuZzJYzA0KBnG7okzY5PdmDFEx3ick+YA1kT9ppj9hyP56AKmcYvrQIS nZBLmNlH4IF6Wxi5QX8lIvqCJIhgCPWQPM3CyP+TglQ4P/DtOxrFKKcvQtc75p7+o05k xhzw== 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=TmEotmm+GdQGzl1fbL9drIiYRUCp/u1tAcuhI+o4qzw=; b=lV2yXa+HZq8Z/2rIbwGm1moN/L9RuVujq7TxqfCFCLo+fmPPjq+5kPUT10OPuuUey7 zbt/Oq47KjC4DIK7okkJkiW7gitxR1lsmS0WQL0XXh2D5xVaNsXnAFUqdxCzTNaGOIUT kbizUz4ucGeLfvQPm6UoEErXqY2s5km/Vz2o28odH9w4LF1dXbkhyb0iiFeS6h2hv4ha OgIot5cAh4rXGiRrx+iTuTaHG7LGp79JDhKR1RFNLejPa3WyiZHGnSqTkrUz4d7dClBs /7RJHtPKiajSndDRTcv2UCXsmXlPO6+IoCiw43xxwWODmZHo1CKZtmNu/tLf6D0k05At VsQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AID9hOO6; 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 z11si5532569pgu.306.2019.03.16.18.50.34; Sat, 16 Mar 2019 18:51:04 -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=AID9hOO6; 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 S1726927AbfCQBtd (ORCPT + 99 others); Sat, 16 Mar 2019 21:49:33 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:38748 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbfCQBtc (ORCPT ); Sat, 16 Mar 2019 21:49:32 -0400 Received: by mail-it1-f194.google.com with SMTP id k193so16518565ita.3; Sat, 16 Mar 2019 18:49:31 -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=TmEotmm+GdQGzl1fbL9drIiYRUCp/u1tAcuhI+o4qzw=; b=AID9hOO6EkpRxcNqi0jacbMZAzyDNGgFJvaAJ3C6pNO9rPRrNxZ/H087u6iwaEosCD KfA8H2SdiWyTv/UJdc//F8hBj1eo0LtN6zXaDe9e1iov6QBdH92WP932gt5RQU6K+Y7k D+AUtvZRM0RKBgUz9PXc5lzLNpenNr8F2X/lncb6T9hg6UBoDfIVDvLYKqy8NcJJY9Ti TvNdPcu7OCqzjum6LGMZCEcIC4zX3HbL+soBtrKIkhEN89F9mufsG4XK679VVYcx8OVS 4gIPYnQZ1lbMJndIO8MktTJ/GJipyC1kUTFczLbP13927rI9aRJ9ouhKleBXVEnXn0ZM 0qSg== 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=TmEotmm+GdQGzl1fbL9drIiYRUCp/u1tAcuhI+o4qzw=; b=EaLabrEH5U/k+NP2ukuNb/8Zd63AreZNAdViRiuDjGJHMAvtUistkWRfo8YtFx1ulh HIE/nn8nMvtuPn8c8ooKC8rdRQPK6k2v+dFkYGCP6Qw5FHg7drv/vWqGUp6Y2J/OlB+Z WiJdomq1xpSy5Kzd1k0LpqL3Qtnh2DbWZwWBDYwTkejgAObkCWObfcBJsoxJqGhmYKFO d5ILdQaIez9e7XjcO+U6bppv7j5EiY3diF5gpSsZr62RJAzG7x5z6PvDZ7oh8eMRn134 rjhVzoQJ20quJoLZXkftm9KkvUHcCTn8qaCjd8G/KasGSWLQ950JrHdIOpQlIUq3ZikJ pCiQ== X-Gm-Message-State: APjAAAXaOEGnnL+ObRcGNf3519t3QHKNG233SIdnWVeB3wwctx7mZk/I Bog3opngb9hYLXfAviCuOHs= X-Received: by 2002:a02:a589:: with SMTP id b9mr7248428jam.40.1552787371293; Sat, 16 Mar 2019 18:49:31 -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 134sm3230284itx.29.2019.03.16.18.49.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Mar 2019 18:49:30 -0700 (PDT) Date: Sat, 16 Mar 2019 21:49:28 -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: <20190317014927.GA60356@ubu-Virtual-Machine> References: <262046fa9e89d5f483ecd5972d86f4f9608dbcc3.1552592620.git.kimbrownkd@gmail.com> <20190314154533.17c8a362@shemminger-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190314154533.17c8a362@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 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? Thanks, Kim