public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: oberpar@linux.ibm.com
Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 3/4] gcov: add MC/DC condition coverage support
Date: Sat, 14 Mar 2026 10:17:48 -0400	[thread overview]
Message-ID: <20260314141749.3382679-4-sashal@kernel.org> (raw)
In-Reply-To: <20260314141749.3382679-1-sashal@kernel.org>

Add CONFIG_GCOV_CONDITION_COVERAGE option to enable GCC's MC/DC
condition coverage instrumentation (-fcondition-coverage). MC/DC is
required by safety standards such as DO-178C and ISO 26262.

Add -fcondition-coverage and -Wno-error=coverage-too-many-conditions
to CFLAGS_GCOV when enabled. Both flags are gated on the config option
to avoid Clang warnings about unknown options.

Also add -fcondition-coverage to CFLAGS_REMOVE in the x86 UML vDSO
Makefile to prevent instrumentation of userspace vDSO code.

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 Makefile                  |  3 +++
 arch/x86/um/vdso/Makefile |  4 ++--
 kernel/gcov/Kconfig       | 15 +++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 2b15f0b4a0cb5..5b0657cd3e534 100644
--- a/Makefile
+++ b/Makefile
@@ -807,6 +807,9 @@ CFLAGS_GCOV	:= -fprofile-arcs -ftest-coverage
 ifdef CONFIG_CC_IS_GCC
 CFLAGS_GCOV	+= -fno-tree-loop-im
 endif
+ifdef CONFIG_GCOV_CONDITION_COVERAGE
+CFLAGS_GCOV	+= -fcondition-coverage -Wno-error=coverage-too-many-conditions
+endif
 export CFLAGS_GCOV
 
 # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later.
diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile
index 8a7c8b37cb6eb..3c8909f96a4c0 100644
--- a/arch/x86/um/vdso/Makefile
+++ b/arch/x86/um/vdso/Makefile
@@ -44,8 +44,8 @@ $(vobjs): KBUILD_CFLAGS += $(CFL)
 #
 # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
 #
-CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
-CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
+CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage -fcondition-coverage
+CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage -fcondition-coverage
 
 #
 # The DSO images are built using a special linker script.
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index 04f4ebdc3cf59..7939c8f5ced3c 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -52,4 +52,19 @@ config GCOV_PROFILE_ALL
 	larger and run slower. Also be sure to exclude files from profiling
 	which are not linked to the kernel image to prevent linker errors.
 
+config GCOV_CONDITION_COVERAGE
+	bool "Enable MC/DC condition coverage instrumentation"
+	depends on GCOV_KERNEL
+	depends on CC_HAS_CONDITION_COVERAGE
+	default n
+	help
+	This option adds Modified Condition/Decision Coverage (MC/DC)
+	instrumentation using GCC's -fcondition-coverage flag. MC/DC
+	coverage data can be viewed using gcov --conditions.
+
+	MC/DC is required by safety standards such as DO-178C (avionics)
+	and ISO 26262 (automotive).
+
+	This increases instrumentation overhead. If unsure, say N.
+
 endmenu
-- 
2.51.0


  parent reply	other threads:[~2026-03-14 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-14 14:17 [PATCH 0/4] gcov: Add MC/DC condition coverage support Sasha Levin
2026-03-14 14:17 ` [PATCH 1/4] gcov: fix gcov_info_add() merge semantics for IOR counters Sasha Levin
2026-03-14 14:17 ` [PATCH 2/4] kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detection Sasha Levin
2026-03-14 14:17 ` Sasha Levin [this message]
2026-03-14 14:17 ` [PATCH 4/4] Documentation: gcov: document MC/DC condition coverage support Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260314141749.3382679-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=oberpar@linux.ibm.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox