From patchwork Mon Sep 25 12:03:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9969811 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 2ABEC60365 for ; Mon, 25 Sep 2017 12:03:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CAD728C67 for ; Mon, 25 Sep 2017 12:03:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11B9428C6A; Mon, 25 Sep 2017 12:03:34 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E7AE28C67 for ; Mon, 25 Sep 2017 12:03:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D2E186E1AB; Mon, 25 Sep 2017 12:03:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3344A6E1AB for ; Mon, 25 Sep 2017 12:03:31 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 0FCC79E6A; Mon, 25 Sep 2017 12:03:29 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: push80_117043406b46 X-Filterd-Recvd-Size: 6843 Received: from joe-laptop.perches.com (unknown [47.151.132.55]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Mon, 25 Sep 2017 12:03:27 +0000 (UTC) From: Joe Perches To: Daniel Vetter , Jani Nikula , Sean Paul , David Airlie Subject: [PATCH] drm: Reduce object size of drm_dev_printk/DRM_DEV_ uses Date: Mon, 25 Sep 2017 05:03:25 -0700 Message-Id: <693db79230a414560005936cedf4080d20235c03.1506340959.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Remove unnecessary function_name and prefix arguments. Removing these arguments reduces object size. prefix is used to add an "ERROR" prefix to the format for DRM_DEV_ERROR and is an empty string for all other uses. This string can be added instead by the DRM_DEV_ERROR macro. function_name is used to emit the calling function. This can be done by using %ps and __builtin_return_address(0). Signed-off-by: Joe Perches --- drivers/gpu/drm/drm_drv.c | 12 +++++------- include/drm/drmP.h | 42 ++++++++++++++++++------------------------ include/drm/drm_drv.h | 5 ++--- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index be38ac7050d4..4d0f2c5197f3 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -74,11 +74,8 @@ static bool drm_core_init_complete = false; static struct dentry *drm_debugfs_root; -#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV" - void drm_dev_printk(const struct device *dev, const char *level, - unsigned int category, const char *function_name, - const char *prefix, const char *format, ...) + unsigned int category, const char *format, ...) { struct va_format vaf; va_list args; @@ -91,10 +88,11 @@ void drm_dev_printk(const struct device *dev, const char *level, vaf.va = &args; if (dev) - dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix, - &vaf); + dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV", + __builtin_return_address(0), &vaf); else - printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf); + printk("%s[" DRM_NAME ":%ps] %pV", + level, __builtin_return_address(0), &vaf); va_end(args); } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 7277783a4ff0..16dd63ffa1ff 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -172,8 +172,8 @@ struct pci_controller; * \param arg arguments */ #define DRM_DEV_ERROR(dev, fmt, ...) \ - drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ - fmt, ##__VA_ARGS__) + drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, \ + "*ERROR* " fmt, ##__VA_ARGS__) #define DRM_ERROR(fmt, ...) \ drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__) @@ -196,8 +196,8 @@ struct pci_controller; DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) #define DRM_DEV_INFO(dev, fmt, ...) \ - drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ - ##__VA_ARGS__) + drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, \ + fmt, ##__VA_ARGS__) #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ ({ \ @@ -214,50 +214,44 @@ struct pci_controller; * \param fmt printf() like format string. * \param arg arguments */ -#define DRM_DEV_DEBUG(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ - ##args) +#define DRM_DEV_DEBUG(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) #define DRM_DEBUG(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) -#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ - fmt, ##args) +#define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) #define DRM_DEBUG_DRIVER(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) -#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ - ##args) +#define DRM_DEV_DEBUG_KMS(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) #define DRM_DEBUG_KMS(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) -#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ - fmt, ##args) +#define DRM_DEV_DEBUG_PRIME(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, ##__VA_ARGS__) #define DRM_DEBUG_PRIME(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__) -#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ - fmt, ##args) +#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) #define DRM_DEBUG_ATOMIC(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) -#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ - drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ - ##args) +#define DRM_DEV_DEBUG_VBL(dev, fmt, ...) \ + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) #define DRM_DEBUG_VBL(fmt, ...) \ drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) -#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ +#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, ...) \ ({ \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ if (__ratelimit(&_rs)) \ drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ - __func__, "", fmt, ##args); \ + fmt, ##__VA_ARGS__); \ }) /** diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 71bbaaec836d..f6430f183ca8 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -592,10 +592,9 @@ struct drm_driver { int dev_priv_size; }; -__printf(6, 7) +__printf(4, 5) void drm_dev_printk(const struct device *dev, const char *level, - unsigned int category, const char *function_name, - const char *prefix, const char *format, ...); + unsigned int category, const char *format, ...); __printf(3, 4) void drm_printk(const char *level, unsigned int category, const char *format, ...);