Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp544892pxa; Fri, 21 Aug 2020 14:06:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBELLEGSQ9l6NHmzaMi3U6NRb2JRT0CDsEjQCsHsEnVgsDQ6KKEaP9WlCb0oJNTvZAM36n X-Received: by 2002:a17:906:cc47:: with SMTP id mm7mr4569118ejb.362.1598044017128; Fri, 21 Aug 2020 14:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598044017; cv=none; d=google.com; s=arc-20160816; b=WGNa530IF3VMYYF8g2ExEEuOmMpXICZqrKiQevkBfwjJ5JtGN4lBw+KIrpZ8/5F48I uFdy/+TB67cUn0F9c6loH2pf+PkyVhcpNcEB7b6tLRT4mAt6LSxYpY5sr9jcDTTwTxws gkD5eM1Ycsq923Ud9Wk6XPaH29g7PDVDOego534iotRHw0ZW7ZNq0bBzLXWJdRvF5z+y 3tJ72Rp7SyJC9aubqPTcGOWCI6Ho6lQLf3I4VcJDKHMt7+QSGZGu1sbMfzqoyfglbmoN 7u9l5SItaa2zBhhMp3vXcp1wim311aXOsEmkDf54CpmwVydBwixQhdfRqR6s4fSnQ7QV D8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=0ifxSCsKczrUn+WbGjX3a/hRA8CzPxM+bxoomihsGoA=; b=K9gdjRsefLZ7uCRM4aEiMPogHO1EbRTXLrEuLVXp4CguWW2f+7hb5RoPx58TKldk43 ZHVO3LZb5zJwlXsggAeK0+z94SP6THFY0kT+jRQk4g9k6+XH4lnCpD1oYftsO4sUcsNe rm/FJIJPDfWxFAksY7Wjes52VqKxfNv+aPRhnplCxaxuU6FpiJDOu75TY27S0jhQgpdP 23yAFanpLsVGmAGScOFVmcF3xwKPArI6Lw6kGvWobgjnhsetRE8tg8anY+VgTDaaeZuU TG68RtiMtGQGSO3SfYaFfhHoXAu0dFmz103wVFQ2GpDIce/PWPxJU6p9dwgehTnYyPMy kuRw== 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 ok21si2169089ejb.373.2020.08.21.14.06.33; Fri, 21 Aug 2020 14:06:57 -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 S1726709AbgHUVDi convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 Aug 2020 17:03:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbgHUVDh (ORCPT ); Fri, 21 Aug 2020 17:03:37 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 169B72076E; Fri, 21 Aug 2020 21:03:36 +0000 (UTC) Date: Fri, 21 Aug 2020 17:03:34 -0400 From: Steven Rostedt To: Andrew Morton Cc: Joerg Vehlow , Thomas Gleixner , Sebastian Andrzej Siewior , Huang Ying , linux-kernel@vger.kernel.org, Joerg Vehlow , Peter Zijlstra Subject: Re: [BUG RT] dump-capture kernel not executed for panic in interrupt context Message-ID: <20200821170334.73b52fdd@oasis.local.home> In-Reply-To: <20200821134753.9547695c9b782275be3c95b5@linux-foundation.org> References: <2c243f59-6d10-7abb-bab4-e7b1796cd54f@jv-coder.de> <20200528084614.0c949e8d@gandalf.local.home> <20200727163655.8c94c8e245637b62311f5053@linux-foundation.org> <20200821110848.6c3183d1@oasis.local.home> <20200821134753.9547695c9b782275be3c95b5@linux-foundation.org> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 Aug 2020 13:47:53 -0700 Andrew Morton wrote: > On Fri, 21 Aug 2020 11:08:48 -0400 Steven Rostedt wrote: > > > On Fri, 21 Aug 2020 12:25:33 +0200 > > Joerg Vehlow wrote: > > > > > Hi Andrew and Others (please read at least the part with @RT developers), > > > > > > > Yup, mutex_trylock() from interrupt is improper. Well dang, that's a > > > > bit silly. Presumably the 2006 spin_lock_mutex() wasn't taken with > > > > irqs-off. > > > > > > > > Ho hum, did you look at switching the kexec code back to the xchg > > > > approach? > > > > > > > I looked into reverting to the xchg approach, but that seems to be > > > not a good solution anymore, because the mutex is used in many places, > > > a lot with waiting locks and I guess that would require spinning now, > > > if we do this with bare xchg. > > > > > > Instead I thought about using a spinlock, because they are supposed > > > to be used in interrupt context as well, if I understand the documentation > > > correctly ([1]). > > > @RT developers > > > Unfortunately the rt patches seem to interpret it a bit different and > > > spin_trylock uses __rt_mutex_trylock again, with the same consequences as > > > with the current code. > > > > > > I tried raw_spinlocks, but it looks like they result in a deadlock at > > > least in the rt kernel. Thiy may be because of memory allocations in the > > > critical sections, that are not allowed if I understand it correctly. > > > > > > I have no clue how to fix it at this point. > > > > > > Jörg > > > > > > [1] https://kernel.readthedocs.io/en/sphinx-samples/kernel-locking.html > > > > There's only two places that wait on the mutex, and all other places > > try to get it, and if it fails, it simply exits. > > > > What I would do is introduce a kexec_busy counter, and have something > > like this: > > > > For the two locations that actually wait on the mutex: > > > > loop: > > mutex_lock(&kexec_mutex); > > ret = atomic_inc_return(&kexec_busy); > > if (ret > 1) { > > /* Atomic context is busy on this counter, spin */ > > atomic_dec(&kexec_busy); > > mutex_unlock(&kexec_mutex); > > goto loop; > > } > > [..] > > atomic_dec(&kexec_busy); > > mutex_unlock(&kexec_mutex); > > > > And then all the other places that do the trylock: > > > > cant_sleep(); > > ret = atomic_inc_return(&kexec_busy); > > if (ret > 1) { > > atomic_dec(&kexec_busy); > > return; > > } > > [..] > > atomic_dec(&kexec_busy); > > Aw gee. Hide all this in include/linux/rostedt_lock.h... Heh, if this was the way to go, I would have definitely recommended packaging that up in static inline functions in some local header. Not necessarily rostedt_lock.h, but I'll use that if people let me :-) > > Sigh. Is it too hard to make mutex_trylock() usable from interrupt > context? That's a question for Thomas and Peter Z. -- Steve