Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp380210pxu; Tue, 1 Dec 2020 13:40:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwlF+5FZDayxOuzIe5NphZRym19QGRbYc67ED1mk2LgqO/5ksvmGDRDI/+WuZWU1gbdOEf X-Received: by 2002:aa7:c403:: with SMTP id j3mr5098212edq.217.1606858827729; Tue, 01 Dec 2020 13:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606858827; cv=none; d=google.com; s=arc-20160816; b=LyEJ/3IBhQhniH+xUbqAntuS5GkhTt1W27og0mqHjgmaiStZWZ6rzRfHvhLIGcUkss A2d5Ha8Ff6lL8UR5eZaEG8G9Y3F4rRS3vF0OONwQi69IAsBZupivK7vIkV8VUqUnFqDW dsdIdvmdJqdZZ9criNCMTICXA6Osk5uuOlVFZx/ORIIssQI49HlB2IL3RoizNpq1iR3F VOD7gSOgQwlgxC21PIWjLxyP92cpQCSYzpXec18IG6qShIU1sSxV0rX7hN72zw1kDSh/ x2NsmnrW1PWzHR4MW6kaVBWVcP2DTHrbTF5iEBk2RokxOHUDbPXOYnSZVMadNk6ASn8H uNyQ== 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=VOfy7I+JfJNFr5nKa99p/PnWq1cmu5wGQSaePmGF9lo=; b=IpP+suechJdkjnNGI7gQlPYF8USL9KaSAIjJ/zLKCMLiAyCrUaTQdssUaC/6OsYkvD 41i61NOTACt+jHKt6aPWXy/JVe6L4iZaRNkt5kBftB+FYaeps98Rf8pClIO3z9fGpkNK 85/sn0Klr6vfi12teoPSRMoEw0QRNvYfDDCqx05rKF9C37iMKmwVTBtpU2r4VFVIbYg8 6t2rBnhfxJFZx8EG8WwagVKG+T/P33NVlB0qgT75/fmQDwToBFTqgJZVl54CjHqikZ9V pZjbsB6tav8Yq12l+voXUL/205Sveo9pNaSQOmi34IKVa610XvkO8n6g4GXZkC7Pa8df WaOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dodU69bM; 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 u23si743117ejj.163.2020.12.01.13.40.05; Tue, 01 Dec 2020 13:40:27 -0800 (PST) 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=dodU69bM; 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 S1729843AbgLAVih (ORCPT + 99 others); Tue, 1 Dec 2020 16:38:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729317AbgLAVih (ORCPT ); Tue, 1 Dec 2020 16:38:37 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1070BC061A04 for ; Tue, 1 Dec 2020 13:37:13 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id i14so2269584qtq.18 for ; Tue, 01 Dec 2020 13:37:13 -0800 (PST) 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=VOfy7I+JfJNFr5nKa99p/PnWq1cmu5wGQSaePmGF9lo=; b=dodU69bM2w4739uzVye+y4jtglX3kpRzjscI0GbwcduOaRiiAF4qIiLCdF1q6oX3wk pUD5Ndeh73E2deG4Whw5KpplKyo+tERYmf13gaWfLYPGdA3PlmgrkbjNepiosHlzkLxk bNPX9Mln5u4xxSb2ddOYEHu9vBV5aswLRqXq1YvmJGNA+UFionr74fPHqks/AmBjSG5K wImLilm8AUw64QLRFpWry1xi+iqe+xBzAckeWyBEk70hGn1j6CtUCDU71oPM5PyxtS24 uxteYTrSE1Z32cdNjH3k9kEfWfQDveAyVC+dZStPY32Swa3uQRYzcILaUV3t8/keJNMz No+w== 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=VOfy7I+JfJNFr5nKa99p/PnWq1cmu5wGQSaePmGF9lo=; b=IZjEznYoY574c5IBbKLfXIFK1sbfQgeNafNBzb+XEGgJKioKlN6ShjfVzbCnEQ0i3l vhXK6/gAhPyeIKNrc/xbQ8+J6KnI5lHG7dkxEB89r7GgJyzIKZozTDfKSUpF7W1JMCB+ YfiPeqHOJqTjQmmSFSAnGEbWs2bu+h4yQt1f23d/LTBVEd9wuZtPYRD9wMjcgmDZwquI e+pXBPTMDcYii/eqrPYLjCHmf/2fSYmJWVvIDvH/dXeVWdQOBZ2N7/Gl+rSIiEg3Zd6N nArWOxgBUP4hbEnRoHPX0uhfsEAiZfnCrWpFqdSrDGnZtSTFiQNwkXf4FHRf3d1A6/sC 0fvQ== X-Gm-Message-State: AOAM532VOqs7GpL9WviIJzYyk6G4Lu2gtiaX741JYnk8vLd0SkGK2OZD 2NYyJ8wN/qGy3sDQD6PdxcxZsUjYOFTrwnH/pOk= 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:a0c:bd10:: with SMTP id m16mr5440647qvg.15.1606858632172; Tue, 01 Dec 2020 13:37:12 -0800 (PST) Date: Tue, 1 Dec 2020 13:36:52 -0800 In-Reply-To: <20201201213707.541432-1-samitolvanen@google.com> Message-Id: <20201201213707.541432-2-samitolvanen@google.com> Mime-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH v8 01/16] tracing: move function tracer options to Kconfig From: Sami Tolvanen To: Masahiro Yamada , Steven Rostedt , Will Deacon Cc: Josh Poimboeuf , 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, 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. Note that FTRACE_MCOUNT_USE_* options are updated on rebuild and therefore, work even if the .config was generated in a different environment. 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 43ecedeb3f02..16b7f0890e75 100644 --- a/Makefile +++ b/Makefile @@ -849,12 +849,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 @@ -862,6 +858,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 @@ -871,12 +873,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 ae647379b579..2175ddb1ee0c 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.29.2.576.ga3fc446d84-goog