Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1213651pxa; Thu, 13 Aug 2020 03:37:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbLPvsuO1MeNKWm8AH3E7LRBWsqy7lpa+BeLjZKq6j9f3n0aMXOA2WxcjYYMoTKsY+Mw8b X-Received: by 2002:a17:906:3c43:: with SMTP id i3mr4230293ejg.133.1597315038952; Thu, 13 Aug 2020 03:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597315038; cv=none; d=google.com; s=arc-20160816; b=V8nVgTBXv987NlxXc8kIXWBcCNRhKh/scClsK4Nt9wZECie/fqx+mlHxH8J2MEhqif 2aAG69WwtnjGYHmTjI1cdvn5nvh7bgu+vNd+u3g25A7fCTOptE47Yd6nsxu5Kh2aDtvt /ZgwIU1DFfIFZFEQWuY6jgnAn4S/yjoPEkVNn4MDKakgFo2Hx2S16R7OtSV5uV8ncMBJ vWQluPnHtlJgioxhUEDZDkFPepQ5lUUhvrVB067w2ZdxoQzlhUPO2wDo1hCbK3ZJnSlB TFPruj8Uo1RfBd8F+WkvXXLViBN/vSeq2/x0DDPfx9fAmLDMp59uE7yEOyOp6pYjJlaj AUwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9hnbVDwhrL8TE76gwR/KK7IaS55JjZNnoo+tIvGIEU0=; b=DpVye7RJWlHqKKRyuU5TdjI+yIF2kYeedTFkWDmoAxB84bMAa9ku5IxDBSieXc3eA5 Im0w6ihNHYRag8YzZpeHDRmCcvmybwD7X/oKkCAj11EKCuD83CiMgz3NcXI5LBdH98ng 5p7AXo5QbXowp+hOiREzMqJjeMo8H9UL6rDS3WeZmzZCeAs/0fOWmsZaHboY68OGEZh9 g7O3fLFCEj9cRuucwotTYyTF58F9OOUzXA6PMwkJ2Kei2PFulxZEzJ+dcHTczV+Iz2+o 9zAlDn7gSJszsLiN/g41WLAyWxabEJEpITgr+4Z+U5HQ9K72RqzBGW6O22YedUxgFS+J 12Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=iVUntBDc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q2si3137318edj.526.2020.08.13.03.36.54; Thu, 13 Aug 2020 03:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=iVUntBDc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgHMKgY (ORCPT + 99 others); Thu, 13 Aug 2020 06:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgHMKgY (ORCPT ); Thu, 13 Aug 2020 06:36:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C670C061757; Thu, 13 Aug 2020 03:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9hnbVDwhrL8TE76gwR/KK7IaS55JjZNnoo+tIvGIEU0=; b=iVUntBDcQRBcXmCxiAuZxmiaCO fMcOPwDOVL2SBc93pNJSxLMHLWma1GFmTjcW2w4c0jezZrp57rlDytNxiQ6cIc8zzH77hvI0zSj7T 4wU24ELLmQ7/gXUm6C0FwP08SvK0qlPgwetTYFomhwYv0KvgT0eqaH5J+T8lE7ZbT185Rq3dAm2Qa z2Zs++d0zdYjPJ+ZdVrN2Dlo1l8nOjHHi8cC6hncvLTSnrn1xKHLsyuTaR964sgSIbF5T2TJjxFkK 6A+gITKwEoH4VbOR3QsDSUFze9MVTbAFzyHX67d2Cdf6mDiJ2A0/4NBP/DpeYkOGDN49wxEkn+kRJ OxFXHUNw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6Aan-00078D-57; Thu, 13 Aug 2020 10:36:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1D9F6300238; Thu, 13 Aug 2020 12:36:16 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 05CC62C217FD8; Thu, 13 Aug 2020 12:36:16 +0200 (CEST) Date: Thu, 13 Aug 2020 12:36:15 +0200 From: peterz@infradead.org To: Uriel Guajardo Cc: brendanhiggins@google.com, mingo@redhat.com, will@kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, urielguajardo@google.com Subject: Re: [PATCH v2] kunit: added lockdep support Message-ID: <20200813103615.GT2674@hirez.programming.kicks-ass.net> References: <20200812193332.954395-1-urielguajardojr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812193332.954395-1-urielguajardojr@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 12, 2020 at 07:33:32PM +0000, Uriel Guajardo wrote: > KUnit will fail tests upon observing a lockdep failure. Because lockdep > turns itself off after its first failure, only fail the first test and > warn users to not expect any future failures from lockdep. > > Similar to lib/locking-selftest [1], we check if the status of > debug_locks has changed after the execution of a test case. However, we > do not reset lockdep afterwards. > > Like the locking selftests, we also fix possible preemption count > corruption from lock bugs. > +static void kunit_check_locking_bugs(struct kunit *test, > + unsigned long saved_preempt_count, > + bool saved_debug_locks) > +{ > + preempt_count_set(saved_preempt_count); > +#ifdef CONFIG_TRACE_IRQFLAGS > + if (softirq_count()) > + current->softirqs_enabled = 0; > + else > + current->softirqs_enabled = 1; > +#endif Urgh, don't silently change these... if they're off that's a hard fail. if (DEBUG_LOCKS_WARN_ON(preempt_count() != saved_preempt_count)) preempt_count_set(saved_preempt_count); And by using DEBUG_LOCKS_WARN_ON() it will kill IRQ tracing and trigger the below fail. > + if (saved_debug_locks && !debug_locks) { > + kunit_set_failure(test); > + kunit_warn(test, "Dynamic analysis tool failure from LOCKDEP."); > + kunit_warn(test, "Further tests will have LOCKDEP disabled."); > + } > +}