From patchwork Thu Mar 15 14:04:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 10284539 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 81E3B60291 for ; Thu, 15 Mar 2018 14:05:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E38828A56 for ; Thu, 15 Mar 2018 14:05:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6302D28A7A; Thu, 15 Mar 2018 14:05:00 +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 165C228A70 for ; Thu, 15 Mar 2018 14:04:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB8456E86E; Thu, 15 Mar 2018 14:04:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25B2A6E86E; Thu, 15 Mar 2018 14:04:57 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2018 07:04:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,311,1517904000"; d="scan'208";a="208503469" Received: from ashleylh-mobl1.ger.corp.intel.com (HELO [10.249.35.19]) ([10.249.35.19]) by orsmga005.jf.intel.com with ESMTP; 15 Mar 2018 07:04:53 -0700 Subject: Re: [PATCH] drm: Reduce object size of DRM_ERROR and DRM_DEBUG uses To: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Joe Perches References: <016b5cb84cede20fd0f91ed6965421d99fd5f2ce.1520978414.git.joe@perches.com> <20180315133026.GR5453@intel.com> From: Maarten Lankhorst Message-ID: <1b50f5d8-97a6-2442-34bb-2782c35505fd@linux.intel.com> Date: Thu, 15 Mar 2018 15:04:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180315133026.GR5453@intel.com> Content-Language: en-US X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Op 15-03-18 om 14:30 schreef Ville Syrjälä: > On Tue, Mar 13, 2018 at 03:02:15PM -0700, Joe Perches wrote: >> drm_printk is used for both DRM_ERROR and DRM_DEBUG with unnecessary >> arguments that can be removed by creating separate functins. >> >> Create specific functions for these calls to reduce x86/64 defconfig >> size by ~20k. >> >> Modify the existing macros to use the specific calls. >> >> new: >> $ size -t drivers/gpu/drm/built-in.a | tail -1 >> 1876562 44542 995 1922099 1d5433 (TOTALS) >> >> old: >> $ size -t drivers/gpu/drm/built-in.a | tail -1 >> 1897565 44542 995 1943102 1da63e (TOTALS) >> >> Miscellanea: >> >> o intel_display requires a change to use the specific calls. > How much would we lose if we move the (drm_debug&FOO) outside the > functions again? I'm somewhat concerned about all the function call > overhead when debugs aren't even enabled. Upstream: text data bss dec hex filename 377143 5689 4352 387184 5e870 drivers/gpu/drm/drm.ko With this patch: 373831 5689 4352 383872 5db80 drivers/gpu/drm/drm.ko Moving the if outside (below): 377629 5689 4352 387670 5ea56 drivers/gpu/drm/drm.ko Bye savings.. I don't think there are any places in which the debug output is performance sensitive, so I'm ok with not inlining. diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 79abf6d5b4db..928822403a59 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -89,14 +89,11 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void drm_dbg(unsigned int category, const char *format, ...) +void __drm_dbg(const char *format, ...) { struct va_format vaf; va_list args; - if (!(drm_debug & category)) - return; - va_start(args, format); vaf.fmt = format; vaf.va = &args; @@ -106,7 +103,7 @@ void drm_dbg(unsigned int category, const char *format, ...) va_end(args); } -EXPORT_SYMBOL(drm_dbg); +EXPORT_SYMBOL(__drm_dbg); void drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 3a40c5a3a5fa..2a145b97bdfc 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -200,8 +200,17 @@ __printf(6, 7) void drm_dev_printk(const struct device *dev, const char *level, unsigned int category, const char *function_name, const char *prefix, const char *format, ...); -__printf(2, 3) -void drm_dbg(unsigned int category, const char *format, ...); + +__printf(1, 2) +void __drm_dbg(const char *format, ...); + + +#define drm_dbg(category, format, ...) \ + do { \ + if (drm_debug & category) \ + __drm_dbg(format, ## __VA_ARGS__); \ + } while (0) + __printf(1, 2) void drm_err(const char *format, ...);