Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp556020imm; Wed, 23 May 2018 01:26:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYGGm8V+NY6HAdj8mDTWb9WEu5Cn5hiD5cVWrrqwPIyGLGFj/Da3VbjU60v5040CBNlEZ3 X-Received: by 2002:a62:c050:: with SMTP id x77-v6mr1917782pff.67.1527064004332; Wed, 23 May 2018 01:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527064004; cv=none; d=google.com; s=arc-20160816; b=CIsr/bfnIIZPepyql5jlvAsMa8yQukjNgeozsOp5OUGIngH0CpVzTYEyafUC7wUJwc NsUFfeNB3KfjBHZv0qM18v9PJy8dbwGxIX8uPe85EIDgPkktGLnIj+pgfJ5T8JRvwpN3 VwZnClLbyQsVQAreZOrOeIBBQ8O1HlQ9XJD0H2KAlGSlikYlO23Jb53YHPyByBwSqlnY hbH7cLmSMLFauaDXsA1A50R0L/I3tuyrTAc0poaYYW7/DC9VbG6f0M3mOge4MRVp9uW+ a3ZAfRDj/oDXAHc2h2j9STxwaoqJjwY8V6pn0oJiF/2B0THeC8LtHKdM/RdCbQ3fwzAJ Hp0A== 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:arc-authentication-results; bh=d1h9if1aPkO790w+QxF7pTOdtGMwxAuNGa8OEGMIkeA=; b=JagAYzkzMT6gjPdZhfluL8lO1OKIOpDFs7+woyF8mV5kNXzU7KB3HRaHwEiuup6gvH hkGHAtGSedyktFC2jQUp5qUd0vXmhE8UEX8ikMNzcY6sd+QyIv/3aRfGP0JoxYhIApxn zHtFv1TfI1saTSP7u5XTLiWF4ckfnRLMBJ2lyT/zo0aWAy6igW2Nv8uUFX0mwtBXW1o2 eqwwuuxuGwB4Wig4OPaNJDC3flsNGgq/Wx4rSCiboDfaQbN2MqNHLUmsGU97VaD1AGss phxiscSzKO05J1qEznimLye/vBcLFPhEiZg4ld564gMgbkhaEV4GdnlCHkwcsfR9w+1V RZJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xvUOgXlQ; 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 i21-v6si555548pgn.638.2018.05.23.01.26.29; Wed, 23 May 2018 01:26:44 -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=@kernel.org header.s=default header.b=xvUOgXlQ; 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 S1754401AbeEWIZU (ORCPT + 99 others); Wed, 23 May 2018 04:25:20 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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