Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1976404imb; Sun, 3 Mar 2019 13:12:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwIYWz24OxpUaq0NtaoT3u1kjQxxTKH6X/KFCHM3Uf2M+aTTN+/mzyp0G/2289e0yjPOQx2 X-Received: by 2002:a63:c449:: with SMTP id m9mr15309548pgg.41.1551647549732; Sun, 03 Mar 2019 13:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551647549; cv=none; d=google.com; s=arc-20160816; b=iBRnKebnyzy/F9QJ//Rp0T1CkAy+tT2DlmoMv3cE36F1dAgANLX5T1wP0mEXmlvmEm CyRodg/Ua/XDdCfyTICT9zHFLLY02xKoT5OSqcZs+9TRyG58Yd1mz5PkUlLDtlUEOheo JAV7L1PsCBV4DtdSjlTjmCt5rKHI4fdjm14lpPJjug2plhGZjWnayqG3thjOW2H7cPwc baSXIbi1o+2sf36A7Mgt+ohXWJimRFIMMyjyLwyIxP1TPosLARzbJwPLCi3xn/Uyuv41 TrjXTcYVz+BzNnF942mcbuo0C/guYf5RuBfWGA+ptM8MShQHrKe/NJ7/lFYca2qfqiRF IsMA== 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=UlqwdBoM26XzEO4IUZVTE3fMlYnL5azn8awk8TJxkC0=; b=c/09FB8npsAZfr4T1VnHdP+vM61GwFmpaAejvm7C9fhTw5iWy5GFMisYvttZgZC9KN AclIi5ajJhImY9UNZyWOsstSzzLow0gAz9tKy2vEi36oHDr7XlacVMwf9NXTp2HSMJSn IZCbOp5y4Y4IcVSHlf2iaL3iQF95AGVFWB4Y8uoSTJdJYM+4zQBaXkkPbUWXGopc3HFu Olk7GBiKx4+uAYVU+bBE+HGPjf5tV80KjGHP0erMu6oCjtNN64bbCdd6V2/0jTRX5ikz ijR9BRPhEdiGnMs2w5j9dDJtxIyZ8tUxZQySqV8mZ5/rm7mc0tiR10/zGTxcft95evnG M9iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r5nJ3Hgz; 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 t18si3587637pgh.89.2019.03.03.13.12.12; Sun, 03 Mar 2019 13:12:29 -0800 (PST) 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=r5nJ3Hgz; 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 S1726655AbfCCVLd (ORCPT + 99 others); Sun, 3 Mar 2019 16:11:33 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:37569 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbfCCVLc (ORCPT ); Sun, 3 Mar 2019 16:11:32 -0500 Received: by mail-io1-f65.google.com with SMTP id v10so2455231iop.4; Sun, 03 Mar 2019 13:11:31 -0800 (PST) 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=UlqwdBoM26XzEO4IUZVTE3fMlYnL5azn8awk8TJxkC0=; b=r5nJ3HgzQRToig0IMHGz+OUNsVA3vJmae/cNiKn8EJrOCcOYZFPcg/Sf5+Fl2Ls//3 sJiGY/Qhq+2vEd1vkMHV89mZ7pWcMcR6l3PSkxgGU+hATRal0WVCO4k+K+z0q95c+kYq OaxBcsiNKHjF67mUhZob6Hp41JVLKwFF6ZtPqy3mAxh6zP7BUoV7M75Q9hV2+TlbJm+b 35soozdU1mXa6PF9EDk2hQpR7JkF4Hgs5L+aW/CIDk+rBZ4xH8Ld1vBjOuU8x+AG90PU UFLgVoPxAN8jxaQnlBM3S7Wcl5ZAGFdY9XBPVu+b9SAqH00Hap+sGtpEKh6cFJF7/pGl Gr5A== 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=UlqwdBoM26XzEO4IUZVTE3fMlYnL5azn8awk8TJxkC0=; b=HyM7iASi9dRSYdEMYNtUuO5AvqxEa4wisue0EJxfd1MnEZ0azMWvOaxFTCyfE+4wkO yVfiFdE3gQ2oBXPdkZ0cyZtBwkuUf9erVUffs4Rxx9o7TQvRmL5VzVwGAAHZaKKUq/AS lFhjckq0/+Oki5r7BQW+105/nE/F2Uz+LMBGFFRA2Bjx2d/27lOcwX5BJEbl2Pf9BwZ/ cB3JHjbK6bljkoyFwaWpGNpPYy4+p7WppeWh3DOk3PkcZr1yD8fZUTHLkf2Xgl2VKYAQ q7DGPTTlHpzUvJkHH1W76JIK+3liKQNRYym0kLU8w7mqeMG+IejAWGi6GFv0R4I2zoq3 41DQ== X-Gm-Message-State: APjAAAU4mNRojbCZBkcJe5Pjcr9wYywwvpHKZHZN9fdL+RWk1uz72/uE 6nxxif0sYFoeq1ZQCCIeoso= X-Received: by 2002:a5e:c707:: with SMTP id f7mr8529259iop.76.1551647491320; Sun, 03 Mar 2019 13:11:31 -0800 (PST) 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 v21sm2288395ita.21.2019.03.03.13.11.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Mar 2019 13:11:30 -0800 (PST) Date: Sun, 3 Mar 2019 16:11:28 -0500 From: Kimberly Brown To: Greg KH Cc: Michael Kelley , Long Li , Sasha Levin , Stephen Hemminger , Dexuan Cui , "K. Y. Srinivasan" , Haiyang Zhang , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when monitor pages are used Message-ID: <20190303211128.GA2071@ubu-Virtual-Machine> References: <20190226053530.GA2897@ubu-Virtual-Machine> <20190301191824.GA4108@ubu-Virtual-Machine> <20190303080543.GA32186@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190303080543.GA32186@kroah.com> 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 Sun, Mar 03, 2019 at 09:05:43AM +0100, Greg KH wrote: > On Fri, Mar 01, 2019 at 02:18:24PM -0500, Kimberly Brown wrote: > > +/* > > + * Channel-level attribute_group callback function. Returns the permission for > > + * each attribute, and returns 0 if an attribute is not visible. > > + */ > > +static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj, > > + struct attribute *attr, int idx) > > +{ > > + const struct vmbus_channel *channel = > > + container_of(kobj, struct vmbus_channel, kobj); > > + > > + /* Hide the monitor attributes if the monitor mechanism is not used. */ > > + if (!channel->offermsg.monitor_allocated && > > + (attr == &chan_attr_pending.attr || > > + attr == &chan_attr_latency.attr || > > + attr == &chan_attr_monitor_id.attr)) > > + return 0; > > + > > + return attr->mode; > > +} > > + > > +static struct attribute_group vmbus_chan_group = { > > + .attrs = vmbus_chan_attrs, > > + .is_visible = vmbus_chan_attr_is_visible > > +}; > > + > > static struct kobj_type vmbus_chan_ktype = { > > .sysfs_ops = &vmbus_chan_sysfs_ops, > > .release = vmbus_chan_release, > > - .default_attrs = vmbus_chan_attrs, > > Why did you remove this line? I removed the default attributes because vmbus_chan_attrs contains non-default attributes. You suggested that I use one attribute_group and an is_visible() callback for the device-level attributes (see https://lore.kernel.org/lkml/20190226081848.GA15659@kroah.com/). I assumed (possibly incorrectly) that I should do the same for these channel-level attributes. > > }; > > > > /* > > @@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel) > > if (ret) > > return ret; > > > > + ret = sysfs_create_group(kobj, &vmbus_chan_group); > > Why are you adding these "by hand"? What was wrong with using the > default attribute group pointer? You also are not removing the > attributes :( Are you referring to default_attrs in kobj_type? It's not an attribute_group pointer, it's a pointer to an attribute pointer array. The problem with using default_attrs is that all of the attributes are visible. I'm fairly certain that the monitor attributes are being removed. sysfs_create_group() uses the attribute_group's is_visible() callback to control the attribute visibility. And, when I look at the sysfs files, I can see that the monitor sysyfs files are removed. In v3, I proposed moving the monitor attributes to a special attribute_group and adding that group manually when needed. Do you prefer that approach for the channel-level monitor attributes? Thanks, Kim > > greg k-h