From patchwork Tue Nov 4 08:03:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 5223531 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 284B99F295 for ; Tue, 4 Nov 2014 08:03:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4227A20160 for ; Tue, 4 Nov 2014 08:03:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3602F2012B for ; Tue, 4 Nov 2014 08:03:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16DDC6E498; Tue, 4 Nov 2014 00:03:53 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A58B6E498 for ; Tue, 4 Nov 2014 00:03:50 -0800 (PST) Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id D46DC351FB0; Tue, 4 Nov 2014 08:03:48 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::, RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1373:1437:1515:1516:1518:1535:1544:1593:1594:1605:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3865:3870:4250:4321:4605:5007:6119:6261:7903:8603:10004:10848:11026:11473:11658:11914:12043:12291:12296:12438:12517:12519:12555:12683:13548:14394:21080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: bone33_2128f5ca85f57 X-Filterd-Recvd-Size: 5177 Received: from joe-X200MA.home (pool-71-103-235-196.lsanca.fios.verizon.net [71.103.235.196]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Tue, 4 Nov 2014 08:03:47 +0000 (UTC) Message-ID: <1415088226.24560.1.camel@perches.com> Subject: [PATCH] drm: Reduce code size of drm_err and DRM_DEBUG[_] uses From: Joe Perches To: David Airlie Date: Tue, 04 Nov 2014 00:03:46 -0800 X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Cc: LKML , dri-devel 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using %pf, __builtin_return_address(0) instead ofy "%s", __func__ reduces code size by eliminating a function argument. (allyesconfig) $ size drivers/gpu/drm/built-in.o* text data bss dec hex filename 4656061 1321947 1669536 7647544 74b138 drivers/gpu/drm/built-in.o.new 4737680 1321947 1669472 7729099 75efcb drivers/gpu/drm/built-in.o.old Signed-off-by: Joe Perches --- drivers/gpu/drm/drm_drv.c | 10 ++++++---- include/drm/drmP.h | 45 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index bc3da32..22f76a2 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -56,7 +56,7 @@ static struct idr drm_minors_idr; struct class *drm_class; static struct dentry *drm_debugfs_root; -void drm_err(const char *func, const char *format, ...) +void drm_err(const char *format, ...) { struct va_format vaf; va_list args; @@ -66,13 +66,14 @@ void drm_err(const char *func, const char *format, ...) vaf.fmt = format; vaf.va = &args; - printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf); + printk(KERN_ERR "[" DRM_NAME ":%pf] *ERROR* %pV", + __builtin_return_address(0), &vaf); va_end(args); } EXPORT_SYMBOL(drm_err); -void drm_ut_debug_printk(const char *function_name, const char *format, ...) +void drm_ut_debug_printk(const char *format, ...) { struct va_format vaf; va_list args; @@ -81,7 +82,8 @@ void drm_ut_debug_printk(const char *function_name, const char *format, ...) vaf.fmt = format; vaf.va = &args; - printk(KERN_DEBUG "[" DRM_NAME ":%s] %pV", function_name, &vaf); + printk(KERN_DEBUG "[" DRM_NAME ":%pf] %pV", + __builtin_return_address(0), &vaf); va_end(args); } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 53ed876..02aaa1a 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -122,11 +122,10 @@ struct dma_buf_attachment; #define DRM_UT_KMS 0x04 #define DRM_UT_PRIME 0x08 -extern __printf(2, 3) -void drm_ut_debug_printk(const char *function_name, - const char *format, ...); -extern __printf(2, 3) -void drm_err(const char *func, const char *format, ...); +__printf(1, 2) +void drm_ut_debug_printk(const char *format, ...); +__printf(1, 2) +void drm_err(const char *format, ...); /***********************************************************************/ /** \name DRM template customization defaults */ @@ -155,7 +154,7 @@ void drm_err(const char *func, const char *format, ...); * \param arg arguments */ #define DRM_ERROR(fmt, ...) \ - drm_err(__func__, fmt, ##__VA_ARGS__) + drm_err(fmt, ##__VA_ARGS__) /** * Rate limited error output. Like DRM_ERROR() but won't flood the log. @@ -170,7 +169,7 @@ void drm_err(const char *func, const char *format, ...); DEFAULT_RATELIMIT_BURST); \ \ if (__ratelimit(&_rs)) \ - drm_err(__func__, fmt, ##__VA_ARGS__); \ + drm_err(fmt, ##__VA_ARGS__); \ }) #define DRM_INFO(fmt, ...) \ @@ -186,26 +185,26 @@ void drm_err(const char *func, const char *format, ...); * \param arg arguments */ #define DRM_DEBUG(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_CORE)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) +do { \ + if (unlikely(drm_debug & DRM_UT_CORE)) \ + drm_ut_debug_printk(fmt, ##args); \ +} while (0) #define DRM_DEBUG_DRIVER(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) +do { \ + if (unlikely(drm_debug & DRM_UT_DRIVER)) \ + drm_ut_debug_printk(fmt, ##args); \ +} while (0) #define DRM_DEBUG_KMS(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_KMS)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) +do { \ + if (unlikely(drm_debug & DRM_UT_KMS)) \ + drm_ut_debug_printk(fmt, ##args); \ +} while (0) #define DRM_DEBUG_PRIME(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_PRIME)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) +do { \ + if (unlikely(drm_debug & DRM_UT_PRIME)) \ + drm_ut_debug_printk(fmt, ##args); \ +} while (0) /*@}*/