Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1350236imu; Fri, 9 Nov 2018 15:12:14 -0800 (PST) X-Google-Smtp-Source: AJdET5cZNLbeb51IJ3AmznZBfYw9S6bZ0pHi3XJHj2eQlS1inepCY5xYubvdODWMaNVg6NTSFeJ2 X-Received: by 2002:a17:902:8302:: with SMTP id bd2-v6mr8824314plb.100.1541805134550; Fri, 09 Nov 2018 15:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541805134; cv=none; d=google.com; s=arc-20160816; b=s16mk0Ef38K0mCE1th3l1fq4gyCji97YpSQGQSghx4sEZ1WXJ6hIIGoZvF/pKv98dA 31NABJs3Q3kdHFgkklqdxunkaB+jxT68wzdIg2A/Y8scjHAPyhHYZY8Pvzd+SGGUb0pV nAS74Q04Y0iG7/o+qZGS1sLjjkMusqvHJc0w2jsq35jmajZ9ExZ++iqr/wCK5JDnivgf NVyaZQTPnq9oF21z7gxj4ZcJyhhNuMqUDo4eFTmNOg3Myu3Egtlh1tHN4UOF1qn4fkJA IfK4x55v5VGmEEyaAUiCvEP83qgOqp35AzUnx5bOq+4boSUKVgJQucoPFsNX0aTuK/LC rfag== 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=ZxYezAbvcYT+DmndAaVqMLZ3DVn779bkEogocNkcQok=; b=xuda3nic4Us5aCJkrDokEmBs0ab8DApLnSBtpCwPgA2FuUSXa30TxKggfru6K3dpGn oQSTORkcczpx0UJ9Ii0P7hnGuL0rjQI8wSEnICcwtMls3HZlUMfPZfk8vzUJ8XMvWnNG GV/W6ylW0XeLWpzowXT2klL2Pgswn40qIegXWAZxGCBNUrJbCp9ChivsnNnWNbiEzYZw VpzD0h2ErbyD3+lx52gX5Cddhe9OQyP6bM+3YyW4+eQndBBF5ZIc5HMYxRckzR2u9KlR Rhanr1OaTP4gxi5pDwT21yji67unHESuibBqonbYYo6a1ZnKWR+J5u2rIgv9I9g/HmBS jFgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=WF2B5Wfn; 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 f91-v6si9658650plf.324.2018.11.09.15.11.59; Fri, 09 Nov 2018 15:12:14 -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=WF2B5Wfn; 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 S1729088AbeKJIyQ (ORCPT + 99 others); Sat, 10 Nov 2018 03:54:16 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38175 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729074AbeKJIyP (ORCPT ); Sat, 10 Nov 2018 03:54:15 -0500 Received: by mail-lf1-f68.google.com with SMTP id p86so2500236lfg.5 for ; Fri, 09 Nov 2018 15:11:29 -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=ZxYezAbvcYT+DmndAaVqMLZ3DVn779bkEogocNkcQok=; b=WF2B5Wfn359DGYJp03v5+YUJXklZAqDKzF06NeiNj2FYLBa3DvA9fNxBXcKLAikAYN aLCG3vj90ikjGACDYAQR6lKKR+3xwHhJ0rzySfTyYQr3blTm7Q3Xs8QPD91Bt/4GY3Mk Tlg6uDgJcYJpj2DHNjomIDuCnxWO6Vr76p5j0= 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=ZxYezAbvcYT+DmndAaVqMLZ3DVn779bkEogocNkcQok=; b=WcBsIxiodlto517aW6CW2tlKMrAPcsD5+XqRooMcuw4R+xy9TQNTdKEaThpSajun1T b/6OoyoNpHsuotcAotjAY5koYdsAIW+M5nvHPicghPCN5iQrzEpzBMOXQ4kUkxmryIlz pl7t66tf1UKcKEGKrBsAwJgk57xCUeZuLi7McLlvUp3et4IFRlKsTv+ZqMudJfe1duLq 07R43vQp6jYk1E7/9M1APc2k8y1c2DJimXu3Vdo8rdeANPFXsVwGPzmUS72n1eT4W+Lo RbmURXSsufb8kyfqPaVa1gFaXAZ+QjUcHyvfcZoryPAVUOxO8RmqafN4BWCtuhJW1n3c /x6w== X-Gm-Message-State: AGRZ1gJqnsYndRb39UQBEeBjSt5tPtUyHS4qam6XT9G3/MaPNmfV1PCh isCuivY11HLiNAFIljMTqYVaGg== X-Received: by 2002:a19:9dd1:: with SMTP id g200mr6210714lfe.127.1541805088505; Fri, 09 Nov 2018 15:11:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Nov 2018 15:11:28 -0800 (PST) From: Rasmus Villemoes To: Andrew Morton , Jason Baron Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes , x86@kernel.org, Ingo Molnar Subject: [PATCH v3 23/23] x86_64: use relative pointers with dynamic debug Date: Sat, 10 Nov 2018 00:10:21 +0100 Message-Id: <20181109231021.11658-24-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 Similar to how x86_64 uses bug_entry-relative pointers to reduce sizeof(struct bug_entry), the same thing can now be done for struct _ddebug, saving 16 bytes for each of those (i.e., each pr_debug, dev_dbg etc. in a CONFIG_DYNAMIC_DEBUG kernel). Note the use of .ifndef/.endif in asm to avoid fs/aio.c:1382: Error: symbol `__UNIQUE_ID_ddebug112' is already defined This is due to uses of pr_debug et al in functions that get inlined. In such a case, __COUNTER__ is obviously only expanded once, but the asm() is repeated once for every inlined instance. Letting all instances share the same descriptor object is the right thing to do; that is also what happens when it is the compiler that defines a static object inside an inline(d) function. That, however, leads to another problem if the same identifier is used in two different DEFINE_DYNAMIC_DEBUG_METADATA() in the same translation unit: They would both end up referring to the same (first occuring) instance. So the second one would end up using the wrong file, line, function etc. information. All current in-tree macro users of DEFINE_DYNAMIC_DEBUG_METADATA() have been updated to ensure they use UNIQUE_ID to generate the identifier. To prevent such a problem from going unnoticed, we use a guard symbol in assembly whose value is unique per DEFINE_DYNAMIC_DEBUG_METADATA invocation. Cc: x86@kernel.org Cc: Ingo Molnar Cc: Jason Baron Signed-off-by: Rasmus Villemoes --- arch/x86/Kconfig | 1 + arch/x86/include/asm/dynamic_debug.h | 58 ++++++++++++++++++++++++++++ arch/x86/kernel/macros.S | 1 + 3 files changed, 60 insertions(+) create mode 100644 arch/x86/include/asm/dynamic_debug.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ba7e3464ee92..c7cb31f39e5a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -91,6 +91,7 @@ config X86 select CLOCKSOURCE_WATCHDOG select DCACHE_WORD_ACCESS select DMA_DIRECT_OPS + select DYNAMIC_DEBUG_RELATIVE_POINTERS if X86_64 select EDAC_ATOMIC_SCRUB select EDAC_SUPPORT select GENERIC_CLOCKEVENTS diff --git a/arch/x86/include/asm/dynamic_debug.h b/arch/x86/include/asm/dynamic_debug.h new file mode 100644 index 000000000000..80730409183f --- /dev/null +++ b/arch/x86/include/asm/dynamic_debug.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_DYNAMIC_DEBUG_H +#define _ASM_X86_DYNAMIC_DEBUG_H + +#ifndef __ASSEMBLY__ + +#ifdef DEBUG +#define _DPRINTK_INIT_TRUE 1 +#else +#define _DPRINTK_INIT_TRUE 0 +#endif + +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + extern struct _ddebug name; \ + asm volatile("DYNAMIC_DEBUG_METADATA" \ + " ident="__stringify(name) \ + " modname=%c0" \ + " func=%c1" \ + " file=%c2" \ + " fmt=%c3" \ + " flag_line=%c4" \ + " init_true=%c5" \ + " cnt=%c6" \ + : : "i" (KBUILD_MODNAME), "i" (__func__), \ + "i" (__FILE__), "i" (fmt), \ + "i" (_DPRINTK_FLAGS_LINENO_INIT), \ + "i" (_DPRINTK_INIT_TRUE), \ + "i" (__COUNTER__) \ + ) + +#else /* __ASSEMBLY__ */ + +.macro DYNAMIC_DEBUG_METADATA ident modname func file fmt flag_line init_true cnt +.ifndef \ident + .pushsection __verbose,"aw" +\ident : + .long \modname - \ident + .long \func - \ident + .long \file - \ident + .long \fmt - \ident + .long \flag_line + .long 0 + .if \init_true + STATIC_KEY_INIT_TRUE + .else + STATIC_KEY_INIT_FALSE + .endif + .popsection + .set \ident\().ddebug.once, \cnt +.elseif \ident\().ddebug.once - \cnt + .error "'\ident' used as _ddebug identifier more than once" +.endif +.endm + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_X86_DYNAMIC_DEBUG_H */ + diff --git a/arch/x86/kernel/macros.S b/arch/x86/kernel/macros.S index 161c95059044..2c2b8e5229a9 100644 --- a/arch/x86/kernel/macros.S +++ b/arch/x86/kernel/macros.S @@ -14,3 +14,4 @@ #include #include #include +#include -- 2.19.1.6.gbde171bbf5