Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2145588imm; Thu, 18 Oct 2018 09:43:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV61fPr2jKqQS+Bh6wmLzTlzGqriex2wqRNIQpdBgnbreW09u3g73nkYQgDaus5Z7sdgELmAZ X-Received: by 2002:a63:9f0a:: with SMTP id g10-v6mr27893678pge.232.1539880984278; Thu, 18 Oct 2018 09:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539880984; cv=none; d=google.com; s=arc-20160816; b=G+Di00JWYIQy4zXprMvlkP+e4t3joaPQKCavsaG3Dnsrl5a8kc3ee1Q1l1E9kkpsQ5 Df8fZPBIeAHkPgUhs+iYwfzAR9mg35j2WhxU6YK0Cu6xZd4laq+qEXQV7gHtpd4EdAKp vZMcX2057LTMpwS9i/ZCnyf3K/QHuSrcjDlantPSR8Q0LPacsL7OFacpD8+xhEPr2hVp cHbJdRRcj5SPMUOrD7KnhXJGR6kdPzIG3AG/TReXu6X5HM79cMGLscbdGmV1hkNt51eG ZFy7caXk0s/BkweGz17YaKR7bqHwp1GJ5jGd+t4SkCNFd49DD4mW38siWAejNU3cdxm0 8FjA== 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=hD2UDmBptUsKoR5mlLPU73uQ4qeYO1A2VnT5183hWhg=; b=vQxNTZcuhO6paA9SFqqCo4sENOdYb8XCa5HN75X9+KlDVWKO6flduPiK0sD9uWWZtN Z+Zo47KkWJlplEEFYb1ZCkY/kBTFd4n/vjSBkEk3G9p4Q/jO5srsG8kSzIo2Og8gs9Pz pcHzkcSq3k63nlsWJqsVan229sefpAIRvmq1+lYHSY8oUoukrQSD295B8tJlUqN4oVRi cj1EuKMLnlbhNZKJeAMhY5BVtGk9Z+bt8OCL4COL+B5+JDXDQsUnqNnhC35NT1+n5Px7 Yw4i1S2nn9mq2MmVdxaFFTII1e32dXXpNMxTl7xwDtXtMEC8agynVGRVwp2vCiK15T4G oyUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=n1kWfhyS; 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 be11-v6si2699672plb.193.2018.10.18.09.42.48; Thu, 18 Oct 2018 09:43: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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=n1kWfhyS; 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 S1728433AbeJSAnj (ORCPT + 99 others); Thu, 18 Oct 2018 20:43:39 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46554 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727402AbeJSAnj (ORCPT ); Thu, 18 Oct 2018 20:43:39 -0400 Received: by mail-pg1-f194.google.com with SMTP id r190-v6so2820396pgr.13 for ; Thu, 18 Oct 2018 09:41:52 -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=hD2UDmBptUsKoR5mlLPU73uQ4qeYO1A2VnT5183hWhg=; b=n1kWfhyScmT+fKNO8kRQETw0i7EEmPuraxf+G3v+5B6gcaoDGKs37Zzp5G8Zrytg2K rGtLXMQg4TZztwi4Ek2E14Fyqgym2MeVd2hAjBkVhwWf0ANe5NJ/whaWMXuASyZKmFEF r8cozq3WCetNhNbkVYtF0hYr0jwhf/mO9TX2zM8KKS/hUGpp26DRUlyRe/2BHJmOTPV1 chHz1aD0Vl8s3VhPuVk2ubUmRPyRACv3Bqib95NQVzXgUDHisMiU9NWjlCJUlvFnFSch iCp/kHtsKUB3E3xsHHtgAtAKK4HDakxhg7T8VLQbelSkjCj4Bqq58S8tpcJh0/xZIcD5 /UhQ== 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=hD2UDmBptUsKoR5mlLPU73uQ4qeYO1A2VnT5183hWhg=; b=dqcIY7agLlYFyzA3Iwfzf2IoUvCfLysaL1kZeKPqg9egh2vmPrHF0EuiVlqaf3X/Lo 7aLdANhyVxF4G+EfYEqdtPgfLhxrmzbOAExSgE88EURKlS/ogUNbdxSSU+UekTJYSpYj e58+9FnMjJSmFywfeuQ7txJecXTOxxKbkZwov0GNvIY/0z7PQRzmbM/SmMT/ZDTKs/pH TJKZ/gpwV5H2MAA3uL2gxhUxaGmmSGxkwglPcQnFDwwAmkG9ipncbPS/141CzP4Oo0is W8HPj2l+FC8NwWEo4+KKCp+F9cCxpRRbAs6CN2kkPREyfcpfEp84ecOxEDuUz0/q+eCY 42TQ== X-Gm-Message-State: ABuFfojUf7qtU45udG0g0+qVqhdQUSN6Ki2Rm6JzI+13gweu2B/Zr3YF UKkCMaDbO7RLXFB/BOo6Nnd9Jw== X-Received: by 2002:a63:5224:: with SMTP id g36-v6mr29584985pgb.253.1539880911707; Thu, 18 Oct 2018 09:41:51 -0700 (PDT) Received: from shemminger-XPS-13-9360 ([167.220.99.60]) by smtp.gmail.com with ESMTPSA id e3-v6sm27538387pgc.71.2018.10.18.09.41.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 09:41:51 -0700 (PDT) Date: Thu, 18 Oct 2018 09:41:45 -0700 From: Stephen Hemminger To: Michael Kelley Cc: Olaf Hering , KY Srinivasan , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" Subject: Re: [PATCH V2 3/4] vmbus: add per-channel sysfs info Message-ID: <20181018094127.6a48fa55@shemminger-XPS-13-9360> In-Reply-To: References: <20170918034955.10913-1-kys@exchange.microsoft.com> <20170918035419.11062-1-kys@exchange.microsoft.com> <20170918035419.11062-3-kys@exchange.microsoft.com> <20181018171953.079f6fb6.olaf@aepfle.de> 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, 18 Oct 2018 15:32:35 +0000 Michael Kelley wrote: > From Olaf Hering Sent: Thursday, October 18, 2018 8:20 AM > > > > > This extends existing vmbus related sysfs structure to provide per-channel > > > state information. This is useful when diagnosing issues with multiple > > > queues in networking and storage. > > > > > +++ b/drivers/hv/vmbus_drv.c > > > +static ssize_t write_avail_show(const struct vmbus_channel *channel, char *buf) > > > +{ > > > + const struct hv_ring_buffer_info *rbi = &channel->outbound; > > > + > > > + return sprintf(buf, "%u\n", hv_get_bytes_to_write(rbi)); > > > +} > > > +VMBUS_CHAN_ATTR_RO(write_avail); > > > > This is upstream since a year. > > > > But I wonder how this can work if vmbus_device_register is called, > > and then something reads the populated sysfs files before vmbus_open returns. > > Nothing protects rbi->ring_buffer in this case, which remains NULL > > until vmbus_open populates it. > > > > A simple reproduce, with a modular kernel, is to boot with init=/bin/bash > > head /sys/bus/vmbus/devices/*/channels/*/* > > > > There are multiple race conditions with this and other VMbus sysfs information. > There's a race on the close path as well. I've got an action on my list to get it > cleaned up. > > Michael > There is also a bunch of issues with code like: static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr, char *buf) { struct hv_device *hv_dev = device_to_hv_device(dev); if (!hv_dev->channel) return -ENODEV; return sprintf(buf, "%d\n", hv_dev->channel->offermsg.child_relid); } Which should be using ACCESS_ONCE on hv_dev->channel or doing proper RCU.