Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2863617lqp; Mon, 25 Mar 2024 11:20:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWX4ihsmtpsdAaGO2/VnGW8KOY81j2hcEIBlEDIpmdAi4jusz4teM+2XIpeAf5RKXuq5g29K+jqj2Nn+f5xDnTGRpRkHfkGSuEcbM2lw== X-Google-Smtp-Source: AGHT+IEV6TjQZPRy4Y34nIAPkl2kT/ERmUAUgEDAwx2gYKjv4mVt1iIX/t2E+PvUZuDtj9sJVG5/ X-Received: by 2002:a17:906:b84e:b0:a47:34d8:e052 with SMTP id ga14-20020a170906b84e00b00a4734d8e052mr366110ejb.36.1711390839535; Mon, 25 Mar 2024 11:20:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711390839; cv=pass; d=google.com; s=arc-20160816; b=nnUlhqxVvIcvcjEgpc3WYZ+u3gVYlqEwI0b7UHht85aCdAOM1mi7YdS7sOQmsWYlU5 WNsb/WLjmiH8sMO4N641NMOL9xxDa/c2QxB8mQwd9WZUa4RoJoZt9+4HfTrl3RZa7eqH hoxJkgGFiBOndb5aBIF5WyO69PVc4NI22UL/2NttGOM72DJgadgPbg5OL0JgAKVoEvIk y4UEWywSGLju0wVdyBnvAGqXAlITraPxvzunfOkK79kqiUaay9686sxsGz8KLxmDDVvF Ye2yxHVW0Xdv+yHbhbNGyaTmbhQO+oi3UtaQvQ8W9pB2C7CIoJx7bqAX0alxEGaUrf1k R6Kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:sender:dkim-signature; bh=XNSADZIa55EnhS6o0yIL3ifpTu+GjUejKXDxEmLThHE=; fh=cXYQrsP5WLCIpMv2hq6tsAJn2LDvNSr0psENDG8q8oo=; b=KFe2TiU/IlYW3XqKfVDLasa4aE2DGPnpNHKdk0AcYD8z79WlKkBL+sCrgOwZUB9k03 TGB1FRwnCqSKd8LaQyURgmpyGwSNRCkTJrlIbP7atrboolkif9skk7xc/7B5aTmUSoSQ /3/Ioo6nqaFbFyNRC+h3+yodtgif4yN9zMz/0CT+mcEYkJ4kwI8U/JXliHoKUjtdI2JF vymBe1aY4ba1Uotas21MRJMtEOpd+KPP3BPFTSSwNtrwRgYB/ZdT2/JFbSYC7zI0v21c KsGswKqPyPLyQoK8jX/dHpnGWvWS2t3NFDIrOZguqlAlBIQ3yRU4/y2hl1XGcknhvqIK tgBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SMLdE8Nh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117642-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qk18-20020a1709077f9200b00a474c8c588fsi1983219ejc.92.2024.03.25.11.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SMLdE8Nh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117642-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3D3EF1FA2DF8 for ; Mon, 25 Mar 2024 18:20:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C61548286F; Mon, 25 Mar 2024 17:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SMLdE8Nh" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC7757316D; Mon, 25 Mar 2024 17:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389178; cv=none; b=fiSbPfuHu7mnkKKibi5PSwc/4EW69FBMuYNGLdsffM7KPxdy90OL89dPua4Eho/JpHntM1D8rPF0xm41L4BU9ZfDCkWODwzWH9ynfmx7XZYLYaLx0gtokmxkvYwUagtyGHeI8xHaYkRXkkVJEBNgjfM+GYNuvFIFGXAEfH4rxtg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389178; c=relaxed/simple; bh=VOccJ8b4F3FXwu0VomVq1foVe5FqXJomPjb+iB5b73s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fp72Ylo/oPBGRwhBW3phHW6IPEtCDuwdk+agY3d8XmlhCi6O3kF/FXmT7JR+4wBguarCo/60xR1IQzKRyWcHTX2t6w07RQeuJJKU6Umj7udhXuk221xmtx+Qwn3fijiNceQ3O3Ao7pbMbEkD6D0/RY4r5nijF26ihc3IH2itqww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SMLdE8Nh; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e6ee9e3cffso3160916b3a.1; Mon, 25 Mar 2024 10:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711389175; x=1711993975; darn=vger.kernel.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=XNSADZIa55EnhS6o0yIL3ifpTu+GjUejKXDxEmLThHE=; b=SMLdE8NhIvS+23/6Ri6e6rdzSwgwu2ycsoDk5lDGQRGURaJu5cYQcP+2EjwCRUYeb2 wGweWJsxo2A9fKbb+6RpI1gm2i9Ll1wBBJcQX4hoMQPjhnVs6eQHch5uLbT6NRkeULNy W6OGx2oPSewur/f4TvTbmNCaDD+o/gAicBhvAAv+8U099zp7a77vs3myPhDJv3Ehcgg5 a8W6MpxsloS67xWWk0rVDI4tFwRdjooGIEuNvBmdY+hFWLc+sEW0f7Jih7WBDtJaP56v bmzB6PQ2cTPF1MmXnyTng3FOarpsbRUCagneumu5wE8OpaAt417pJf7kSYHcf5MM/xdm YZ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711389175; x=1711993975; 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=XNSADZIa55EnhS6o0yIL3ifpTu+GjUejKXDxEmLThHE=; b=pTOmskKrO1h0mgcGLJvQt8/IHGLF3LSeMLJWMMmD9Wc6ZuE46w3NpB+GEDctLWwLj9 Wl3I0jJ5A7aEBPjkYXyLQgbn/dfmhm6Q+VJBjanYdRPG9uUAzfiI3t4V4TC68YvNW/os 0+aCVKZ5U1LuUocaQGBJoNEdjmnQcO1a3JdG804tXRP9Tw++S1SoWvb2+J1P0+OTdhwi NlOlTl5E5p/WrWnzTty1SYnPc9//MumF31MlKUMPo3ZZBeBUYoLqkHuTNjhAP4bn5IMs z9FSx2Vb/vPKFiG0zpIi1Jpq2AVOXF48JpWfG8GGCJEQkLgjoBF8plEQCOoxdd1nZEnt Ny8A== X-Forwarded-Encrypted: i=1; AJvYcCUKJUIL4B6OFUGp438YAZhGqW3a8Ccq+nTu+Z0rkTNkdoZB7XxNXgCexfTqVursAWlfZpYzdJp4DFmEtmZfN2YDKZ9VCaGSR11DCKq0lpwQE7xgguIoWJM123rQQEpgUO3uR+cmrRXccF5kDCfRKyWH/jcTOKWZ93/MBOP1bhe1gzJA4wQnaVZJ6UxVLu+y6p2BGm8OV5w1uMQmDkvwfkZ64IA9M9Lt7kzBZS+X812WUoNNSHpthZACLZp9+kKNGL1TigbCcu4sXdRZaMKrIvins0bLmL+RqsHfiGEA/vJQAauoIsLbhZbbPmQh7z+oug== X-Gm-Message-State: AOJu0Yx+1f1tqoAf2v28Y3okPnVCpeNchqGfAGpD/pRkukccziO7HuLf 6hCfIewTZnvBH8lvsAk1HqNdcYZ+C6FElfKb+qCpvhDUXiSbvmsxblKSciuu X-Received: by 2002:a05:6a20:6a0e:b0:1a3:c4ba:a453 with SMTP id p14-20020a056a206a0e00b001a3c4baa453mr6509702pzk.7.1711389175417; Mon, 25 Mar 2024 10:52:55 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id dr18-20020a056a020fd200b005cd835182c5sm5239787pgb.79.2024.03.25.10.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:52:53 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-kselftest@vger.kernel.org Cc: David Airlie , Arnd Bergmann , =?UTF-8?q?Ma=C3=ADra=20Canal?= , Dan Carpenter , Kees Cook , Daniel Diaz , David Gow , Arthur Grillo , Brendan Higgins , Naresh Kamboju , Maarten Lankhorst , Andrew Morton , Maxime Ripard , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Daniel Vetter , Thomas Zimmermann , dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, Guenter Roeck Subject: [PATCH v2 00/14] Add support for suppressing warning backtraces Date: Mon, 25 Mar 2024 10:52:34 -0700 Message-Id: <20240325175248.1499046-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 introduces support for counting suppressed backtraces. This capability is used in patch three to implement unit tests. Patch four documents the new API. The next two patches add support for suppressing backtraces in drm_rect and dev_addr_lists unit tests. These patches are intended to serve as examples for the use of the functionality introduced with this series. The remaining patches implement the necessary changes for all architectures with GENERIC_BUG support. With CONFIG_KUNIT enabled, image size increase with this series applied is approximately 1%. The image size increase (and with it the functionality introduced by this series) can be avoided by disabling CONFIG_KUNIT_SUPPRESS_BACKTRACE. 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. Design note: Function pointers are only added to the __bug_table section if both CONFIG_KUNIT_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled to avoid image size increases if CONFIG_KUNIT is disabled. There would be some benefits to adding those pointers all the time (reduced complexity, ability to display function names in BUG/WARNING messages). That change, if desired, can be made later. 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. Changes since RFC: - Introduced CONFIG_KUNIT_SUPPRESS_BACKTRACE - Minor cleanups and bug fixes - Added support for all affected architectures - Added support for counting suppressed warnings - Added unit tests using those counters - Added patch to suppress warning backtraces in dev_addr_lists tests Changes since v1: - Rebased to v6.9-rc1 - Added Tested-by:, Acked-by:, and Reviewed-by: tags [I retained those tags since there have been no functional changes] - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option, enabled by default.