From patchwork Fri Aug 19 21:34:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9290941 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 59D8A6077B for ; Fri, 19 Aug 2016 21:35:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FEE82957A for ; Fri, 19 Aug 2016 21:35:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43656295AB; Fri, 19 Aug 2016 21:35:29 +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 7B403295AA for ; Fri, 19 Aug 2016 21:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755805AbcHSVf0 (ORCPT ); Fri, 19 Aug 2016 17:35:26 -0400 Received: from mail.kernel.org ([198.145.29.136]:40334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755750AbcHSVfR (ORCPT ); Fri, 19 Aug 2016 17:35:17 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8663203A5; Fri, 19 Aug 2016 21:35:15 +0000 (UTC) Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33401203DC; Fri, 19 Aug 2016 21:35:12 +0000 (UTC) From: mcgrof@kernel.org To: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, jpoimboe@redhat.com, bp@alien8.de, linux@arm.linux.org.uk, mhiramat@kernel.org, masami.hiramatsu.pt@hitachi.com, jbaron@akamai.com, heiko.carstens@de.ibm.com, ananth@linux.vnet.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, realmz6@gmail.com Cc: x86@kernel.org, luto@amacapital.net, keescook@chromium.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, rusty@rustcorp.com.au, gnomes@lxorguk.ukuu.org.uk, alan@linux.intel.com, dwmw2@infradead.org, arnd@arndb.de, ming.lei@canonical.com, linux-arch@vger.kernel.org, benh@kernel.crashing.org, ananth@in.ibm.com, pebolle@tiscali.nl, fontana@sharpeleven.org, david.vrabel@citrix.com, konrad.wilk@oracle.com, mcb30@ipxe.org, jgross@suse.com, andrew.cooper3@citrix.com, andriy.shevchenko@linux.intel.com, paul.gortmaker@windriver.com, xen-devel@lists.xensource.com, ak@linux.intel.com, pali.rohar@gmail.com, dvhart@infradead.org, platform-driver-x86@vger.kernel.org, mmarek@suse.com, linux@rasmusvillemoes.dk, jkosina@suse.cz, korea.drzix@gmail.com, linux-kbuild@vger.kernel.org, tony.luck@intel.com, akpm@linux-foundation.org, linux-ia64@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rostedt@goodmis.org, jani.nikula@intel.com, mchehab@osg.samsung.com, markus.heiser@darmarit.de, acme@redhat.com, jolsa@kernel.org, msalter@redhat.com, chris@zankel.net, jcmvbkbc@gmail.com, linux-xtensa@linux-xtensa.org, paulus@samba.org, mpe@ellerman.id.au, James.Bottomley@HansenPartnership.com, "Luis R. Rodriguez" , Barry Song , Mike Frysinger , Michael Matz , Guenter Roeck , Fengguang Wu Subject: [PATCH v4 13/16] dynamic_debug: port to use linker tables Date: Fri, 19 Aug 2016 14:34:11 -0700 Message-Id: <1471642454-5679-14-git-send-email-mcgrof@kernel.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1471642454-5679-1-git-send-email-mcgrof@kernel.org> References: <1471642454-5679-1-git-send-email-mcgrof@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Luis R. Rodriguez" This removes the custom vmlinux.lds.h hacks and uses the generalized solution for .data (SECTION_DATA) entries. This is much more potential for further fine tuning here though in the future. For instance, linker tables enable an extra postfix for order level annotations, this could easily be used as the KBUILD_MODNAME and with a bit of linker table changes we may be able to get a direct O(1) count of the entries for that KBUILD_MODNAME: it would just be a count on the number of entries for the given order level. This should help make dynamic_debug_init() cleaner and also reduce the amount of time it takes at boot time. Instead of iterating over each print until we have all for a KBUILD_MODNAME, we'd instead directly operate on each KBUILD_MODNAME directly. Tested dynamic debug with dyndbg query ana debugfs control and it works as expected, for both built-in code and modules. v4: fix compilation on blackfin v3: added modular support v2: introduced this patch into the series Cc: Barry Song Cc: Mike Frysinger Cc: Steven Miao Cc: Michael Matz Cc: Guenter Roeck Cc: Fengguang Wu Signed-off-by: Luis R. Rodriguez --- include/asm-generic/vmlinux.lds.h | 5 ----- include/linux/dynamic_debug.h | 5 +++-- lib/dynamic_debug.c | 13 ++++++------- scripts/module-common.lds.S | 1 + 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 140fbed4a817..ba49b7ad7af2 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -211,11 +211,6 @@ *(.data.unlikely) \ STRUCT_ALIGN(); \ *(__tracepoints) \ - /* implement dynamic printk debug */ \ - . = ALIGN(8); \ - VMLINUX_SYMBOL(__start___verbose) = .; \ - *(__verbose) \ - VMLINUX_SYMBOL(__stop___verbose) = .; \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 546d68057e3b..a52618a77b09 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -4,6 +4,7 @@ #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) #include #endif +#include /* * An instance of this structure is created in a special @@ -50,6 +51,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); #if defined(CONFIG_DYNAMIC_DEBUG) +DECLARE_LINKTABLE(struct _ddebug, __verbose); extern int ddebug_remove_module(const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -71,8 +73,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const char *fmt, ...); #define DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, key, init) \ - static struct _ddebug __aligned(8) \ - __attribute__((section("__verbose"))) name = { \ + static LINKTABLE(__verbose, SECTION_ORDER_ANY) name = { \ .modname = KBUILD_MODNAME, \ .function = __func__, \ .filename = __FILE__, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index da796e2dc4f5..f0060c84c654 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -37,8 +37,7 @@ #include #include -extern struct _ddebug __start___verbose[]; -extern struct _ddebug __stop___verbose[]; +DEFINE_LINKTABLE(struct _ddebug, __verbose); struct ddebug_table { struct list_head link; @@ -978,14 +977,14 @@ static int __init dynamic_debug_init(void) int n = 0, entries = 0, modct = 0; int verbose_bytes = 0; - if (__start___verbose == __stop___verbose) { - pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); + if (LINUX_SECTION_EMPTY(__verbose)) { + pr_warn("dynamic debug linker table empty on CONFIG_DYNAMIC_DEBUG build\n"); return 1; } - iter = __start___verbose; + iter = LINUX_SECTION_START(__verbose); modname = iter->modname; iter_start = iter; - for (; iter < __stop___verbose; iter++) { + LINKTABLE_FOR_EACH(iter, __verbose) { entries++; verbose_bytes += strlen(iter->modname) + strlen(iter->function) + strlen(iter->filename) + strlen(iter->format); @@ -1008,7 +1007,7 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in (readonly) verbose section\n", modct, entries, (int)(modct * sizeof(struct ddebug_table)), - verbose_bytes + (int)(__stop___verbose - __start___verbose)); + verbose_bytes + (int)(LINUX_SECTION_SIZE(__verbose))); /* apply ddebug_query boot param, dont unload tables on err */ if (ddebug_setup_string[0] != '\0') { diff --git a/scripts/module-common.lds.S b/scripts/module-common.lds.S index be3bde1ea0ce..be57ca0994dc 100644 --- a/scripts/module-common.lds.S +++ b/scripts/module-common.lds.S @@ -21,6 +21,7 @@ SECTIONS { __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } __jump_table 0 : { *(SORT(SECTION_TBL(SECTION_DATA, __jump_table, *))) } + __verbose 0 : { *(SORT(SECTION_TBL(SECTION_DATA, __verbose, *))) } . = ALIGN(8); .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) }