Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1350193imu; Fri, 9 Nov 2018 15:12:11 -0800 (PST) X-Google-Smtp-Source: AJdET5dVTmCKEEJfSh87XveEQ7YI26pjSU12eJhsr47tEresOt5ymSBmGGuMzshwPRclYnRs2pUX X-Received: by 2002:a63:4d0e:: with SMTP id a14mr6316241pgb.408.1541805131368; Fri, 09 Nov 2018 15:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541805131; cv=none; d=google.com; s=arc-20160816; b=KgRklQiv/OiPlPQ9nVs9x8LS9DqY4uUHrC7D5R+XHBKjeuN5Pjn/1ZF3d8VjmR4RNk a+239U5fUVn5lYLrnZSMgg5Jyni1Zrchd6lG0u9cPE/mvenShXdeJaqorWirDRXEE2rN FkIHwu8Nwn/Pw2VDiMekPUIgYjdYQKb8iUKFWGYZENR03vlLnfQ4xxY4jSf3ze0Ahb80 GNWJkexUJEbVJxKVWXQxwTmN1wzzs4PJzU0Pky0b5PBC/HUl0aGb9kjjTnB74v6GgKzC 4otJdWD9C2nFsYaj+jIW2hVme6lmoxj2vcJKkRs+TQ26YrInFhZke6NgQBRYKMFyTXDT LilQ== 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=QIZFEFvzkPZA9DrPR+t1P6RqDjylV60S7jW3I5FB+J4=; b=wNnwa+Ufow4BsaIkaiJ3TUEpf5XdZ/smi1XjlaM3SoF6CM3cyE/GK8XZRhWfi0+U4X JgsxJ9H4UqQnMRNhNE2gkjcU/ze2BXwxqcAxN606IhWcHHqNAx84FzW/Enn8tYlAr5jO 4xecdHpmo6/1yXwCSm0t6Mt+l76i0c0Ra1OWLlubSjNMDiUi775VDoeOF1PKEqVsNUOZ aNzjniwXtqOpxJ13p7ysdbZJKUKmSk71oWXQcqdEgPSK8CX/+xblwrCuDoqOQNu1cT2/ Nlkz9vM6AZiWIxTriKc7Ab2TLt9J2UVyx3ZvfmyBf3lfiyTd0lZ3Ziv+O0rQUBsOJ4fD SxqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=YUa2XjB3; 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 t23si8316828pgi.181.2018.11.09.15.11.55; Fri, 09 Nov 2018 15:12:11 -0800 (PST) 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=YUa2XjB3; 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 S1729072AbeKJIyN (ORCPT + 99 others); Sat, 10 Nov 2018 03:54:13 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34861 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729017AbeKJIyK (ORCPT ); Sat, 10 Nov 2018 03:54:10 -0500 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so2978902ljb.2 for ; Fri, 09 Nov 2018 15:11:25 -0800 (PST) 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=QIZFEFvzkPZA9DrPR+t1P6RqDjylV60S7jW3I5FB+J4=; b=YUa2XjB3kjAlibCWVKzxlBUMktrQ1UdqxzQkShxHkPUywJAOzYODiJuu0qpYzeWAoU 9Vcp9Zr3e0nEM1GlvmrdRNfiPaxXBqdNUuUHb7L1VHNjvqq7MyLMUmt7p0nE4/pJ0LgO T8Mc9hye5tdKDcagtPozBpPWH1ZBBiZgfzST4= 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=QIZFEFvzkPZA9DrPR+t1P6RqDjylV60S7jW3I5FB+J4=; b=CbD8E5YrVioJGgS5yndgdMnlwU5v3unzTASjfRNGpQcd7BMQGzo74KPu5Gm1R765Ka OJXFaDQ38zckLmJ0npMqJkPaf4bMk7VTNF01Eutl2J9ctsMwznQ/XSCLDwdDH+Pbn+vj wk48BmTPDxD5Z2BTgHIxVwmJa7MRC1yyzfUm5Hg+dIhk/6yg2Ibp+L+vs1X1mCjMiffn 0IfPFjVkCBX0bjsSqhUpw2VG/PsbUK/mT9twss7Zd8DcEDvDRj6LUcFxuS2NHb6eE7sG GjOxX1dhZ0iIUSMUqBZCM/LFJ/z+dOaz30VZ0EueduPhuLzoCKXYo3a+WxSWhwpwtFWF kPUw== X-Gm-Message-State: AGRZ1gKEx4UYrHZn/2JxoJuQ5F2RtcNaMD03Cqa06AqU0PzlVGcwEhjO ACf63eEgxukPr3IX5GO0WTacMA== X-Received: by 2002:a2e:59ca:: with SMTP id g71-v6mr6823012ljf.79.1541805084530; Fri, 09 Nov 2018 15:11:24 -0800 (PST) Received: from prevas-ravi.prevas.se (dhcp-5-186-114-252.cgn.ip.fibianet.dk. [5.186.114.252]) by smtp.gmail.com with ESMTPSA id x16sm1584012lff.26.2018.11.09.15.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Nov 2018 15:11:24 -0800 (PST) From: Rasmus Villemoes To: Andrew Morton , Jason Baron Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH v3 20/23] dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS Date: Sat, 10 Nov 2018 00:10:18 +0100 Message-Id: <20181109231021.11658-21-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.19.1.6.gbde171bbf5 In-Reply-To: <20181109231021.11658-1-linux@rasmusvillemoes.dk> References: <20181009112013.14238-1-linux@rasmusvillemoes.dk> <20181109231021.11658-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 1af29b8224fd..1cac0ed659b6 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.6.gbde171bbf5