Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2477946pxy; Tue, 3 Aug 2021 07:28:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+GMoq83n5uIh648h6wabBB/KNfvNu7aJ38c/DYSanF3corfnKRIz62gP3EwGm1fpmVd/j X-Received: by 2002:a92:d292:: with SMTP id p18mr525671ilp.286.1628000926996; Tue, 03 Aug 2021 07:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628000926; cv=none; d=google.com; s=arc-20160816; b=i4zylBVSSGN0DFjfp9cZnkLZHtIgglwJS+ED24NOQ7O4y3lOBoCcAw+r2RJo7WYGmc +cWrYIs3j/z5UK5GNk78eUWEJaOfZAyzdrLCbCv8JIMJSX2b50S0Ytp8e5EjB2E/vNhL ao2w6adR74OqeQwd4vqhgeh2aDgqnTgFkTDkhXJbprsUXgV5OuLvJg3ZgS9N2Ps9rVdD h4z9VvBip8g60qVJQWkvEyO0T9F32efGjiD28CmBAgoujDjJufO6bQqoSRZ0TIYJwwIb +FnZDZC1sV7YmKZtcS38lAU+CmPUJIIuJzXEXSKFvW/3LYEo6Fc81FoM7fSrjKFF/WFv gssQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Hyrev4qZ9gpvHA1KPCI74nwAO20DWHqFncjdod67xeY=; b=AaKsQglF81x+c2/hwE2DZoJJuInHOP1P37IBl0DF4D7ZY/2zZM0EkNt6HBhKgUoE1x VJzhPwkFFB/PkeqdpcJ73e3L30iXSpPPk2VTgWDfNhCIA5cKAMUW3GXAVwohkRl7oQoB oXXheobimi3aB26w9u28rEhnnrUKINxrjnOYeSh03eOYabVoAiKSLrPH4A6oqe/GIXch /+/O/k+qtaF0eCXJYYA7PMpCKg8dEjQ/FkzoioL/t0g0o5KlXv9pQoLq99ZxEvuWAoX5 yVQBdIVYeoKZBT7kNhWsEs5GPY6WwumApjlYp9lE1yZ+0yGU41NbVAUPoTAGj45ZTzQF lWCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PYhmKlzH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si16664849ilr.103.2021.08.03.07.28.32; Tue, 03 Aug 2021 07:28:46 -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=pass header.i=@linaro.org header.s=google header.b=PYhmKlzH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236363AbhHCO0O (ORCPT + 99 others); Tue, 3 Aug 2021 10:26:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236224AbhHCO0O (ORCPT ); Tue, 3 Aug 2021 10:26:14 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269C7C061757 for ; Tue, 3 Aug 2021 07:26:03 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id u15so12605357wmj.1 for ; Tue, 03 Aug 2021 07:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Hyrev4qZ9gpvHA1KPCI74nwAO20DWHqFncjdod67xeY=; b=PYhmKlzHVcWBCe22CBKVh/KxzmRCtPAQBvU+UWPmJGHL6O8vEmHQ2VVS7padRiJfDv M0L+E63SYkCVgoWe8p7Jfd5Lvh/vsoT3Hi5J0VWPan3CZIXdxpFKAwATKpBrOAGhUKM7 tW3YaxbCKIcKPv7p7/Kx3CzOZ9ev/Q1EULAYiP/qxyhk5ODDZcKhNo+GVGA0pf/cki+l 62n2JMxkUOb0ktuQSYOHM48ZBedtzV4VW23uslZwi4WCIUhadBSmTJ4R3hh0SDk3xtii KUbHi5FBa2auiSaifO4Ufh18Eq/uukG0ta2ryDOAfVyzBOiYCbrAiIsw/XZP2hS2AE1J zzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Hyrev4qZ9gpvHA1KPCI74nwAO20DWHqFncjdod67xeY=; b=RvyNNTzNuHikcGRbd5f5yPt/D6oekfL8Q1tpoThmQYD45tCHhc0KfjlExKirIm3+aX u+0FdbvaImQBZGNNH/i/Amn25tpIUEPa0bros5duV/d+9iVPmhhIUaJNqMJMm1SzC7XP gH7T2Y1cwyR16akBLj/XkZhsvFj5E3RDLLRYnCjWuH+Dzgd2wOKIGBBHX2C0b7edBlww pEY3j4pWMmvqMP09g8lpuz4bJLk2HiiD7rrF8fcgzYoMpdrKObanVfhoP+9DgxBzcF6H w+e2gV2hB5fWC7w3c/LiIJ/5iSxPu43zwv9AlnNdU4ZEC7FAosiOHBFACwcMliZNhdJ1 Vhmg== X-Gm-Message-State: AOAM531K+u4+ozGqpsW68t5E2+WWZjAJSTDFRtl2mXFJyMHfq6QiX9Ez QMqe33995y/rO9jFsB+loes0hg== X-Received: by 2002:a7b:c0c1:: with SMTP id s1mr22633670wmh.130.1628000761410; Tue, 03 Aug 2021 07:26:01 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id f7sm17949139wrr.54.2021.08.03.07.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 07:26:00 -0700 (PDT) Date: Tue, 3 Aug 2021 15:25:58 +0100 From: Daniel Thompson To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Jason Wessel , Douglas Anderson , Srikar Dronamraju , "Gautham R. Shenoy" , Chengyang Fan , Christophe Leroy , Bhaskar Chowdhury , Nicholas Piggin , =?utf-8?Q?C=C3=A9dric?= Le Goater , "Gustavo A. R. Silva" , Peter Zijlstra , linuxppc-dev@lists.ozlabs.org, kgdb-bugreport@lists.sourceforge.net Subject: Re: [PATCH printk v1 03/10] kgdb: delay roundup if holding printk cpulock Message-ID: <20210803142558.cz7apumpgijs5y4y@maple.lan> References: <20210803131301.5588-1-john.ogness@linutronix.de> <20210803131301.5588-4-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210803131301.5588-4-john.ogness@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 03, 2021 at 03:18:54PM +0206, John Ogness wrote: > kgdb makes use of its own cpulock (@dbg_master_lock, @kgdb_active) > during cpu roundup. This will conflict with the printk cpulock. When the full vision is realized what will be the purpose of the printk cpulock? I'm asking largely because it's current role is actively unhelpful w.r.t. kdb. It is possible that cautious use of in_dbg_master() might be a better (and safer) solution. However it sounds like there is a larger role planned for the printk cpulock... > Therefore, a CPU must ensure that it is not holding the printk > cpulock when calling kgdb_cpu_enter(). If it is, it must allow its > printk context to complete first. > > A new helper function kgdb_roundup_delay() is introduced for kgdb > to determine if it is holding the printk cpulock. If so, a flag is > set so that when the printk cpulock is released, kgdb will be > re-triggered for that CPU. > > Signed-off-by: John Ogness > --- > arch/powerpc/include/asm/smp.h | 1 + > arch/powerpc/kernel/kgdb.c | 10 +++++++- > arch/powerpc/kernel/smp.c | 5 ++++ > arch/x86/kernel/kgdb.c | 9 ++++--- > include/linux/kgdb.h | 3 +++ > include/linux/printk.h | 8 ++++++ > kernel/debug/debug_core.c | 45 ++++++++++++++++++++-------------- > kernel/printk/printk.c | 12 +++++++++ > 8 files changed, 70 insertions(+), 23 deletions(-) > > [...] > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 3d0c933937b4..1b546e117f10 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -214,6 +215,7 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, > #ifdef CONFIG_SMP > static atomic_t printk_cpulock_owner = ATOMIC_INIT(-1); > static atomic_t printk_cpulock_nested = ATOMIC_INIT(0); > +static unsigned int kgdb_cpu = -1; Is this the flag to provoke retriggering? It appears to be a write-only variable (at least in this patch). How is it consumed? Daniel. > /** > * __printk_wait_on_cpu_lock() - Busy wait until the printk cpu-reentrant > @@ -325,6 +327,16 @@ void __printk_cpu_unlock(void) > -1); /* LMM(__printk_cpu_unlock:B) */ > } > EXPORT_SYMBOL(__printk_cpu_unlock); > + > +bool kgdb_roundup_delay(unsigned int cpu) > +{ > + if (cpu != atomic_read(&printk_cpulock_owner)) > + return false; > + > + kgdb_cpu = cpu; > + return true; > +} > +EXPORT_SYMBOL(kgdb_roundup_delay); > #endif /* CONFIG_SMP */ > > /* Number of registered extended console drivers. */ > -- > 2.20.1 >