Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4722322imm; Tue, 9 Oct 2018 04:22:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV60t/Ur+ejdVZCPvEeULl6ded08/uqgaun5o+4VFta+rtTK2tXzhoQ9a48dxC08KSFZQhmnW X-Received: by 2002:a63:b305:: with SMTP id i5-v6mr24755773pgf.46.1539084120945; Tue, 09 Oct 2018 04:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539084120; cv=none; d=google.com; s=arc-20160816; b=sOSRUKsjVM7yUTTu5wRtStKuS8wls7b8S7GpmqukPLm9U7fkQtQYijozsb+ktSIUaA XRBgTLA0AYdL5ZKKDVFZtM6U7nFrnB7RBgJigmmIdVe6sQVHCfa6jl5Ceqhdh99LxSGq sPv3SOTsaWmozCoRAAwfY6mXbwzy+0B8kWg7yDNE4e4RvwEoik7yTeaJAt2YyB58DEqB JPrVrMXafQgO2B3/QhD8rMCKX1wz3Pbco6rVMWvwJt1ADyQG0sh6MDSbbIVXpLziFrzg rWxjJjdcVx0swxbMCNWM1KR0446vbIt8XHefb+wc3UcCW3zvwhAY3HGJWO/YK8lX8qiJ c5HA== 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=bNlo7Xml9kbylJ3btmIU4Plsv/3T5m5XqBhAAklwC+g=; b=mE81HM6hZjby4+i2H5Br+7NFZ/S0YuP1XELrZvhPTxg5X1Cz9fJzR9YoChOQibWS1Z CIYkJr0lDch6gXK5URzlEcA7EmwueW7Ib+nVSbKf13cFJjkYN/aBeoE+m3nrtPujJQ1k J4ynpky/vZTUofmXZaeZdqOG2t1+1lf2Q86/vORJFQitrx6d2q7nXs7YoqSD6WIGthxw g4AJDeGZmfyVJ1clg8iGWDp3YCI0CLOQV5WQaDojMTeRCr7p3xdaf1KQ0i3/72Doz/DV olswD7zxQnyUNl+Yp984GYuUqtNWrxzVOzcOprOX0G4+lSl1ycO0G/f4ZXtMSLY57WUq HQvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=DQIq4JQp; 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 c5-v6si17777821pgq.226.2018.10.09.04.21.43; Tue, 09 Oct 2018 04:22:00 -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=DQIq4JQp; 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 S1727734AbeJIShN (ORCPT + 99 others); Tue, 9 Oct 2018 14:37:13 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45085 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbeJIShL (ORCPT ); Tue, 9 Oct 2018 14:37:11 -0400 Received: by mail-ed1-f66.google.com with SMTP id v18-v6so1301300edq.12 for ; Tue, 09 Oct 2018 04:20:41 -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=bNlo7Xml9kbylJ3btmIU4Plsv/3T5m5XqBhAAklwC+g=; b=DQIq4JQpy9OJOK62xeOmmv3CZpTTqhrpkmYvjLbOKQdDV7rLLU6H6TOrW8DuyNyxOp N06RgOFduXVmwdlw9AK7fBVELACc2qeM21/8sw3/91SLxyOFWJhk/rhZhc2IHXQcM0s/ 2jkgeACUBX0omsyaSYBEk19peqBNV/V+nIERw= 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=bNlo7Xml9kbylJ3btmIU4Plsv/3T5m5XqBhAAklwC+g=; b=hEbV6CLTEKUEGNRFrNfF1yb7FA8KiWM7Cemebt8+hJcBVII1xtT1FXXRrZFNERlVxp +A0b+cRF5Es2W+ECx5PR/EXbYZGZD0CqRViHlP3dBh5iOhNT7w086whdiF773BoYimYR dUXGihEGFlbW/GhgMp8EvnGxKYTN2qjUfIFa97K/L1ch9ESL1u5Kz96Vucz3ebujXdRA JN9Bvgs92DJcWRTFyPcZXJHZqnIacW2l1aERT7PL0ZlZa9nkUZpNOEYGhpRtoj5ghz1P 1GYwsrP6YDuJjLhTD+eHhwnmdlaEFdiQXpjpuJNqsjHVAKIJzRUsLGDWL5nQ9j+xwZIF R2AQ== X-Gm-Message-State: ABuFfoiw0AShC+WvgdFHCEbntxJ165FIj1C/7w2DPjqRvOdV/bmAIFWy 8uOg2IBMdOS9AT+Sbyr/NimEwB6TDJ4= X-Received: by 2002:a50:d09e:: with SMTP id v30-v6mr34554570edd.61.1539084040791; Tue, 09 Oct 2018 04:20:40 -0700 (PDT) Received: from prevas-ravi.vestasvisitor.net ([193.47.71.171]) by smtp.gmail.com with ESMTPSA id n23-v6sm3595821eja.41.2018.10.09.04.20.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 04:20:40 -0700 (PDT) From: Rasmus Villemoes To: Jason Baron , Andrew Morton Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH v2 20/23] dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS Date: Tue, 9 Oct 2018 13:20:10 +0200 Message-Id: <20181009112013.14238-21-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.19.1.4.g721af0fda3 In-Reply-To: <20181009112013.14238-1-linux@rasmusvillemoes.dk> References: <20180919220444.23190-1-linux@rasmusvillemoes.dk> <20181009112013.14238-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 e1be30e8422b..cc4222a20aa1 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 HAVE_JUMP_LABEL diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 4966c4fbe7f7..a4113f746826 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -146,6 +146,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 9d4c840ff0de..61e61b36e479 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.19.1.3.g1d92a00e68