Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2142563imm; Thu, 18 Oct 2018 09:39:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RZe0Y3XxyUaFENe5JarvcOrkdswlKDxTUWu8hWEl60shl0r9uhieHUbkuTwd94OJ1KaNM X-Received: by 2002:a63:565d:: with SMTP id g29-v6mr28710381pgm.227.1539880794212; Thu, 18 Oct 2018 09:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539880794; cv=none; d=google.com; s=arc-20160816; b=PtUU3ADLafJ2K6MP/S4rQUCp0w8qyzm3CbSmC0ZzK/aWy/5lsDNCfOGtFctStGmwKS HL3YsN3gTOYem5b+GQTj2A3cdJT4VFGCEHDESwp/UuQlA9fG+9o2oETIk7RfX0tbAuck TXDipYRQwRApEZI8hA7QT6m7E2aR7aNAcHpk6i4wYFzXPQYgAMomJ+6EpU8iPnT36nJU XuBmVZditpkohpAl0d0nzNEQUkSoc8xcymRUE2ucGL3quxqNUD1NETW3MU7GEZCYaXla gmMpX/O0p0vfDNZYrZ+PhJrUEdsY4OcYirb5NGQcmzC4+S4hi5lEq82yZTW8cfmdHtSK Oh8Q== 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=n9cayDzcVMP4WLKuDaSK5zDDTxeiv+ZcJ/644yHDAQU=; b=CopuV9nka6WYIejFF2W2uNA/OHzvpQHijEzxyRqfRBMYMwhnjUCDKPGLyr5XLnWee4 GHS0bwIklg6pUa/DsfoQR4fxI4nHb7JfZ22YdDmePzP61ph1ZtBfI//sNxJU9CdUCArV ER12mFTaAhS4JcL1Jua1sXb+yt+EyGqSwrkuwrEyrjEQ1JcruZjYhQVJWSaEP+ucwrX/ WYizlNVRBWuXlEtHxJ3Dcf14a9vHixwEJrN+LWVJGIvFYoQYORozVjWc79do1LWIaOOY xglBMCs9s5BLEUva6zbhGtV19pLyNGNFswFj2/tjvoQ44HxfM2Jul7PDWtSmP3L84N1E kp+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=FqinnVBq; 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 p33-v6si22284068pld.57.2018.10.18.09.39.36; Thu, 18 Oct 2018 09:39:54 -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=FqinnVBq; 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 S1727963AbeJSAkv (ORCPT + 99 others); Thu, 18 Oct 2018 20:40:51 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46888 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbeJSAkv (ORCPT ); Thu, 18 Oct 2018 20:40:51 -0400 Received: by mail-pl1-f195.google.com with SMTP id v5-v6so14558032plz.13 for ; Thu, 18 Oct 2018 09:39:05 -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=n9cayDzcVMP4WLKuDaSK5zDDTxeiv+ZcJ/644yHDAQU=; b=FqinnVBq9YhYlfg/fXTTZVtk0EpfL8v1W9eYVkj0VWYi5L4DsgbisNSDY5eIV86YF3 mN2TEc9uMZUiDhhNwya7IiOeUszkeefa/zDcJZu42ucC6bStLHI1Gs09dYsQwnl78Gmy H1bRoETBZx2/VjsMMdPatAkmmVmabS0sbF49YSM4TyYGqu/dlRiOiATKfYrIRQvkqZgF FNhPyPYPizxjoa567FrgFQC1rH4UOYBR/6JbOF/QG+9gsT40xa1h9Cg9JUfoxnvbNCbJ tt+Ntfhp9wHwEi+oSzGuFdv+gZvN6Lu3VsKJwkh5MV2fGUH6Et/Fh3vuoT5wu2x/gPes 9RjQ== 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=n9cayDzcVMP4WLKuDaSK5zDDTxeiv+ZcJ/644yHDAQU=; b=kM+buqno6Yo9AtQdEY1d8qSIFeE3iOk/X0xa71j9OuMXPGfLvsl8xKVRyYT3s6LvJ7 taW8181exN4hS/K+AC0SwcbqNLN9BvuAZHB9GYDJEKBNzLHZblzP1BcwFcLiEz1DUW8i YQUjf6JSzmq9jKKM2pS9JxqLwpR6EM7rnIychnQcqT9GCUKJslcJNG9sNxD4EWhELp9I 0lafyyPVXqYuLRWMyhIO4snP02NecQRpQ4hJwwC77MdfJTO2gAFuBuan4vHsCF6bIpTH K5F9a+Z35Pwb8dymlU5ApVGRQ/tQp2McjNEwhWtT5hPOtPUGSBgFsmsqty+tSVNR471p Lm7g== X-Gm-Message-State: ABuFfohiKNmPGNJVETDNa8yQ4EBC3sCu2SyTslF7l3wJcdlVpYom/qmg +zooRrW1l+6ne5mZVS6U55wAaQ== X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr19215642pld.131.1539880744703; Thu, 18 Oct 2018 09:39:04 -0700 (PDT) Received: from shemminger-XPS-13-9360 ([167.220.105.188]) by smtp.gmail.com with ESMTPSA id a1-v6sm32981925pfj.38.2018.10.18.09.39.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 09:39:04 -0700 (PDT) Date: Thu, 18 Oct 2018 09:39:02 -0700 From: Stephen Hemminger To: Olaf Hering Cc: kys@microsoft.com, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org Subject: Re: [PATCH V2 3/4] vmbus: add per-channel sysfs info Message-ID: <20181018093902.7b36c570@shemminger-XPS-13-9360> In-Reply-To: <20181018171953.079f6fb6.olaf@aepfle.de> 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 17:19:53 +0200 Olaf Hering wrote: > Am Sun, 17 Sep 2017 20:54:18 -0700 > schrieb kys@exchange.microsoft.com: > > > 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/*/* > > Olaf Good catch, actually the problem goes across all of the ring buffer sysfs files so it existed long before that. The channel ring buffer could be missing. I am less worried about the open from init case, and more worried about issues when channels are closed (as happens when changing number of channels on a net device). As Al has pointed out for years, sysfs is riddled with dangling reference issues.