From patchwork Fri Mar 12 09:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=efvpbX9R; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh5z27vGz9sRR for ; Fri, 12 Mar 2021 20:56:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pzC7UP3aTjZAp5A/mbs2M5YZxnFZoTYrCL3NFdLxy5Y=; b=efvpbX9Rf52O8pmZpUlv+vpEP HmGqnS9uldsSkg5sYt3Yy5ISNNy7OY37AiuqL8cYiNnC13oRz3KiICMmFeDNmbtptifEaKPKIm/bb 4BHi3F81b9TEyPKVo4SfAgBPcX+ZQQv6eS4Bn7uJVD9UsvMtB8aJQ1IGUSkR+Xp6FtRQCu3kqtsNf Z4vmpznULy22CYiv68HzlXCRdhob+A6RbDnU/h9rJxHWGkY3PrZ96AVW66bVVhtqHJQtDwBx/uxjp zHOdgX22koFoYe5HENgx8yHipVTHE2KgyQM+RPkrhkb8Bepbx6b8OzMZwUPK78lrLB5gCuD/avb+h BKz/9mPdQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWR-00B5bf-T1; Fri, 12 Mar 2021 09:55:55 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5To-Rl for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:44 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW2-00F7m8-93; Fri, 12 Mar 2021 10:55:30 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 4/6] um: split up CONFIG_GCOV Date: Fri, 12 Mar 2021 10:55:24 +0100 Message-Id: <20210312104627.927fb4c7d36f.Idb980393c41c2129ee592de4ed71e7a5518212f9@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_946423_79DD93DC X-CRM114-Status: GOOD ( 17.31 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg It's not always desirable to collect coverage data for the entire kernel, so split off CONFIG_GCOV_BASE. This option only enables linking with coverage options, and compiles a single file (reboot.c) w [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg It's not always desirable to collect coverage data for the entire kernel, so split off CONFIG_GCOV_BASE. This option only enables linking with coverage options, and compiles a single file (reboot.c) with them as well to force gcov to be linked into the kernel binary. That way, modules also work. To use this new option properly, one needs to manually add '-fprofile-arcs -ftest-coverage' to the compiler options of some object(s) or subdir(s) to collect coverage data at the desired places. Signed-off-by: Johannes Berg --- arch/um/Kconfig.debug | 38 ++++++++++++++++++++++++++++++-------- arch/um/Makefile-skas | 2 +- arch/um/kernel/Makefile | 11 ++++++++++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index 315d368e63ad..ca040b4e86e5 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug @@ -13,19 +13,41 @@ config GPROF If you're involved in UML kernel development and want to use gprof, say Y. If you're unsure, say N. -config GCOV - bool "Enable gcov support" +config GCOV_BASE + bool "Enable gcov support (selectively)" depends on DEBUG_INFO - depends on !KCOV + depends on !KCOV && !GCOV_KERNEL help This option allows developers to retrieve coverage data from a UML - session. + session, stored to disk just like with a regular userspace binary, + use the same tools (gcov, lcov, ...) to collect and process the + data. - See for more - details. + See also KCOV and GCOV_KERNEL as alternatives. - If you're involved in UML kernel development and want to use gcov, - say Y. If you're unsure, say N. + This option (almost) only links with the needed support code, but + doesn't enable coverage data collection for any code (other than a + dummy file to get everything linked properly). See also the GCOV + option which enables coverage collection for the entire kernel and + all modules. + + If you're using UML to test something and want to manually instruct + the compiler to instrument only parts of the code by adding the + relevant options for the objects you care about, say Y and do that + to get coverage collection only for the parts you need. + + If you're unsure, say N. + +config GCOV + bool "Enable gcov support (whole kernel)" + depends on DEBUG_INFO + depends on !KCOV && !GCOV_KERNEL + select GCOV_BASE + help + This enables coverage data collection for the entire kernel and + all modules, see the GCOV_BASE option for more information. + + If you're unsure, say N. config EARLY_PRINTK bool "Early printk" diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas index ac35de5316a6..b5be5f55ac11 100644 --- a/arch/um/Makefile-skas +++ b/arch/um/Makefile-skas @@ -8,5 +8,5 @@ GCOV_OPT += -fprofile-arcs -ftest-coverage CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) -LINK-$(CONFIG_GCOV) += $(GCOV_OPT) +LINK-$(CONFIG_GCOV_BASE) += $(GCOV_OPT) LINK-$(CONFIG_GPROF) += $(GPROF_OPT) diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index c1205f9ec17e..0403e329f931 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -21,7 +21,7 @@ obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o -obj-$(CONFIG_GCOV) += gmon_syms.o +obj-$(CONFIG_GCOV_BASE) += gmon_syms.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_GENERIC_PCI_IOMAP) += ioport.o @@ -32,6 +32,15 @@ include arch/um/scripts/Makefile.rules targets := config.c config.tmp +# This just causes _something_ to be compiled with coverage +# collection so that gcov is linked into the binary, in case +# the only thing that has it enabled is a module, when only +# CONFIG_GCOV_BASE is selected. Yes, we thus always get some +# coverage data for this file, but it's not hit often ... +ifeq ($(CONFIG_GCOV_BASE),y) +CFLAGS_reboot.o += -fprofile-arcs -ftest-coverage +endif + # Be careful with the below Sed code - sed is pitfall-rich! # We use sed to lower build requirements, for "embedded" builders for instance.