From patchwork Tue Mar 19 16:07:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13596840 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94A1681AAA; Tue, 19 Mar 2024 16:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864481; cv=none; b=OeI3vMNdg6yjVMmtiq0tKq56xPDg4kqfKI9CQbCUsOrsV5dXBgPB50WamC4kSQLeA++3O+w1JZRfQ7qf92QkvYQgFxZu14dIiM5G85UpvbQqJqUokqle/6YfyIbM+BF6Ue/V0soGStqYFUX4OZbo3yXIwi7yj0BxNls0jOXUVJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864481; c=relaxed/simple; bh=2oPRCy2jisk83BK9tWeY8QIf69NClUJuFjLh49eN6r0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ln38dstdQImXd5xm7mIcahK3WihL3Wm/Y1hlmfzWgoLJ91EY14GOCP6vn2FBwv9nOy2Wf52ja+z7Rc9P7My1TxsFTI3+48/6vpydgolNBmEATvJUkMucfO+3DmpV8WmCR2VNdDxNURNwRpdfVAxUXHGch7UvT+xdILfR1BAwtgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HVz/p9rB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HVz/p9rB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99459C433C7; Tue, 19 Mar 2024 16:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710864481; bh=2oPRCy2jisk83BK9tWeY8QIf69NClUJuFjLh49eN6r0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HVz/p9rBxhLOlLri5i/0BzV9oAyPFuWl446RsG5glK2Fb9QuyrYeK7iDpNGAceUDs JpybmA6kMskp7XblzeigLRxUDb+lmOCHKYF1apEwS37IalkjmeqTWYxJrLMwsS5vTW 9z2czcLT7o7SgrGFr1Q4nC2TyQTJ9a4VsD434q4LjXDbI9Um8yF8Qw92uyHbLTX/ix PM5QjPXgSNHDt6ejmQJXKjavZcGLrwdeIr2H4JdVpNa79lZ6z3W+qpaAPqvKmMrwxC PWPxgkgeLTncmtrBmZAEfAdeJ9NgCqTaAALcq5T5FD+kCUBrGletNb2NLWxWUJtDH+ FQUlwBq30YgzQ== From: Nathan Chancellor Date: Tue, 19 Mar 2024 09:07:52 -0700 Subject: [PATCH 1/2] compiler_types: Ensure __diag_clang() is always available Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240319-tracing-fully-silence-wstring-compare-v1-1-81adb44403f5@kernel.org> References: <20240319-tracing-fully-silence-wstring-compare-v1-0-81adb44403f5@kernel.org> In-Reply-To: <20240319-tracing-fully-silence-wstring-compare-v1-0-81adb44403f5@kernel.org> To: rostedt@goodmis.org, mhiramat@kernel.org Cc: mathieu.desnoyers@efficios.com, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1458; i=nathan@kernel.org; h=from:subject:message-id; bh=2oPRCy2jisk83BK9tWeY8QIf69NClUJuFjLh49eN6r0=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKk/d8QHGN6Jk5eUfuqdlPjaq3AGg+KDv2ttSu+cev9MU I214s2jjlIWBjEuBlkxRZbqx6rHDQ3nnGW8cWoSzBxWJpAhDFycAjARhWhGhpZp8t/DEvb8m8t9 vnPloyumYmcbDZ+3eOrzbnGwljmRGMDwz1Jnh+aRY8KHrITq/WL6vGxK7/EVVFR6XVqRqu4a7zW RCQA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Attempting to use __diag_clang() and build with GCC results in a build error: include/linux/compiler_types.h:468:38: error: 'ignore' undeclared (first use in this function); did you mean 'inode'? 468 | __diag_ ## compiler(version, ignore, option) | ^~~~~~ This error occurs because __diag_clang() is only defined in compiler-clang.h, which is only included when using clang as the compiler. This error has not been seen before because __diag_clang() has only been used in __diag_ignore_all(), which is defined in both compiler-clang.h and compiler-gcc.h. Add an empty stub for __diag_clang() in compiler_types.h, so that it is always defined and just becomes a no-op when using GCC. Fixes: f014a00bbeb0 ("compiler-clang.h: Add __diag infrastructure for clang") Signed-off-by: Nathan Chancellor Reviewed-by: Justin Stitt --- include/linux/compiler_types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 3e64ec0f7ac8..fb0c3ff5497d 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -461,6 +461,10 @@ struct ftrace_likely_data { #define __diag_GCC(version, severity, string) #endif +#ifndef __diag_clang +#define __diag_clang(version, severity, string) +#endif + #define __diag_push() __diag(push) #define __diag_pop() __diag(pop) From patchwork Tue Mar 19 16:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13596841 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 608AD823C4; Tue, 19 Mar 2024 16:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864482; cv=none; b=rK6IeZf4jOV6XOP9ohLQ5Dl5e5yxaublewFRrKQwitCPYOTTC6SPXpOIDWpyqFKsu3nvRZl5u22CV8SDde/SdZBjCrfgmKNiozESU5yaIyJkSghHdWJUgZ+Zmv+eYyrCcDQwVtcQOYI6uxydstQ7f3rUVhDSDPrL4NJZkB9ITcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864482; c=relaxed/simple; bh=w2V5d2UCp17oxIbLB5SOI4dH0DOO083lsUavf7oC++4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dv9oimm/QW88JIv6Dgh01FPSdimIsAsh9j4dqV9qlwKvPRndxVVOeI8muMlVd0Ktvz5TfQPAqh4XkyDOjh7cAe1zgd9RXe/NlUAZLGjvQs2xa/0yLXJi0AW50a9G6HJDW63IPG2HTr3s5FCxgvV2uanwni1gskVfXKGw+a1sEK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E3tSh9A5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E3tSh9A5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60280C433B1; Tue, 19 Mar 2024 16:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710864482; bh=w2V5d2UCp17oxIbLB5SOI4dH0DOO083lsUavf7oC++4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=E3tSh9A5+XGqk4VZBDEd/MVbLWUCyGytI3xgprjfOtf3E8EYVjB1bHoWdT/UIzekT w9+Wy5Mqg+yQWRhsWudBzsdacxXg7NXQVH+ZPgnbfcH0kVnlbMx7tfajWSM9eUjXsn oNxqN7ugN2W7/M6wvZ7IAMe2Tt8vcgFWpdAZvkh6CScEW11jPU4fQh2MC1xH2VSIDW DRdyxUGsSg+44m1MW95V4f9vlQbkJ3rLIRCUo5HP6NGtGb5HQiF/gYDHmm8ibwdXNd H+dXSZpDJ0kzFF6MfdQ0otiGA+j1Ge96FyypYy84O7Phjw0MiS11zburvPfriokXNx XFHffYkUyaaGw== From: Nathan Chancellor Date: Tue, 19 Mar 2024 09:07:53 -0700 Subject: [PATCH 2/2] tracing: Ignore -Wstring-compare with diagnostic macros Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240319-tracing-fully-silence-wstring-compare-v1-2-81adb44403f5@kernel.org> References: <20240319-tracing-fully-silence-wstring-compare-v1-0-81adb44403f5@kernel.org> In-Reply-To: <20240319-tracing-fully-silence-wstring-compare-v1-0-81adb44403f5@kernel.org> To: rostedt@goodmis.org, mhiramat@kernel.org Cc: mathieu.desnoyers@efficios.com, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Linux Kernel Functional Testing , Nathan Chancellor X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2414; i=nathan@kernel.org; h=from:subject:message-id; bh=w2V5d2UCp17oxIbLB5SOI4dH0DOO083lsUavf7oC++4=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKk/d8R7Hs/lnXK5btVJPat/s5lNFeuF1v3onvZ1S8aea oUfdw8e6ShlYRDjYpAVU2Spfqx63NBwzlnGG6cmwcxhZQIZwsDFKQAT+bub4b+7dNrTHXVsa/9O +Mgoad3hwerOPyVwy6P95yY8ailrKGZhZLh0+HSu9apfVhN9DJ4ekH7tyWYXeH3G/jOTpzdIhK9 hEGYGAA== X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Commit b1afefa62ca9 ("tracing: Use strcmp() in __assign_str() WARN_ON() check") addressed a clang warning, -Wstring-compare, with the use of __builtin_constant_p() to dispatch to strcmp() if the source string is a string literal and a direct comparison if not. Unfortunately, even with this change, the warning is still present because __builtin_constant_p() is not evaluated at this stage of the pipeline, so clang still thinks the else branch could occur for this situation: include/trace/events/sunrpc.h:705:4: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] ... include/trace/stages/stage6_event_callback.h:40:15: note: expanded from macro '__assign_str' 40 | (src) != __data_offsets.dst##_ptr_); \ | ^ ... Use the compiler diagnostic macros to disable this warning around the WARN_ON_ONCE() expression since a string comparison function, strcmp(), will always be used for the comparison of string literals. Fixes: b1afefa62ca9 ("tracing: Use strcmp() in __assign_str() WARN_ON() check") Reported-by: Linux Kernel Functional Testing Closes: https://lore.kernel.org/all/CA+G9fYs=OTKAZS6g1P1Ewadfr0qoe6LgOVSohqkXmFXotEODdg@mail.gmail.com/ Signed-off-by: Nathan Chancellor --- include/trace/stages/stage6_event_callback.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 83da83a0c14f..56a4eea5a48e 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -35,9 +35,14 @@ do { \ char *__str__ = __get_str(dst); \ int __len__ = __get_dynamic_array_len(dst) - 1; \ + __diag_push(); \ + __diag_ignore(clang, 11, "-Wstring-compare", \ + "__builtin_constant_p() ensures strcmp()" \ + "will be used for string literals"); \ WARN_ON_ONCE(__builtin_constant_p(src) ? \ strcmp((src), __data_offsets.dst##_ptr_) : \ (src) != __data_offsets.dst##_ptr_); \ + __diag_pop(); \ memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ EVENT_NULL_STR, __len__); \ __str__[__len__] = '\0'; \