From patchwork Sun Jan 15 21:10:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9517847 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 A0291600F6 for ; Sun, 15 Jan 2017 21:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 615AE26CF9 for ; Sun, 15 Jan 2017 21:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5435D28410; Sun, 15 Jan 2017 21:14: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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 97C0226CF9 for ; Sun, 15 Jan 2017 21:14:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSs5l-0008Fy-SR; Sun, 15 Jan 2017 21:11:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSs5k-0008ES-Hk for xen-devel@lists.xensource.com; Sun, 15 Jan 2017 21:11:56 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 85/B3-15802-B95EB785; Sun, 15 Jan 2017 21:11:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsVybKJsh+6sp9U RBnuv6Vrcm/Ke3YHRY3vfLvYAxijWzLyk/IoE1ox3k16xFHzUqXi4qYmlgXGRahcjF4eQwFRG iaMT/rFBOMuYJCYvO8vSxcjBwSagK3HztgRIXESgm1ni07ydjCAOs8AfHonbUz4DOZwcwgJOE j0PDjF3MbJzsAioSnQyg0R5BcwlHix/CmZLCMhL7Gq7yApicwLFO+e/YAMZLySQJNG0yQWiJE NiXs8cVgjbS2LRjUtQtprE1XObmCcw8i1gZFjFqFGcWlSWWqRraKCXVJSZnlGSm5iZA+SZ6uW mFhcnpqfmJCYV6yXn525iBAYJAxDsYFwz1fkQoyQHk5Io7zGd6gghvqT8lMqMxOKM+KLSnNTi Q4wyHBxKErx9T4BygkWp6akVaZk5wHCFSUtw8CiJ8N54DJTmLS5IzC3OTIdInWJUlBLn9QDpE wBJZJTmwbXBYuQSo6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHmjQabwZOaVwE1/BbSYCWjxdR 2wxSWJCCmpBsYCFScWgfkL/Wue6MeVhzgH3jPfqHhu9h3/N9vVir9LfUi2sJl1sefbu09b9C2 +H10f1Gcu2J387MG+t+JBv01kGO4fEcs/6On2+/MT81vH3A5ZGuUU8Ux6Nz1jJ+vOWbeTXCc0 Pamd9Or6bm71D365lt+2fVDv0qltCLr15Nj6d9Y6XNEFu+KVWIozEg21mIuKEwE7oLSqjAIAA A== X-Env-Sender: mcgrof@kernel.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1484514713!43739937!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29655 invoked from network); 15 Jan 2017 21:11:54 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jan 2017 21:11:54 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8CAE2058E; Sun, 15 Jan 2017 21:11:51 +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 ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E60FF205D1; Sun, 15 Jan 2017 21:11:47 +0000 (UTC) From: "Luis R. Rodriguez" To: bp@alien8.de, bp@suse.de, hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, mingo@redhat.com, jpoimboe@redhat.com, npiggin@gmail.com, 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, dalias@libc.org, linux@arm.linux.org.uk Date: Sun, 15 Jan 2017 13:10:53 -0800 Message-Id: <20170115211057.17167-11-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170115211057.17167-1-mcgrof@kernel.org> References: <20170109145833.11502-1-mcgrof@kernel.org> <20170115211057.17167-1-mcgrof@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: gnomes@lxorguk.ukuu.org.uk, linux-ia64@vger.kernel.org, jkosina@suse.cz, benh@kernel.crashing.org, ming.lei@canonical.com, linux@rasmusvillemoes.dk, platform-driver-x86@vger.kernel.org, James.Bottomley@HansenPartnership.com, paul.gortmaker@windriver.com, paulus@samba.org, sparclinux@vger.kernel.org, wangnan0@huawei.com, Michael Matz , Barry Song , mchehab@osg.samsung.com, linux-arch@vger.kernel.org, markus.heiser@darmarit.de, xen-devel@lists.xensource.com, msalter@redhat.com, linux-sh@vger.kernel.org, mpe@ellerman.id.au, joro@8bytes.org, x86@kernel.org, fontana@sharpeleven.org, dsahern@gmail.com, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, dvhart@infradead.org, dwmw2@infradead.org, linux@roeck-us.net, linux-xtensa@linux-xtensa.org, pali.rohar@gmail.com, Mike Frysinger , keescook@chromium.org, arnd@arndb.de, konrad.wilk@oracle.com, jani.nikula@intel.com, will.deacon@arm.com, rusty@rustcorp.com.au, rostedt@goodmis.org, ak@linux.intel.com, namhyung@kernel.org, andriy.shevchenko@linux.intel.com, mcb30@ipxe.org, linux-kbuild@vger.kernel.org, alan@linux.intel.com, jgross@suse.com, chris@zankel.net, pebolle@tiscali.nl, tony.luck@intel.com, jcmvbkbc@gmail.com, gregkh@linuxfoundation.org, dmitry.torokhov@gmail.com, adrian.hunter@intel.com, luto@amacapital.net, "Luis R. Rodriguez" , mmarek@suse.com, david.vrabel@citrix.com, jolsa@kernel.org, andrew.cooper3@citrix.com, akpm@linux-foundation.org, Fengguang Wu , torvalds@linux-foundation.org, korea.drzix@gmail.com Subject: [Xen-devel] [PATCH v7 10/14] dynamic_debug: port to use linker tables X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This removes the custom vmlinux.lds.h hacks and uses the generalized solution for .data entries. There is much more potential for further fine tuning here in the future though. 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. We can work on this later to make this change easier to review. Tested dynamic debug with dyndbg query and debugfs control and it works as expected, for both built-in code and modules. v6: rename table macro as suggested by Andy Shevchenko v5: o Use ..tbl instead of .tbl as suggested by Nicholas Piggin. This is the typical way to avoid clash with compiler generated section. o Replace section macros with section names, use LINKTABLE_EMPTY(), LINKTABLE_START() 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 | 4 ---- include/linux/dynamic_debug.h | 5 +++-- lib/dynamic_debug.c | 13 ++++++------- scripts/module-common.lds | 1 + 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 887d844f0406..37b99537d5a9 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -216,10 +216,6 @@ *(.data.unlikely) \ STRUCT_ALIGN(); \ *(__tracepoints) \ - . = ALIGN(8); \ - VMLINUX_SYMBOL(__start___verbose) = .; \ - KEEP(*(__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..27a335e3b1f3 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 (LINKTABLE_EMPTY(__verbose)) { + pr_warn("dynamic debug linker table empty on CONFIG_DYNAMIC_DEBUG build\n"); return 1; } - iter = __start___verbose; + iter = LINKTABLE_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)(LINKTABLE_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 b/scripts/module-common.lds index db0e724556c5..25755d458f09 100644 --- a/scripts/module-common.lds +++ b/scripts/module-common.lds @@ -17,6 +17,7 @@ SECTIONS { __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } __jump_table 0 : { *(SORT(.data..tbl.__jump_table.*)) } + __verbose 0 : { *(SORT(.data..tbl.__verbose.*)) } . = ALIGN(8); .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) }