From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 608CB7DF8B for ; Wed, 23 May 2018 08:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754181AbeEWIZT (ORCPT ); Wed, 23 May 2018 04:25:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:59968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754168AbeEWIZS (ORCPT ); Wed, 23 May 2018 04:25:18 -0400 Received: from localhost (unknown [37.173.74.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 947BB20873; Wed, 23 May 2018 08:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527063918; bh=lllqYauaHfHojljRSs/yHN80aE5ZBMmRLA7f2XDLaMY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xvUOgXlQBfY48TUXV5OKLmlpQGpkiwYB/usIm1dhm/MldgBBIZtsHgrOIt3CZCf9i NVJWZRUetwj5CKVBet0lnUS1X+efk3oA32C6BdIz+dExIDoKhlLYnXu64OT7QMUoMS fAzFLto+Ytm6lgxLqFgxYsGB2JVrpPHOJOzhtP9c= Date: Wed, 23 May 2018 10:24:58 +0200 From: Greg Kroah-Hartman To: Rajat Jain Cc: Bjorn Helgaas , Jonathan Corbet , Philippe Ombredanne , Kate Stewart , Thomas Gleixner , Frederick Lawler , Oza Pawandeep , Keith Busch , Gabriele Paoloni , Alexandru Gagniuc , Thomas Tai , "Steven Rostedt (VMware)" , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jes Sorensen , Kyle McMartin , rajatxjain@gmail.com Subject: Re: [PATCH 2/5] PCI/AER: Add sysfs stats for AER capable devices Message-ID: <20180523082458.GE7247@kroah.com> References: <20180522222805.80314-1-rajatja@google.com> <20180522222805.80314-3-rajatja@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180522222805.80314-3-rajatja@google.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Tue, May 22, 2018 at 03:28:02PM -0700, Rajat Jain wrote: > +#define aer_stats_aggregate_attr(field) \ > + static ssize_t \ > + field##_show(struct device *dev, struct device_attribute *attr, \ > + char *buf) \ > +{ \ > + struct pci_dev *pdev = to_pci_dev(dev); \ > + return sprintf(buf, "0x%llx\n", pdev->aer_stats->field); \ > +} \ Use tabs at the end please, otherwise your trailing \ look horrid. > +static DEVICE_ATTR_RO(field) > + > +aer_stats_aggregate_attr(dev_total_cor_errs); > +aer_stats_aggregate_attr(dev_total_fatal_errs); > +aer_stats_aggregate_attr(dev_total_nonfatal_errs); > + > +static struct attribute *aer_stats_attrs[] __ro_after_init = { > + &dev_attr_dev_total_cor_errs.attr, > + &dev_attr_dev_total_fatal_errs.attr, > + &dev_attr_dev_total_nonfatal_errs.attr, > + NULL > +}; > + > +static umode_t aer_stats_attrs_are_visible(struct kobject *kobj, > + struct attribute *a, int n) > +{ > + struct device *dev = kobj_to_dev(kobj); > + struct pci_dev *pdev = to_pci_dev(dev); > + > + if (!pdev->aer_stats) > + return 0; > + > + return a->mode; > +} > + > +const struct attribute_group aer_stats_attr_group = { > + .name = "aer_stats", > + .attrs = aer_stats_attrs, > + .is_visible = aer_stats_attrs_are_visible, > +}; > + > +void pci_dev_aer_stats_incr(struct pci_dev *pdev, struct aer_err_info *info) > +{ > + int status, i, max = -1; > + u64 *counter = NULL; > + struct aer_stats *aer_stats = pdev->aer_stats; > + > + if (unlikely(!aer_stats)) > + return; Can you measure the speed difference with and without that unlikely() macro? If not, please don't use it. Hint, the cpu and compiler are always always better at this than we are... thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html