From patchwork Tue Mar 5 18:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13582860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E6C5C54798 for ; Tue, 5 Mar 2024 18:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=59Odg7lJsQNazyxG1wgAoof24wnfYCbuZUVaBkXb5qg=; b=sB1NBG4tPPaPt8 dzvYiigqYNxMr2h70iCsFteSqNwtUDgjPF1D8TLxKY52ILtJaXkGyJ0FQp6Uqz7C1yyY4kSM6dkvi TbCXzPXNk2kXS4g/0giSGAhnK9DbbJT0Fp4dsrEYxyDXb6JWp2mP67CB6K/2qfjj36JMJDOccMBM+ 83F8HtkhL3edoCJF5CzOZaTKv7s71OP/kFRNroVlvOJA5HkfCKYC+hLMOztc0WsbbB+ljVrNIX8ax UT/KKTn+1a+WB9MM3ErbuDxvxvWBPUP/YmZVNCu2mFX/j+/O/LdZEipemxBQXssp6O0mQGnhjupdh P9TWK3tJk3+QD/9yiLZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZiX-0000000EtC4-2Z0n; Tue, 05 Mar 2024 18:40:45 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhZiU-0000000EtA8-3bBI for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 18:40:44 +0000 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-36576b35951so4727385ab.3 for ; Tue, 05 Mar 2024 10:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709664040; x=1710268840; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=YQLzgqGcJCQTSOmHQSBuR9Qy4cscbXhB7FIpF8lqDFg=; b=guMA3zWOXNO+j5OPeHrsczOHSAQnhuXKhhSzVsE3pVvjvDTPAPLCi3cRJY4FkPvoa4 oa+Hv/1XWolBbcv/1p6CA0NkR6i5cUvH/8x6UEc8T8W0lYRhPrEMWwXmPnqk3AWzkBkE NqepIvrK0j2y1d2YwO4P+o3jb0PjyQUN3h20CJ5HlFu11f/7CrIsxwBwN6JqqrP/JKbp 8A7fSWJFnkYdNhxr54F7GSFICJW4jYGGpRBvLrmQuyvzg63B8a6CNv8kCvmeZeFM4n9e sTc3DhCstNckBX94LqeoMjRWsFlaR2nrx/wW/1mJ4TKsLMHm/7fT/bPbSEAomhM3Ajtz 6eDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664040; x=1710268840; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YQLzgqGcJCQTSOmHQSBuR9Qy4cscbXhB7FIpF8lqDFg=; b=W3bFkwD+HKudSZI5eZg1V5eCV76dMtBbJKDkc7gaogMYGRmeb//Ve9PGGkHTte5rYM f5I/dpdOPqAaBDwdfhcSJ/A0S4+c2O0QNQEQRRZ8YOHOY/TYQtUTa95VJVBZFCT2H74d roGFg5bzfuUxWGc1aLlQKzwInzpD7cE6osKNplLCmztAabJv2mKcrLt0kkmsS+2PSKnL b5KjYBRRVRbkCWM5gqFxMmMguU38omcbWPAiojkZVd1XtMhfXm3SYw61WXtp8KzAP4qy +k8eQ4ZmwSvX3vZBPV7/26LSEfaORuRvl1gS7WfA0Lba7t/myTsj66Rp0ljpjH7lvQAJ L3ug== X-Forwarded-Encrypted: i=1; AJvYcCVOsUfIuo58kbjom8heXFJldfMyd/nDX/oOcevm0ztf4XuG/rAKd9zC3HGOR5cqVTn024cPb1IOqjkwYpNX6ngK6JFroZjEZZ4/le3+mNhgq7H0WLQ= X-Gm-Message-State: AOJu0YwoLu22jj1Q5n1/TazSBGhFZduax5At8n46aymNKUZf5+HadNxn 3CI33uJF7UQvlzbiGdWNtpXuICm8HkgQXE+V6SE4R3424mK3mmcI X-Google-Smtp-Source: AGHT+IHLOs8AkdboH9ufe3uVfCMuBj2myZQffsOSLGEYtVubGujAxHdd/KSSUYo1ed4iTaJle6dOCA== X-Received: by 2002:a05:6e02:1564:b0:366:140:801 with SMTP id k4-20020a056e02156400b0036601400801mr1621302ilu.20.1709664040035; Tue, 05 Mar 2024 10:40:40 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f17-20020a63e311000000b005dc4da2121fsm9444697pgh.6.2024.03.05.10.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:40:38 -0800 (PST) From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?utf-8?q?Ma=C3=ADra_Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , Thomas Zimmermann , 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 Subject: [RFC PATCH 0/5] Add support for suppressing warning backtraces Date: Tue, 5 Mar 2024 10:40:28 -0800 Message-Id: <20240305184033.425294-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_104042_925711_C3D72C33 X-CRM114-Status: GOOD ( 22.92 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some unit tests intentionally trigger warning backtraces by passing bad parameters to kernel API functions. Such unit tests typically check the return value from such calls, not the existence of the warning backtrace. Such intentionally generated warning backtraces are neither desirable nor useful for a number of reasons. - They can result in overlooked real problems. - A warning that suddenly starts to show up in unit tests needs to be investigated and has to be marked to be ignored, for example by adjusting filter scripts. Such filters are ad-hoc because there is no real standard format for warnings. On top of that, such filter scripts would require constant maintenance. One option to address problem would be to add messages such as "expected warning backtraces start / end here" to the kernel log. However, that would again require filter scripts, it might result in missing real problematic warning backtraces triggered while the test is running, and the irrelevant backtrace(s) would still clog the kernel log. Solve the problem by providing a means to identify and suppress specific warning backtraces while executing test code. Support suppressing multiple backtraces while at the same time limiting changes to generic code to the absolute minimum. Architecture specific changes are kept at minimum by retaining function names only if both CONFIG_DEBUG_BUGVERBOSE and CONFIG_KUNIT are enabled. The first patch of the series introduces the necessary infrastructure. The second patch marks the warning message in drm_calc_scale() in the DRM subsystem as intentional where warranted. This patch is intended to serve as an example for the use of the functionality introduced with this series. The last three patches in the series introduce the necessary architecture specific changes for x86, arm64, and loongarch. This series is based on the RFC patch and subsequent discussion at https://patchwork.kernel.org/project/linux-kselftest/patch/02546e59-1afe-4b08-ba81-d94f3b691c9a@moroto.mountain/ and offers a more comprehensive solution of the problem discussed there. Checkpatch note: Remaining checkpatch errors and warnings were deliberately ignored. Some are triggered by matching coding style or by comments interpreted as code, others by assembler macros which are disliked by checkpatch. Suggestions for improvements are welcome. Some questions: - Is the general approach promising ? If not, are there other possible solutions ? - Function pointers are only added to the __bug_table section if both CONFIG_KUNIT and CONFIG_DEBUG_BUGVERBOSE are enabled. This avoids image size increases if CONFIG_KUNIT=n. Downside is slightly more complex architecture specific assembler code. If function pointers were always added to the __bug_table section, vmlinux image size would increase by approximately 0.6-0.7%. Is the increased complexity in assembler code worth the reduced image size ? I think so, but I would like to hear other opinions. - There are additional possibilities associated with storing the bug function name in the __bug_table section. It could be independent of KUNIT, it could be a configuration flag, and/or it could be used to display the name of the offending function in BUG/WARN messages. Is any of those of interest ? ---------------------------------------------------------------- Guenter Roeck (5): bug: Core support for suppressing warning backtraces drm: Suppress intentional warning backtraces in scaling unit tests x86: Add support for suppressing warning tracebacks arm64: Add support for suppressing warning tracebacks loongarch: Add support for suppressing warning tracebacks arch/arm64/include/asm/asm-bug.h | 29 +++++++++++++------- arch/arm64/include/asm/bug.h | 8 +++++- arch/loongarch/include/asm/bug.h | 38 ++++++++++++++++++-------- arch/x86/include/asm/bug.h | 21 +++++++++++---- drivers/gpu/drm/tests/drm_rect_test.c | 6 +++++ include/asm-generic/bug.h | 16 ++++++++--- include/kunit/bug.h | 51 +++++++++++++++++++++++++++++++++++ include/linux/bug.h | 13 +++++++++ lib/bug.c | 51 ++++++++++++++++++++++++++++++++--- lib/kunit/Makefile | 6 +++-- lib/kunit/bug.c | 40 +++++++++++++++++++++++++++ 11 files changed, 243 insertions(+), 36 deletions(-) create mode 100644 include/kunit/bug.h create mode 100644 lib/kunit/bug.c