Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2668371pxa; Mon, 17 Aug 2020 16:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJVNxofn/tSQHIR2/J89xBQ535euyMdjc0GvuUPEc/iRA678rAcYANNMLej45Rj06Yk0V9 X-Received: by 2002:a50:e803:: with SMTP id e3mr16633948edn.75.1597705486914; Mon, 17 Aug 2020 16:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597705486; cv=none; d=google.com; s=arc-20160816; b=iOBJciB5B+y+2wOYbXnBWle/2v/utv68EBafWVrQSF+wrCRBpbd63af9KcXpAinaqy sftW3uIQ/4NjyfMJrhpi5WiNGQj7wZbs/p45ibuLLEX38xIYaQnE4m48SMRrtdwcJ52k bag4yrZisnaijIIg01kmu713j03PtTNvmrv1DaZi0twoqOJt0OIhFHS6kdD3T2827TAx WIzUTFgsP7W1kK29w2qEOtswzu41B8FgZRLwfwA7lBAQRjlBoRiRqYdJf5p/jMdESjY+ PqFN3FtXBsA8uIxlyeg5wF6LozBc0SDjOfyhb95p2pGFjGRoMotic5VoYmZ1q6SCfnCu rssg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=li7/F1QxAHMT3HlXtBKHPKuGkDNlHShRldK1/b2ptEE=; b=Pp9bZ4KfMvX26K776F/7n0gnT77wRSIvXnJuRAt3NV5l3wOSgu2jShiQHaxMLHjoIF HRgcQ3Ub54hxZjcIZ7n25VDEJ1GI5bV4R8ehNKfZHBBgeXSCcxrUMKz4/vvn6IjACLYp cQw+2DQAXCXksbZKmeCLiTBO5aqmzwdZUxZzq6E/QjiPtRheoyhIcaQToybLpMbMHrz1 rSywL5arBPNJELgRlYz6MFVilP3Ubc2pQbSYB8swSEawMjtHWI1vti6TwqLg3IXL9bU8 ClMQ73ixbGkVKP8ETE1izP6EiJo5+QaZ8sUTyD49T+/cKTRZNcpk4rBJv8PCsVfCrWTy cAmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p1WuDpCo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si12157216ejq.390.2020.08.17.16.04.23; Mon, 17 Aug 2020 16:04:46 -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=pass header.i=@google.com header.s=20161025 header.b=p1WuDpCo; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgHQVBU (ORCPT + 99 others); Mon, 17 Aug 2020 17:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726804AbgHQVBM (ORCPT ); Mon, 17 Aug 2020 17:01:12 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D665CC061343 for ; Mon, 17 Aug 2020 14:01:11 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id a65so14533522otc.8 for ; Mon, 17 Aug 2020 14:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=li7/F1QxAHMT3HlXtBKHPKuGkDNlHShRldK1/b2ptEE=; b=p1WuDpCoxMkf/1Src7GUIJVwp95M+yStBX9RyIIDTXVnnhPXquUBytkGYr7U5k192s Sa/fAAj3vZNZUzntUuHugq4fjEYYBGO1Xbphqfs2WSqzrQrB20TqrV6ulWrPMBvc1h5S eacUQLpPVURfdKEGOa3mIwNneS0bOHJsbejOA1D6h/HQt63O2AreYeCnxztJPYV2n4cd vb7zqR8mvZagwYWzK4NrbSVqi/06Unl4fx+2GuFZ58kWjz+1RBmyYGKVIQmA+Av3hUQS DifBysU4gdtYAjFaDSIxuCcUsZ/yAUT54lnhHy5efkSEsVu1LG30YZeCRoiLBGJM8HGt lGZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=li7/F1QxAHMT3HlXtBKHPKuGkDNlHShRldK1/b2ptEE=; b=aL5OROWxYYLrGG99LoTyS2yHeKR7V6X3v+mKzlKL3WIctFY2NVQR4KRLVzd4F9iIYh TBdR2nA8WWKDVLRs7tujI8IgDrlUgIGZwkjLBPkDkFI8h6G+olXFhXUFdzMHjx1tnS9j KHdxv66k6W5uomn/lbwTEFkguC++BZgq/qDNd64s7cdJN0EvdTURF7Iu+CFZqM5oMQG0 bB25HupQq/UU1/tnvoue+F8PjaytXF0qMEFgbpI2+ASP6n1qNvvZKDleqoOa0Q7nMWjy vp0AdEHKP48Jn5PgKDPstnzz1P2sd0Y/KF5NmP7vmMy1y75TzQFidBCezJIfGqonXmkr qP/Q== X-Gm-Message-State: AOAM5323fxdPMyEBThqN1RKkUHiGmJiE8fTqQhiWYa8XyN3VNVsYdH0E AAPSI1aqTg0mzTzZ/Nu7foJei15svu/9yJxr3HZ34Q== X-Received: by 2002:a05:6830:614:: with SMTP id w20mr13272524oti.283.1597698069848; Mon, 17 Aug 2020 14:01:09 -0700 (PDT) MIME-Version: 1.0 References: <20200814205527.1833459-1-urielguajardojr@gmail.com> <20200815083029.GA2430016@gmail.com> <20200815084443.GO3982@worktop.programming.kicks-ass.net> <20200815091721.GC2444151@gmail.com> In-Reply-To: <20200815091721.GC2444151@gmail.com> From: Uriel Guajardo Date: Mon, 17 Aug 2020 16:00:59 -0500 Message-ID: Subject: Re: [PATCH v3] kunit: added lockdep support To: Ingo Molnar Cc: Peter Zijlstra , Uriel Guajardo , Brendan Higgins , mingo@redhat.com, will@kernel.org, Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Alan Maguire Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 15, 2020 at 4:17 AM Ingo Molnar wrote: > > > * Peter Zijlstra wrote: > > > On Sat, Aug 15, 2020 at 10:30:29AM +0200, Ingo Molnar wrote: > > > > > > * Uriel Guajardo wrote: > > > > > > > From: Uriel Guajardo > > > > > > > > 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. > > > > > > > --- a/lib/kunit/Makefile > > > > +++ b/lib/kunit/Makefile > > > > > > > +void kunit_check_lockdep(struct kunit *test, struct kunit_lockdep *lockdep) { > > > > + int saved_preempt_count = lockdep->preempt_count; > > > > + bool saved_debug_locks = lockdep->debug_locks; > > > > + > > > > + if (DEBUG_LOCKS_WARN_ON(preempt_count() != saved_preempt_count)) > > > > + preempt_count_set(saved_preempt_count); > > > > + > > > > +#ifdef CONFIG_TRACE_IRQFLAGS > > > > + if (softirq_count()) > > > > + current->softirqs_enabled = 0; > > > > + else > > > > + current->softirqs_enabled = 1; > > > > +#endif > > > > + > > > > + 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."); > > > > + } > > > > > > > > > So this basically duplicates what the boot-time locking self-tests do, > > > in a poor fashion? > > > > No, it makes sure that any kunit based self-test fails when it messes up > > it's locking. > > We have a flag for whether lockdep is running though, so is this > basically a very complicated way to parse /proc/lockdep_debug? :-) > I may be missing something here, but what would be the advantage of using another flag or using other means to find lockdep's status? This patch is basically checking if debug_locks has changed after a KUnit test case has executed. It's not sufficient to only check if debug_locks is off, since it could have already been off many test cases ago. I imagine the only difference would be replacing "debug_locks" with another flag or code checking lockdep's status, and I don't see that as being any less complicated.