Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3174961pxf; Sun, 28 Mar 2021 15:06:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGTqRLCoTPwtgEHEVNkcQNo/suM0FM9hWYRB0Z/rLZ6O8dKf880e6dNdJzXhJT/OBdYohS X-Received: by 2002:a17:906:1113:: with SMTP id h19mr25172179eja.478.1616969164008; Sun, 28 Mar 2021 15:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616969164; cv=none; d=google.com; s=arc-20160816; b=y5FNLUOg0zsLZmQxYoou258XsVzkU8f4md/d+xFDzoUQBgYqzaVvmioI0TamEGVmiI TTg/9rRmlG+w+SjDewq8MlNc+WtNYFaNg+de5Ba+B0prjXYuaIzPR4BPxRL0N7JEGxum NcW6qUhtsoOPTYYywG78AjCenhfbE9jupH7qv8cpKuJouIH913nRoh/WX4mACdBJPAB7 Sf8ZP5pYmNudzxLnBL159j+4lB8i4p1s5pvUzAjtkWTGt93Ob9E/DJ0hmANF37S0EdaH 9Mepr6TZTAAxi3pNXkpSO36nreVxaGD2D8yi8WXymsGoZ/IlAnmXAStdSanPr+fUM+QE UItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=IMSDZxbZUdk3bc8y+nSC5JaiqgjkwXBno7O9/VX/IGM=; b=Zm1CJz2NlmIZMB3EJZvK7f7llsx1QzZeAW/Jh7yYO7FprmRT9eC3Zfol8CYspoGq15 5XCjBwCuvxY2bbgO1fEDfY04fhcfV/ze49MXI7lGQipBdKS/zHVLDIIIpznlQdnbjjdk CCah43G+/O3H4gLJizbG9T4KL8lMcUPGmnEJeOOJrTCW7HiNVp1D8n/kPud3Jr5ksEDB R7lqyfT2LEl9lKUzclXRiV4vZ63FoMbUuNzAceQXBJwavPTVji+iUbTsyEu3XtbsWekR nsrEx/NTMhH2C1SnQ1jhKDndleUI0r0iXZvyE+snGijYVUPifFSWu+mKzIErXaobCk7Y /mZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=XOGKBRsX; dkim=neutral (no key) header.i=@linutronix.de; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si11519849eds.501.2021.03.28.15.05.40; Sun, 28 Mar 2021 15:06:03 -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=@linutronix.de header.s=2020 header.b=XOGKBRsX; dkim=neutral (no key) header.i=@linutronix.de; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231213AbhC1WEn (ORCPT + 99 others); Sun, 28 Mar 2021 18:04:43 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:39840 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbhC1WEh (ORCPT ); Sun, 28 Mar 2021 18:04:37 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1616969075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IMSDZxbZUdk3bc8y+nSC5JaiqgjkwXBno7O9/VX/IGM=; b=XOGKBRsXuU8MjqdvlbtmVCwXPtrCPvQKfQg0H5EAqX0/LtFgRZVe3HYRGLaXqUlk+fNrvj Vy3u1DW4xd5yA2mQIxrZj72E0kvVzhJyRKP59i34a/qfQiUTEOkCtFwKxuublH1W1wdhkP H3w0PJb8kXQ4Pkkg7oDbQhgs5tFX2zP0tZzgnoqPAF/ZiiW3nHrnoNkiBYfob7b3V83kIh /K4KikrDNzP3wG79HUhY18PTO9XusxWGhAXkm957dCU/eX7nMZyIe4Wu6eu/RUAxzIwC/t ZpLkWVJKjs6MkMJVz6hPmUlLmIw1OXtYrwq/vS9EEFdw/URpv13u5xRHXu02fA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1616969075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IMSDZxbZUdk3bc8y+nSC5JaiqgjkwXBno7O9/VX/IGM=; b=pK4Ko5ppfmrWGqC5yYOfxVlujh1gHUNHIQivHsjXdPDTEfMhTIwqe19P1WZ4cgyFC4aF1U jmJBgKop2bD1lACw== To: Waiman Long Cc: linux-kernel@vger.kernel.org, David Woodhouse , Marc Zyngier , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness Subject: Re: [PATCH] x86/apic/vector: Move pr_warn() outside of vector_lock In-Reply-To: <20210328195811.32109-1-longman@redhat.com> References: <20210328195811.32109-1-longman@redhat.com> Date: Mon, 29 Mar 2021 00:04:34 +0200 Message-ID: <871rbzc4ul.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Waiman, On Sun, Mar 28 2021 at 15:58, Waiman Long wrote: > It was found that the following circular locking dependency warning > could happen in some systems: > > [ 218.097878] ====================================================== > [ 218.097879] WARNING: possible circular locking dependency detected > [ 218.097880] 4.18.0-228.el8.x86_64+debug #1 Not tainted > [ 218.097881] ------------------------------------------------------ > [ 218.097882] systemd/1 is trying to acquire lock: > [ 218.097883] ffffffff84c27920 (console_owner){-.-.}, at: console_unlock+0x3fb/0x9f0 > [ 218.097886] > [ 218.097887] but task is already holding lock: > [ 218.097888] ffffffff84afca78 (vector_lock){-.-.}, at: x86_vector_activate+0xca/0xab0 > [ 218.097891] > [ 218.097892] which lock already depends on the new lock. > : > [ 218.097966] other info that might help us debug this: > [ 218.097967] > [ 218.097967] Chain exists of: > [ 218.097968] console_oc_lock_class --> vector_lock > [ 218.097972] > [ 218.097973] Possible unsafe locking scenario: > [ 218.097973] > [ 218.097974] CPU0 CPU1 > [ 218.097975] ---- ---- > [ 218.097975] lock(vector_lock); > [ 218.097977] lock(&irq_desc_lock_class); > [ 218.097980] lock(vector_lock); > [ 218.097981] lock(console_owner); > [ 218.097983] > [ 218.097984] *** DEADLOCK *** can you please post the full lockdep output? > This lockdep warning was causing by printing of the warning message: > > [ 218.095152] irq 3: Affinity broken due to vector space exhaustion. > > It looks that this warning message is relatively more common than > the other warnings in arch/x86/kernel/apic/vector.c. To avoid this > potential deadlock scenario, this patch moves all the pr_warn() calls > in the vector.c file outside of the vector_lock critical sections. Definitely not. > -static int activate_reserved(struct irq_data *irqd) > +static int activate_reserved(struct irq_data *irqd, unsigned long flags, > + bool *unlocked) > { > struct apic_chip_data *apicd = apic_chip_data(irqd); > int ret; > @@ -410,6 +411,8 @@ static int activate_reserved(struct irq_data *irqd) > */ > if (!cpumask_subset(irq_data_get_effective_affinity_mask(irqd), > irq_data_get_affinity_mask(irqd))) { > + raw_spin_unlock_irqrestore(&vector_lock, flags); > + *unlocked = true; What? > pr_warn("irq %u: Affinity broken due to vector space exhaustion.\n", > irqd->irq); > } > @@ -446,6 +449,7 @@ static int x86_vector_activate(struct irq_domain *dom, struct irq_data *irqd, > { > struct apic_chip_data *apicd = apic_chip_data(irqd); > unsigned long flags; > + bool unlocked = false; > int ret = 0; > > trace_vector_activate(irqd->irq, apicd->is_managed, > @@ -459,8 +463,9 @@ static int x86_vector_activate(struct irq_domain *dom, struct irq_data *irqd, > else if (apicd->is_managed) > ret = activate_managed(irqd); > else if (apicd->has_reserved) > - ret = activate_reserved(irqd); > - raw_spin_unlock_irqrestore(&vector_lock, flags); > + ret = activate_reserved(irqd, flags, &unlocked); > + if (!unlocked) > + raw_spin_unlock_irqrestore(&vector_lock, flags); Even moar what? > return ret; > } This turns that code into complete unreadable gunk. No way. Thanks, tglx