From patchwork Wed Jun 22 18:23:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9193451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 949DF6075F for ; Wed, 22 Jun 2016 18:24:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A92128411 for ; Wed, 22 Jun 2016 18:24:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F22628416; Wed, 22 Jun 2016 18:24:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E61C28411 for ; Wed, 22 Jun 2016 18:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752010AbcFVSYE (ORCPT ); Wed, 22 Jun 2016 14:24:04 -0400 Received: from smtprelay0229.hostedemail.com ([216.40.44.229]:44684 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751977AbcFVSYD (ORCPT ); Wed, 22 Jun 2016 14:24:03 -0400 Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 610E129DE06; Wed, 22 Jun 2016 18:24:01 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: dirt84_7a49e9dc1c13b X-Filterd-Recvd-Size: 3600 Received: from XPS-9350.home (unknown [96.251.125.34]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Wed, 22 Jun 2016 18:24:00 +0000 (UTC) Message-ID: <1466619839.13093.4.camel@perches.com> Subject: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% From: Joe Perches To: Matan Barak , Leon Romanovsky Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel Date: Wed, 22 Jun 2016 11:23:59 -0700 X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The logging macros create a bit of duplicated code/text. Use specialized functions to reduce the duplication. (defconfig/x86-64) $ size drivers/net/ethernet/mellanox/mlx5/core/built-in.o*    text    data     bss     dec     hex filename  178634    2059      16  180709   2c1e5 drivers/net/ethernet/mellanox/mlx5/core/built-in.o.new  188679    2059      16  190754   2e922 drivers/net/ethernet/mellanox/mlx5/core/built-in.o.old The output changes now do not include line #, but do include the function offset. Signed-off-by: Joe Perches Reviewed-by: Leon Romanovsky ---  drivers/net/ethernet/mellanox/mlx5/core/main.c     | 34 ++++++++++++++++++++++  .../net/ethernet/mellanox/mlx5/core/mlx5_core.h    | 13 +++------  2 files changed, 38 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index a19b593..34cbaf0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1557,3 +1557,37 @@ static void __exit cleanup(void)    module_init(init);  module_exit(cleanup); + +void mlx5_core_err(struct mlx5_core_dev *dev, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + dev_err(&dev->pdev->dev, "%s:%pS:(pid %d): %pV", + dev->priv.name, __builtin_return_address(0), current->pid, + &vaf); + + va_end(args); +} + +void mlx5_core_warn(struct mlx5_core_dev *dev, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + dev_warn(&dev->pdev->dev, "%s:%pS:(pid %d): %pV", +  dev->priv.name, __builtin_return_address(0), current->pid, +  &vaf); + + va_end(args); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 2f86ec6..31430a7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -57,15 +57,10 @@ do { \   mlx5_core_dbg(__dev, format, ##__VA_ARGS__); \  } while (0)   -#define mlx5_core_err(__dev, format, ...) \ - dev_err(&(__dev)->pdev->dev, "%s:%s:%d:(pid %d): " format, \ -        (__dev)->priv.name, __func__, __LINE__, current->pid, \ -        ##__VA_ARGS__) - -#define mlx5_core_warn(__dev, format, ...) \ - dev_warn(&(__dev)->pdev->dev, "%s:%s:%d:(pid %d): " format, \ - (__dev)->priv.name, __func__, __LINE__, current->pid, \ - ##__VA_ARGS__) +__printf(2, 3) +void mlx5_core_err(struct mlx5_core_dev *dev, const char *fmt, ...); +__printf(2, 3) +void mlx5_core_warn(struct mlx5_core_dev *dev, const char *fmt, ...);    #define mlx5_core_info(__dev, format, ...) \   dev_info(&(__dev)->pdev->dev, format, ##__VA_ARGS__)