From: Guenter Roeck <linux@roeck-us.net> To: linux-kselftest@vger.kernel.org Cc: "David Airlie" <airlied@gmail.com>, "Arnd Bergmann" <arnd@arndb.de>, "Maíra Canal" <mcanal@igalia.com>, "Dan Carpenter" <dan.carpenter@linaro.org>, "Kees Cook" <keescook@chromium.org>, "Daniel Diaz" <daniel.diaz@linaro.org>, "David Gow" <davidgow@google.com>, "Arthur Grillo" <arthurgrillo@riseup.net>, "Brendan Higgins" <brendan.higgins@linux.dev>, "Naresh Kamboju" <naresh.kamboju@linaro.org>, "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>, "Andrew Morton" <akpm@linux-foundation.org>, "Maxime Ripard" <mripard@kernel.org>, "Ville Syrjälä" <ville.syrjala@linux.intel.com>, "Daniel Vetter" <daniel@ffwll.ch>, "Thomas Zimmermann" <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, "Guenter Roeck" <linux@roeck-us.net> Subject: [RFC PATCH 5/5] loongarch: Add support for suppressing warning tracebacks Date: Tue, 5 Mar 2024 10:40:33 -0800 [thread overview] Message-ID: <20240305184033.425294-6-linux@roeck-us.net> (raw) In-Reply-To: <20240305184033.425294-1-linux@roeck-us.net> Add support for selectively suppressing WARNING tracebacks to loongarch. This requires adding the function triggering tracebacks to the __bug_table object section. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- arch/loongarch/include/asm/bug.h | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index d4ca3ba25418..25f2b5ae7702 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,47 +3,63 @@ #define __ASM_BUG_H #include <asm/break.h> +#include <kunit/bug.h> #include <linux/stringify.h> #ifndef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #else -#define __BUGVERBOSE_LOCATION(file, line) \ +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str, "aMS", @progbits, 1; \ 10002: .string file; \ .popsection; \ \ .long 10002b - .; \ + __BUG_FUNC_PTR(func) \ .short line; -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) #endif #ifndef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #else -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table, "aw"; \ .align 2; \ 10000: .long 10001f - .; \ - _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + _BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .popsection; \ 10001: #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ break BRK_BUG -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) + +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif #define __BUG_FLAGS(flags) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) : : "i" (__BUG_FUNC)); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ instrumentation_end(); \ } while (0) -- 2.39.2
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net> To: linux-kselftest@vger.kernel.org Cc: "David Airlie" <airlied@gmail.com>, "Arnd Bergmann" <arnd@arndb.de>, "Maíra Canal" <mcanal@igalia.com>, "Dan Carpenter" <dan.carpenter@linaro.org>, "Kees Cook" <keescook@chromium.org>, "Daniel Diaz" <daniel.diaz@linaro.org>, "David Gow" <davidgow@google.com>, "Arthur Grillo" <arthurgrillo@riseup.net>, "Brendan Higgins" <brendan.higgins@linux.dev>, "Naresh Kamboju" <naresh.kamboju@linaro.org>, "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>, "Andrew Morton" <akpm@linux-foundation.org>, "Maxime Ripard" <mripard@kernel.org>, "Ville Syrjälä" <ville.syrjala@linux.intel.com>, "Daniel Vetter" <daniel@ffwll.ch>, "Thomas Zimmermann" <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, "Guenter Roeck" <linux@roeck-us.net> Subject: [RFC PATCH 5/5] loongarch: Add support for suppressing warning tracebacks Date: Tue, 5 Mar 2024 10:40:33 -0800 [thread overview] Message-ID: <20240305184033.425294-6-linux@roeck-us.net> (raw) In-Reply-To: <20240305184033.425294-1-linux@roeck-us.net> Add support for selectively suppressing WARNING tracebacks to loongarch. This requires adding the function triggering tracebacks to the __bug_table object section. To limit image size impact, the pointer to the function name is only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. Otherwise, the __func__ assembly parameter is replaced with a (dummy) NULL parameter to avoid an image size increase due to unused __func__ entries (this is necessary because __func__ is not a define but a virtual variable). Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- arch/loongarch/include/asm/bug.h | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h index d4ca3ba25418..25f2b5ae7702 100644 --- a/arch/loongarch/include/asm/bug.h +++ b/arch/loongarch/include/asm/bug.h @@ -3,47 +3,63 @@ #define __ASM_BUG_H #include <asm/break.h> +#include <kunit/bug.h> #include <linux/stringify.h> #ifndef CONFIG_DEBUG_BUGVERBOSE -#define _BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) #else -#define __BUGVERBOSE_LOCATION(file, line) \ +#if IS_ENABLED(CONFIG_KUNIT) +# define HAVE_BUG_FUNCTION +# define __BUG_FUNC_PTR(func) .long func - .; +#else +# define __BUG_FUNC_PTR(func) +#endif + +#define __BUGVERBOSE_LOCATION(file, func, line) \ .pushsection .rodata.str, "aMS", @progbits, 1; \ 10002: .string file; \ .popsection; \ \ .long 10002b - .; \ + __BUG_FUNC_PTR(func) \ .short line; -#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) +#define _BUGVERBOSE_LOCATION(file, func, line) __BUGVERBOSE_LOCATION(file, func, line) #endif #ifndef CONFIG_GENERIC_BUG -#define __BUG_ENTRY(flags) +#define __BUG_ENTRY(flags, func) #else -#define __BUG_ENTRY(flags) \ +#define __BUG_ENTRY(flags, func) \ .pushsection __bug_table, "aw"; \ .align 2; \ 10000: .long 10001f - .; \ - _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ + _BUGVERBOSE_LOCATION(__FILE__, func, __LINE__) \ .short flags; \ .popsection; \ 10001: #endif -#define ASM_BUG_FLAGS(flags) \ - __BUG_ENTRY(flags) \ +#define ASM_BUG_FLAGS(flags, func) \ + __BUG_ENTRY(flags, func) \ break BRK_BUG -#define ASM_BUG() ASM_BUG_FLAGS(0) +#define ASM_BUG() ASM_BUG_FLAGS(0, .) + +#ifdef HAVE_BUG_FUNCTION +# define __BUG_FUNC __func__ +#else +# define __BUG_FUNC NULL +#endif #define __BUG_FLAGS(flags) \ - asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))); + asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags, %0)) : : "i" (__BUG_FUNC)); #define __WARN_FLAGS(flags) \ do { \ instrumentation_begin(); \ - __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ + if (!IS_SUPPRESSED_WARNING(__func__)) \ + __BUG_FLAGS(BUGFLAG_WARNING|(flags)); \ instrumentation_end(); \ } while (0) -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-03-05 18:40 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-05 18:40 [RFC PATCH 0/5] Add support for suppressing warning backtraces Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck 2024-03-05 18:40 ` [RFC PATCH 1/5] bug: Core " Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck 2024-03-05 19:54 ` Kees Cook 2024-03-05 19:54 ` Kees Cook 2024-03-05 20:17 ` Guenter Roeck 2024-03-05 20:17 ` Guenter Roeck 2024-03-05 18:40 ` [RFC PATCH 2/5] drm: Suppress intentional warning backtraces in scaling unit tests Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck 2024-03-05 18:40 ` [RFC PATCH 3/5] x86: Add support for suppressing warning tracebacks Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck 2024-03-05 18:40 ` [RFC PATCH 4/5] arm64: " Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck 2024-03-05 18:40 ` Guenter Roeck [this message] 2024-03-05 18:40 ` [RFC PATCH 5/5] loongarch: " Guenter Roeck 2024-03-06 18:24 ` [RFC PATCH 0/5] Add support for suppressing warning backtraces Daniel Díaz 2024-03-06 18:24 ` Daniel Díaz 2024-03-06 18:57 ` Guenter Roeck 2024-03-06 18:57 ` Guenter Roeck 2024-03-11 4:36 ` Guenter Roeck 2024-03-11 4:36 ` Guenter Roeck
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=20240305184033.425294-6-linux@roeck-us.net \ --to=linux@roeck-us.net \ --cc=airlied@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=arnd@arndb.de \ --cc=arthurgrillo@riseup.net \ --cc=brendan.higgins@linux.dev \ --cc=dan.carpenter@linaro.org \ --cc=daniel.diaz@linaro.org \ --cc=daniel@ffwll.ch \ --cc=davidgow@google.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=keescook@chromium.org \ --cc=kunit-dev@googlegroups.com \ --cc=linux-arch@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=loongarch@lists.linux.dev \ --cc=maarten.lankhorst@linux.intel.com \ --cc=mcanal@igalia.com \ --cc=mripard@kernel.org \ --cc=naresh.kamboju@linaro.org \ --cc=tzimmermann@suse.de \ --cc=ville.syrjala@linux.intel.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.