Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2747181pxx; Sun, 1 Nov 2020 08:32:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ6bOY/8lK/AcgBphSsSJn6maB6FGrqO0FJbX33JMJ/z79Dv9I1KfAb+luLBmgZuS/6YHF X-Received: by 2002:a17:906:3150:: with SMTP id e16mr11564905eje.266.1604248357089; Sun, 01 Nov 2020 08:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604248357; cv=none; d=google.com; s=arc-20160816; b=i2GCdbVCkMpoqbsUNaB7He9H/b6jl/k725Lm2yisw0tNjAncPmG0qI/htmYgqHqME5 nuEQhKp7x5LXdsj+oesVMmY1mCf1GzmprrGFpEWLPGl+OrlKWzH7hY2BLsLEdv9Xb8KT QrPE/et2BdvzpuIKZuLmkwgs+XSEH7Now4wUFCa5YcVqaMyWbDhXo77SCSbYX3rUILOy LDuJ131yctCgCQpP/Hl9J6KuLyWpp4LKsufl0V7Mv35Ey1j3/yQIqOfXIX2KYkH6Y2Bd qVExg5EwyenrXJruX+kHtEzvO2h9Jr2Owq0H1jn+PfNXMYvqqOYVi0GWiVz7QBqyydEx Ez2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=i3iFp9BNUARkF9tIHFcE/nYLISMjwJAZ5vJ8wiWrVzk=; b=ZUE1iHNiw08QSDpSoNTEJfGMFUNMOZ3Aj12gfz6VCeFhvP7ffAeumtoImlnakA4Lai WbENwOhrlEg99iXf43w3MapCxPR1c279iAheRuoGIrBYWjIr0MjCJ8/ueZ6nm3a1wd8X 2Y1xBLqkoBju7t3dOlBeC+nwkR+OsrKuqxlxnGR9ucrf3yE+X13sthRSMRGWvDJYPS+L yWBWRZc+sTPkR4aqD5Lk1zZmebcaYKrbyn1dq0SHJrihHepRoIpwqc63cn4zUtnQHZHg Gq8W9JkZRk+wJftRC6ruYkkkSSKZt6h8VDm4OsoD407lefUkmpEnWIvH65P3b1LNbwoC b0Sw== 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 bh5si8672708ejb.221.2020.11.01.08.32.11; Sun, 01 Nov 2020 08:32:37 -0800 (PST) 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 S1727026AbgKAQ2k (ORCPT + 99 others); Sun, 1 Nov 2020 11:28:40 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:50554 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726549AbgKAQ2k (ORCPT ); Sun, 1 Nov 2020 11:28:40 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 946CB1C0B8D; Sun, 1 Nov 2020 17:28:38 +0100 (CET) Date: Sun, 1 Nov 2020 17:28:38 +0100 From: Pavel Machek To: Andrea Righi Cc: Boqun Feng , Peter Zijlstra , Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org Subject: Re: lockdep: possible irq lock inversion dependency detected (trig->leddev_list_lock) Message-ID: <20201101162838.GA24370@duo.ucw.cz> References: <20201101092614.GB3989@xps-13-7390> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cWoXeonUoKmBZSoM" Content-Disposition: inline In-Reply-To: <20201101092614.GB3989@xps-13-7390> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > I'm getting the following lockdep splat (see below). >=20 > Apparently this warning starts to be reported after applying: >=20 > e918188611f0 ("locking: More accurate annotations for read_lock()") >=20 > It looks like a false positive to me, but it made me think a bit and > IIUC there can be still a potential deadlock, even if the deadlock > scenario is a bit different than what lockdep is showing. >=20 > In the assumption that read-locks are recursive only in_interrupt() > context (as stated in e918188611f0), the following scenario can still > happen: >=20 > CPU0 CPU1 > ---- ---- > read_lock(&trig->leddev_list_lock); > write_lock(&trig->leddev_list_l= ock); > > kbd_bh() > -> read_lock(&trig->leddev_list_lock); >=20 > *** DEADLOCK *** >=20 > The write-lock is waiting on CPU1 and the second read_lock() on CPU0 > would be blocked by the write-lock *waiter* on CPU1 =3D> deadlock. >=20 > In that case we could prevent this deadlock condition using a workqueue > to call kbd_propagate_led_state() instead of calling it directly from > kbd_bh() (even if lockdep would still report the false positive). console.c is already using bh to delay work from interrupt. But... that should not be neccessary. led_trigger_event should already be callable from interrupt context, AFAICT. Could this be resolved by doing the operations directly from keyboard interrupt? Best regards, Pavel --=20 HTTP://www.livejournal.com/~pavelmachek --cWoXeonUoKmBZSoM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX57iNgAKCRAw5/Bqldv6 8q64AJ9ySHeDJIbc0UtT7/FudduzVYeDZgCcCDzwb2D9psrvx8E6Kk6GTLRG1oA= =ggM2 -----END PGP SIGNATURE----- --cWoXeonUoKmBZSoM--