Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp695141imm; Thu, 4 Oct 2018 01:37:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV60DYt6uG5B6tFq5634SDj64nc3vsjQDFRuTm6boAPL6fYirzkRtdDymNh4m/oxIWjQQjaeF X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr5521984plb.173.1538642229551; Thu, 04 Oct 2018 01:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538642229; cv=none; d=google.com; s=arc-20160816; b=ohiAxMWbDhuHO6d5deBRL0vl6dcLhrJ2uoI0WS223RRPUy3FH9jvDYAzQ1b4bKr1Da 1G+iLL27D9DIGs1zAU9JC3a4C1+iIJ0bgwxQaJrFUMUAIWPJhHT49lr1lehIXn+7kLBz d+96PMYFKRCZ0UCUN0sZMnXzXBGPsUQ6DtvVlH13Y7lSzUSBOQX7G2TmKjt0j7y9AqcY TVkeEm0HxSr8zmc9D8dmMZ9aG+2+WmM2VguYatQFHuaIgIF7xI8aQ6LzPHcGUzBGD6+7 Lqgc9X4494ovcIugRCKjWMzbpV5PBqHQOkcqXfjMO+mPoMfrGJc0I8kKbgh1UeAldr7s mKSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HbPhnUjkbdgWKb85DFJYhpLqmWkkrhmdtgjQOX/Vc1U=; b=MfIb7sfUwDHApi3+Y2Mn2xu/Ek7kNg1bXRjdtcE9ann39XHIHhWu/yVDoRNdl+LGXV uamVZsx10cLJCXp2FHurIIk2xUvvNib4Ohhh/srog9cyFgqf+iszUiIVvLJKXSMvOqUI prDSJYfB8LfCpazCQP5DWfluEElziJX4KhS6IefYGxH9fowbZtjaU+/+2JTtq5Iz9hh+ gLO/QkLV/j9yMjFCXjBVKvI2+YX6DYHQvnqYN6ZPj6N3LghYE1bwyIC3sJ7Onl6amBPl 6qX3ewOjdHbGFB4yOG/W3BaRTWpVwFGsKb1O0T7XIfOC8QrPOfMtBocW8x8SzobF9dEL leRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11-v6si4147585pgs.323.2018.10.04.01.36.53; Thu, 04 Oct 2018 01:37:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbeJDP2V (ORCPT + 99 others); Thu, 4 Oct 2018 11:28:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:46746 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726808AbeJDP2V (ORCPT ); Thu, 4 Oct 2018 11:28:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DEB8FAD82; Thu, 4 Oct 2018 08:36:10 +0000 (UTC) Date: Thu, 4 Oct 2018 10:36:09 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: Daniel Wang , rostedt@goodmis.org, stable@vger.kernel.org, Alexander.Levin@microsoft.com, akpm@linux-foundation.org, byungchul.park@lge.com, dave.hansen@intel.com, hannes@cmpxchg.org, jack@suse.cz, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mathieu Desnoyers , Mel Gorman , mhocko@kernel.org, pavel@ucw.cz, penguin-kernel@i-love.sakura.ne.jp, peterz@infradead.org, tj@kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz, Cong Wang , Peter Feiner Subject: Re: 4.14 backport request for dbdda842fe96f: "printk: Add console owner and waiter logic to load balance console writes" Message-ID: <20181004083609.kcziz2ynwi2w7lcm@pathway.suse.cz> References: <20181001152324.72a20bea@gandalf.local.home> <20181002084225.6z2b74qem3mywukx@pathway.suse.cz> <20181002212327.7aab0b79@vmware.local.home> <20181003091400.rgdjpjeaoinnrysx@pathway.suse.cz> <20181003133704.43a58cf5@gandalf.local.home> <20181004074442.GA12879@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181004074442.GA12879@jagdpanzerIV> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2018-10-04 16:44:42, Sergey Senozhatsky wrote: > On (10/03/18 11:37), Daniel Wang wrote: > > When `softlockup_panic` is set (which is what my original repro had and > > what we use in production), without the backport patch, the expected panic > > would hit a seemingly deadlock. So even when the machine is configured > > to reboot immediately after the panic (kernel.panic=-1), it just hangs there > > with an incomplete backtrace. With your patch, the deadlock doesn't happen > > and the machine reboots successfully. > > > > This was and still is the issue this thread is trying to fix. The last > > log snippet > > was from an "experiment" that I did in order to understand what's really > > happening. So far the speculation has been that the panic path was trying > > to get a lock held by a backtrace dumping thread, but there is not enough > > evidence which thread is holding the lock and how it uses it. So I set > > `softlockup_panic` to 0, to get panic out of the equation. Then I saw that one > > CPU was indeed holding the console lock, trying to write something out. If > > the panic was to hit while it's doing that, we might get a deadlock. > > Hmm, console_sem state is ignored when we flush logbuf, so it's OK to > have it locked when we declare panic(): > > void console_flush_on_panic(void) > { > /* > * If someone else is holding the console lock, trylock will fail > * and may_schedule may be set. Ignore and proceed to unlock so > * that messages are flushed out. As this can be called from any > * context and we don't want to get preempted while flushing, > * ensure may_schedule is cleared. > */ > console_trylock(); > console_may_schedule = 0; > console_unlock(); > } > > Things are not so simple with uart_port lock. Generally speaking we > should deadlock when we NMI panic() kills the system while one of the > CPUs holds uart_port lock. This looks like a reasonable explanation of what is happening here. It also explains why the console owner logic helped. > 8250 has sort of a workaround for this scenario: > > serial8250_console_write() > { > if (port->sysrq) > locked = 0; > else if (oops_in_progress) > locked = spin_trylock_irqsave(&port->lock, flags); > else > spin_lock_irqsave(&port->lock, flags); > > ... > uart_console_write(port, s, count, serial8250_console_putchar); > ... > > if (locked) > spin_unlock_irqrestore(&port->lock, flags); > } > > Now... the problem. A theory, in fact. > panic() sets oops_in_progress back to zero - bust_spinlocks(0) - too soon. I see your point. I am just a bit scared of this way. Ignoring locks is a dangerous and painful approach in general. Best Regards, Petr