Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp41276pxx; Wed, 28 Oct 2020 17:32:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMiGu6sJti936xtwpC+ksp8BGlcFDMUTXD5TUC7Qyynq4f2U/xY/io9koQVgjh/soQxBz1 X-Received: by 2002:a17:906:31c1:: with SMTP id f1mr1701472ejf.253.1603931559476; Wed, 28 Oct 2020 17:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603931559; cv=none; d=google.com; s=arc-20160816; b=Et7F2rhSQd7PDtjZmqEzVffYXJJnZFn/UVfBUiFWlkss55VVJBXC3woeh8cixubYc6 y19S/CXLtpUL0Qroc68S7SWAIoLypNAO5KnsNwCB+tR+SaxY0DBlmVKa0tU2wSkQJWh5 4pcR2cBj8G2YuKicKs4izlp/AI4IPGrXp8G3t6GHGhB4wdbpl0e462PjW9s2qpquB7S4 laVqGWWu0cDWAcmagqroR3mrYvoiNj3zq3Ni7KSneYNoCiDbutrttpez6KaI5KcEsOqS pVuasnEI+5Zr5iTyhR7PLsWMPr1/Ig9ClggSPp0v9afbmlqI0ysTtwYG/Wprud61Z/nF uvyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version; bh=CP2yvU6FFiU/+TtzlPLL9aJdHUjhilLLa3hdN/n5NBw=; b=TBOQkXnmFy+pvmtbhL0hJM3ogW9+u7+bULOpK4SYUy/3CCs+HMOiD5vmDCIRLdNPyc h9DG0av/kE4YYWzwSViSyXSC5RiTSJKquCJchLhDBYVfZiRVxHbsD9ItT1SA8T7Bw9MU 43m0t0gm8ckUDQ0h0MtwNL4iKqrrU0ADgCTy+KnC8Ao1M2ZRNIx4/wJ2qEaAlpFzsdtb pv+GMYTwh9s9O6shzeoUlEFv2F9B1a7Hx13Lhw6Dz9sRmucU/aqj9jUIT37mN4i7viqN QzVTcaWHeu/GGfbM1uyk9Ao/KdfszVvhQPWVfXXLrRW+MJWxX9uKPk9DLyHWj+6lUpLI 47Sw== ARC-Authentication-Results: i=1; mx.google.com; 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 gb8si620152ejc.394.2020.10.28.17.32.17; Wed, 28 Oct 2020 17:32:39 -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; 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 S1729174AbgJ1V6a convert rfc822-to-8bit (ORCPT + 99 others); Wed, 28 Oct 2020 17:58:30 -0400 Received: from mail.fireflyinternet.com ([77.68.26.236]:55860 "EHLO fireflyinternet.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728786AbgJ1V62 (ORCPT ); Wed, 28 Oct 2020 17:58:28 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 22827296-1500050 for multiple; Wed, 28 Oct 2020 17:40:51 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT In-Reply-To: <160381649396.10461.15013696719989662769@build.alporthouse.com> References: <20200930094937.GE2651@hirez.programming.kicks-ass.net> <160208761332.7002.17400661713288945222.tip-bot2@tip-bot2> <160379817513.29534.880306651053124370@build.alporthouse.com> <20201027115955.GA2611@hirez.programming.kicks-ass.net> <20201027123056.GE2651@hirez.programming.kicks-ass.net> <160380535006.10461.1259632375207276085@build.alporthouse.com> <20201027154533.GB2611@hirez.programming.kicks-ass.net> <160381649396.10461.15013696719989662769@build.alporthouse.com> Subject: Re: [tip: locking/core] lockdep: Fix usage_traceoverflow From: Chris Wilson Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org, tip-bot2 for Peter Zijlstra , Qian Cai , x86 To: Peter Zijlstra Date: Wed, 28 Oct 2020 17:40:48 +0000 Message-ID: <160390684819.31966.12048967113267928793@build.alporthouse.com> User-Agent: alot/0.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Chris Wilson (2020-10-27 16:34:53) > Quoting Peter Zijlstra (2020-10-27 15:45:33) > > On Tue, Oct 27, 2020 at 01:29:10PM +0000, Chris Wilson wrote: > > > > > <4> [304.908891] hm#2, depth: 6 [6], 3425cfea6ff31f7f != 547d92e9ec2ab9af > > > <4> [304.908897] WARNING: CPU: 0 PID: 5658 at kernel/locking/lockdep.c:3679 check_chain_key+0x1a4/0x1f0 > > > > Urgh, I don't think I've _ever_ seen that warning trigger. > > > > The comments that go with it suggest memory corruption is the most > > likely trigger of it. Is it easy to trigger? > > For the automated CI, yes, the few machines that run that particular HW > test seem to hit it regularly. I have not yet reproduced it for myself. > I thought it looked like something kasan would provide some insight for > and we should get a kasan run through CI over the w/e. I suspect we've > feed in some garbage and called it a lock. I tracked it down to a second invocation of lock_acquire_shared_recursive() intermingled with some other regular mutexes (in this case ww_mutex). We hit this path in validate_chain(): /* * Mark recursive read, as we jump over it when * building dependencies (just like we jump over * trylock entries): */ if (ret == 2) hlock->read = 2; and that is modifying hlock_id() and so the chain-key, after it has already been computed. diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 035f81b1cc87..f193f756e1e3 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -4831,7 +4831,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (!validate_chain(curr, hlock, chain_head, chain_key)) return 0; - curr->curr_chain_key = chain_key; + curr->curr_chain_key = iterate_chain_key(chain_key, hlock_id(hlock)); curr->lockdep_depth++; check_chain_key(curr); works as a heavy hammer. -Chris