Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4245146yba; Tue, 9 Apr 2019 14:29:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBoh+qmn/A7ou2UwwbVP5EUNgZlCJwMTyc/8GExKtxaOHR5BlHQtc9l5qzJ3tKY41tl/qk X-Received: by 2002:a62:1815:: with SMTP id 21mr39881855pfy.107.1554845369416; Tue, 09 Apr 2019 14:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554845369; cv=none; d=google.com; s=arc-20160816; b=TvvcLBuPgrokHbxfekJL9YDGLhkRgFqcZ58+K4+qMmB9OvwM6Ho3eR4BWD72ZJjYhH s7bBjWaHNWIy9z2o8qKK7dMPykfgqDIMRZP45KwMT8WLLjjDqDtymY2tSEEIFyI/GZTy EYh5HCkBimG0fdyLIl6vPM16IWUEz3hrw3Gl7PVaCKcgKh0ghnbqsq5nfND4ovrlxmnr 1/O4PUQ4LLcv5oUjF9sJ4v6BR53NzSUthoB4CvTR2VoTQcNESTlbUfH6FlBH2NUyBGf5 lVy+ZcCVX0kVkZ95T6DUQga0YKmWlYXba71s99AcigfJot8dazzQda2ihPXpLpAXnjqb BSSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pvxkQyUAnqltiULwUqvTsk4ca9ur6o2LqkmGmDZivdQ=; b=V9mPl+wUjdxVeddCqTfv2JnocAyGx6qf5EdwtkI11D2XhXnvz0OA2VQZlE0Lhwj51n HGJ1dMIjYXwcGTIZmCp0miWi5U7fGdJx7/+AS3eQ5Oe1jLfvHBm0bNrtlTrsAynbrd4p 6rsFyOozXyuSnDzxtY23xkEhw5/TRLCVnvZPOSMa47EPxw5InFgDJ65hFVvNjSiQHuuk I5SlyyNNrAVseEqvbOWOQmJWwxzh/nxno2ZG/M2cUG5ZKzYM20ZZBdS97gGecVMOFgNH wfa8w9LQoyZfVidbAQkEdcIAEcz+KKdlPr6UiyVLSLJ7zMcQUZn1AOCQdx9mMDXUXncx yC/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="Q3/o2P/L"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si12160638pfr.272.2019.04.09.14.29.13; Tue, 09 Apr 2019 14:29:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="Q3/o2P/L"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbfDIV0u (ORCPT + 99 others); Tue, 9 Apr 2019 17:26:50 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:33205 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfDIVZ6 (ORCPT ); Tue, 9 Apr 2019 17:25:58 -0400 Received: by mail-ed1-f67.google.com with SMTP id b8so157433edq.0 for ; Tue, 09 Apr 2019 14:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pvxkQyUAnqltiULwUqvTsk4ca9ur6o2LqkmGmDZivdQ=; b=Q3/o2P/LTinil0xEuw56y8/0ZdcgJYGdKduHUFl7ajjJd2714anBGA63CcGiHy+X5L 8P+jIK/cKXd0qUaQUQWLdqRTPois44hhulAWMPL8p+xNvVvazNLMJqhAugdIquFs7xih QxX7HKpcLape6NkhENrQk5HTKo2TWvNXvCMe0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pvxkQyUAnqltiULwUqvTsk4ca9ur6o2LqkmGmDZivdQ=; b=ARAKGY0zCDyanGizgYdqyqBP4U5j1mH4YXYkBA81kQ1Lrq5CcNQk/EGkQhvGiI/JRV WU08ysVWCy6IV2YqDLI1sTC2VGwM5ICrPhOP61AJMR59HVocVOjiNWNmTBH0hR3Aeru2 1n24e3U3elhXnGmmgjVE8sFpSkv4++yb0kD006M1tLdncnNSZh72p217THyjLRsUjEGF JDY21JMBpuTquZAfbkT+nXAx1sZVIrq+qUN9qPpyOm8eIwY7YnK+qm1xCUhvjtU2pP9p Fc/3mc4UZ+tNJ+HwJbhT7G8gjKpYlYJ1qAoxd/zw9bDF/naXQ70bA2SF7VGCt8vfiRdr hCuQ== X-Gm-Message-State: APjAAAXhoIJ60fSAbPWpIbV77fpQyXPXkUMRJxLX6nA297uQu2gsuG9q iYIeClqp93wcxJeRxWKzEMBOYQ== X-Received: by 2002:aa7:da13:: with SMTP id r19mr3170727eds.134.1554845156798; Tue, 09 Apr 2019 14:25:56 -0700 (PDT) Received: from prevas-ravi.prevas.se (ip-5-186-118-63.cgn.fibianet.dk. [5.186.118.63]) by smtp.gmail.com with ESMTPSA id i26sm3477986ejc.51.2019.04.09.14.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 14:25:56 -0700 (PDT) From: Rasmus Villemoes To: Andrew Morton Cc: Jason Baron , linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH 06/10] dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS Date: Tue, 9 Apr 2019 23:25:13 +0200 Message-Id: <20190409212517.7321-7-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190409212517.7321-1-linux@rasmusvillemoes.dk> References: <20190409212517.7321-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on the same idea for struct bug_entry, an architecture can opt-in to use relative pointers in struct _ddebug. It only makes sense for 64 bit architectures, where one saves 16 bytes per entry (out of 40 or 56, depending on CONFIG_JUMP_LABEL). The architecture is responsible for providing a suitable DEFINE_DYNAMIC_DEBUG_METADATA macro in . Acked-by: Jason Baron Signed-off-by: Rasmus Villemoes --- include/linux/dynamic_debug.h | 14 ++++++++++++++ lib/Kconfig.debug | 3 +++ lib/dynamic_debug.c | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e2fa2737a485..08175c219d60 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -16,10 +16,17 @@ struct _ddebug { * These fields are used to drive the user interface * for selecting and displaying debug callsites. */ +#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS + signed int modname_disp; + signed int function_disp; + signed int filename_disp; + signed int format_disp; +#else const char *modname; const char *function; const char *filename; const char *format; +#endif /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -70,6 +77,12 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...); +#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS +#include +#ifndef DEFINE_DYNAMIC_DEBUG_METADATA +# error "asm/dynamic_debug.h must provide definition of DEFINE_DYNAMIC_DEBUG_METADATA" +#endif +#else #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ static struct _ddebug __aligned(8) \ __attribute__((section("__verbose"))) name = { \ @@ -80,6 +93,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, .flags_lineno = _DPRINTK_FLAGS_LINENO_INIT, \ _DPRINTK_KEY_INIT \ } +#endif #ifdef CONFIG_JUMP_LABEL diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 0d9e81779e37..7cee0895f9c8 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -163,6 +163,9 @@ config DYNAMIC_DEBUG See Documentation/admin-guide/dynamic-debug-howto.rst for additional information. +config DYNAMIC_DEBUG_RELATIVE_POINTERS + bool + endmenu # "printk and dmesg options" menu "Compile-time checks and compiler options" diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 482a35a68752..58288560cc35 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -37,6 +37,24 @@ #include #include +#ifdef CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS +static inline const char *dd_modname(const struct _ddebug *dd) +{ + return (const char *)dd + dd->modname_disp; +} +static inline const char *dd_function(const struct _ddebug *dd) +{ + return (const char *)dd + dd->function_disp; +} +static inline const char *dd_filename(const struct _ddebug *dd) +{ + return (const char *)dd + dd->filename_disp; +} +static inline const char *dd_format(const struct _ddebug *dd) +{ + return (const char *)dd + dd->format_disp; +} +#else static inline const char *dd_modname(const struct _ddebug *dd) { return dd->modname; @@ -53,6 +71,8 @@ static inline const char *dd_format(const struct _ddebug *dd) { return dd->format; } +#endif + static inline unsigned dd_lineno(const struct _ddebug *dd) { return dd->flags_lineno >> 8; -- 2.20.1