Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4110943pxk; Tue, 29 Sep 2020 14:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZGOQe23413porY2WBuP+tjga0IybSjcXygAkBgJpWekjbOgrUEkOwMvdU1rH4nmcb3dr9 X-Received: by 2002:a05:6402:16c9:: with SMTP id r9mr5422670edx.27.1601416341668; Tue, 29 Sep 2020 14:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601416341; cv=none; d=google.com; s=arc-20160816; b=E3XAJ1iy7DsMkSB29/h4ya9FEjVFCqJYJlQ4uLCz+FfO5CBoKdImHMU2DJcKiz/32o M5ooDh3z7pjfBneV+eJBQE0cQBpLZP9QtRgj1z1k/0CumYrwxo5nhh0VlUkG9LVvAbgq K9dyhEi8OjTnxh21aEkO/H9l7VXMtDEaDU5AY6vIfOlOU1rx5V487mfZ7aE251Djmfll ZHFGpTmXAuuf0sEQ9Ce4Up9GtIw3UNpdqB3wckkOIJJGYmwAIs+VP6pXctAjDv2Yfjt7 G70pGbVQS/l+n3wu8le31ZhHPNpfETmbN/GRQ3x4LZQHU42bnvwEXyLeWIhx4SLg6gTa 46Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=8Ng/zcoyfJ13YZKcoMDN8gZ1Jwe/pnq5fe0Ym5zenVI=; b=iYZu8iOTUekyZFYR++TjTXh15EfUlorIXJ8fo4dTI339Xx9m1qnxNQVlLs2n+6cS2s LBkNsVEgOfsbSrRY763DJKFK1I1a5B/yguV0nWB/7rOCcNTyOjw1SaB5jXuFwv2pKOrD T6/S/e1w+UHVKSqNDNA786N1cCUuil4oIYFgvpW4ySQi8GsCtNA41pVdsakrYmylhqH+ NU07FbxlnxsXNw+C4QGI4Jn1SHScIJ9fDWsgDVAjIar9HiuWdatnXQnTdS/37EIXhp/2 GNvO2Wq2Oxg72uIz06XJ0WZTXFc3QxjxmeN7qdMd2e0ckdelmPG2Xu4jvN8pPngEetRH p5sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hJ2k1cYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr5si3356938ejc.370.2020.09.29.14.51.58; Tue, 29 Sep 2020 14:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hJ2k1cYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729395AbgI2VsN (ORCPT + 99 others); Tue, 29 Sep 2020 17:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728391AbgI2Vqu (ORCPT ); Tue, 29 Sep 2020 17:46:50 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5383CC0613DC for ; Tue, 29 Sep 2020 14:46:45 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id v187so4107223pgv.0 for ; Tue, 29 Sep 2020 14:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=8Ng/zcoyfJ13YZKcoMDN8gZ1Jwe/pnq5fe0Ym5zenVI=; b=hJ2k1cYf7zI4meIHY8Uy4V6i8Jnw5zJ6gXSyG4ZS4WtWOLM04fL9+GCHaotwi3O1kD kTLYoVlgy7SsG3U4K1msUNtcb16oxXKr4/TQFI7s6Q8/WGPkSRsFDD2GxMPhFHntnEX1 UqTAPnS+KdKGfOUHgSFQg4QyFtojd9IFM7aswALGg98Bion2yPHSsVlFOMvPOBbcGHRk x3eWkDC4MtkEKlr4m7hj4fkr/DRZ/f28+ZAVK6+8KyG71dVLNRRAWvoDBDJaCjYjg2Ib 8nETBKgc3yK1LXOEVRu7drktVSLFory2Vrh/6aBQG6OWMUgiL14xdAH2/sO39VNUdeVj iuMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8Ng/zcoyfJ13YZKcoMDN8gZ1Jwe/pnq5fe0Ym5zenVI=; b=hpSSW1Q4RytlfTBWyt5x3FzTsmcbXtmvbskybZRB+4jB7Gj7kd4xiTS+S5nQs9Ar4h tzUTbupMuqg8il+D7vUPD5l5Z2rC319TmNeACxGvNGywxa34spLcArRLu8w195TDt8Cf NCeGLeNJqkXWotLu+6TDf7Z0zZjCp6LFCPoktsY9cQGxZrVvWKZJ9H/fgjmA/ZUrRyYD MiR34aN/bwgtg7uIqaEg0Q+zr0O049A+qLAkFRw0MsRgtfad1i0s7XP6AU2mrqZFhq6/ m5Ja9MMTjLL3sGfQsgzlfRPZA+8BQ6aA/l9+o50humS0ALMewq/HzBlAERgakgoRIJb2 HARw== X-Gm-Message-State: AOAM532RMFKG/urw0x+PocpC/FIF81ul4GgtG6gvjH5p6x8l+05TLJsP UrZfmFfq9fV4PwZXyyMyAYfimKT4ZVSnRg7rKOk= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a62:8607:0:b029:13f:b379:480a with SMTP id x7-20020a6286070000b029013fb379480amr5736037pfd.5.1601416004713; Tue, 29 Sep 2020 14:46:44 -0700 (PDT) Date: Tue, 29 Sep 2020 14:46:08 -0700 In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> Message-Id: <20200929214631.3516445-7-samitolvanen@google.com> Mime-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 06/29] tracing: move function tracer options to Kconfig From: Sami Tolvanen To: Masahiro Yamada , Will Deacon , Steven Rostedt Cc: Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move function tracer options to Kconfig to make it easier to add new methods for generating __mcount_loc, and to make the options available also when building kernel modules. Signed-off-by: Sami Tolvanen --- Makefile | 20 ++++++++------------ kernel/trace/Kconfig | 16 ++++++++++++++++ scripts/Makefile.build | 6 ++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 476f19ccac17..77e4f0a9495e 100644 --- a/Makefile +++ b/Makefile @@ -841,12 +841,8 @@ KBUILD_CFLAGS += $(DEBUG_CFLAGS) export DEBUG_CFLAGS ifdef CONFIG_FUNCTION_TRACER -ifdef CONFIG_FTRACE_MCOUNT_RECORD - # gcc 5 supports generating the mcount tables directly - ifeq ($(call cc-option-yn,-mrecord-mcount),y) - CC_FLAGS_FTRACE += -mrecord-mcount - export CC_USING_RECORD_MCOUNT := 1 - endif +ifdef CONFIG_FTRACE_MCOUNT_USE_CC + CC_FLAGS_FTRACE += -mrecord-mcount ifdef CONFIG_HAVE_NOP_MCOUNT ifeq ($(call cc-option-yn, -mnop-mcount),y) CC_FLAGS_FTRACE += -mnop-mcount @@ -854,6 +850,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD endif endif endif +ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT + ifdef CONFIG_HAVE_C_RECORDMCOUNT + BUILD_C_RECORDMCOUNT := y + export BUILD_C_RECORDMCOUNT + endif +endif ifdef CONFIG_HAVE_FENTRY ifeq ($(call cc-option-yn, -mfentry),y) CC_FLAGS_FTRACE += -mfentry @@ -863,12 +865,6 @@ endif export CC_FLAGS_FTRACE KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) KBUILD_AFLAGS += $(CC_FLAGS_USING) -ifdef CONFIG_DYNAMIC_FTRACE - ifdef CONFIG_HAVE_C_RECORDMCOUNT - BUILD_C_RECORDMCOUNT := y - export BUILD_C_RECORDMCOUNT - endif -endif endif # We trigger additional mismatches with less inlining diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index a4020c0b4508..927ad004888a 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -595,6 +595,22 @@ config FTRACE_MCOUNT_RECORD depends on DYNAMIC_FTRACE depends on HAVE_FTRACE_MCOUNT_RECORD +config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY + bool + depends on FTRACE_MCOUNT_RECORD + +config FTRACE_MCOUNT_USE_CC + def_bool y + depends on $(cc-option,-mrecord-mcount) + depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY + depends on FTRACE_MCOUNT_RECORD + +config FTRACE_MCOUNT_USE_RECORDMCOUNT + def_bool y + depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY + depends on !FTRACE_MCOUNT_USE_CC + depends on FTRACE_MCOUNT_RECORD + config TRACING_MAP bool depends on ARCH_HAVE_NMI_SAFE_CMPXCHG diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a467b9323442..a4634aae1506 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -178,8 +178,7 @@ cmd_modversions_c = \ fi endif -ifdef CONFIG_FTRACE_MCOUNT_RECORD -ifndef CC_USING_RECORD_MCOUNT +ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT # compiler will not generate __mcount_loc use recordmcount or recordmcount.pl ifdef BUILD_C_RECORDMCOUNT ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") @@ -206,8 +205,7 @@ recordmcount_source := $(srctree)/scripts/recordmcount.pl endif # BUILD_C_RECORDMCOUNT cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \ $(sub_cmd_record_mcount)) -endif # CC_USING_RECORD_MCOUNT -endif # CONFIG_FTRACE_MCOUNT_RECORD +endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT ifdef CONFIG_STACK_VALIDATION ifneq ($(SKIP_STACK_VALIDATION),1) -- 2.28.0.709.gb0816b6eb0-goog