From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755004AbcK3LbN (ORCPT ); Wed, 30 Nov 2016 06:31:13 -0500 Received: from merlin.infradead.org ([205.233.59.134]:44776 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbcK3LbE (ORCPT ); Wed, 30 Nov 2016 06:31:04 -0500 Date: Wed, 30 Nov 2016 12:30:49 +0100 From: Peter Zijlstra To: Petr Mladek Cc: linyongting@huawei.com, kejinling@huawei.com, akpm@linux-foundation.org, sergey.senozhatsky@gmail.com, bp@suse.de, tj@kernel.org, treding@nvidia.com, linux-kernel@vger.kernel.org, leisure.wang@huawei.com Subject: Re: [PATCH] printk: Fix spinlock deadlock in printk reenty Message-ID: <20161130113049.GN3045@worktop.programming.kicks-ass.net> References: <1480490119-63559-1-git-send-email-linyongting@huawei.com> <20161130105653.GF24060@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161130105653.GF24060@pathway.suse.cz> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 30, 2016 at 11:56:53AM +0100, Petr Mladek wrote: > On Wed 2016-11-30 15:15:19, linyongting@huawei.com wrote: > > In arm, arm64, x86 or other architecture, spinlock variable x86 no longer uses ticket locks. > > The solution is that In function zap_locks(), replace > > raw_spin_lock_init(&logbuf_lock) with raw_spin_unlock(&logbuf_lock), That's broken too. Imagine the CPU that actually holds the lock then _also_ doing an unlock. At that point the tail is ahead of the head and you're also up some creek without no paddle. Note that I ran into all these scenarios many years ago.. > Another solution would be to make printk() to ignore locks > when Oops is in progress. It was somewhere suggested by Peter > Zijlstra. Well, it might cause some problems as well when > there are more CPUs still running and printing. Ignoring is the only option. There is no way to fudge the lock state and live to tell about it.