Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3084008pxx; Sun, 1 Nov 2020 22:22:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4O84BQtWY4EnEidoHR5bLxVmcBR/gzlwPeeyTY225YzdyPnXzNElsV0S2EjxqD/p7umtd X-Received: by 2002:a17:906:b0d6:: with SMTP id bk22mr13763998ejb.153.1604298176805; Sun, 01 Nov 2020 22:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604298176; cv=none; d=google.com; s=arc-20160816; b=vl6kKSWRFlobSuyfF+K5LyM3jyew7SLaz5bbqMuavvg5eWEef2T+pRol9V+OJe1pJf ueGhkEFy1zoFKd47hoUqDaYoYjWIeRrcplePS64QFUEgF1bt8dqeu1RU+yZ6ooh25rhU 0JTP07FHVSoNRfJXXX/BBsL86UGeQxrepOsGdDNfPuuTPx5Hxh/MMzQa6ew2nmusk+Nb /AZtdDt/vbfMhS30ct49K+cWVoSYlwpZEJ+Uhm3qt6fr+PUxUJldJv2e2M69hkWsq9R0 k4yK/Va1GxyYwRQjAmVXfU0UUR9BIsOSOc/ovFHDGk3thlhMNP8ybd0FcFRQrypZIIp6 j0Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iOizdv8Buv6FfQDjIz+DCkY2/qLkv4EBJXrU3sSnCWs=; b=Lvf6jqHMx8egcAq7V301o6ptuME0BuerBZAMfOGTmryqTpeyZ2C7TK1MzBgljDI88B rmx6QH5Zow94BkO5KsitzzXlvJpX802xh4gf9PZF3KDVP9OqHOegyxd55ukHyFM1dlx0 pXGDMzrhqA9Gf6482YlG1TR8mohshpi3HjPe82MOmTgRLYgDUvHQ5a51SNOa88bFVvCj qjEZPbDrN/JjJH+l87F2bkjzTg+w2y/1jX/KH1KZKnIMOvXR5h5TARTRkHizlROR8FFb 1U0c7my34S5y5MyJTI3LdHyFs8X1mkdIQFgpqzCNuY9msywcpJZb63OdEF6M3uJEC81w 146w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yC26Ozff; 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 o11si11962166edz.483.2020.11.01.22.22.33; Sun, 01 Nov 2020 22:22:56 -0800 (PST) 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=yC26Ozff; 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 S1727853AbgKBGTL (ORCPT + 99 others); Mon, 2 Nov 2020 01:19:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgKBGTK (ORCPT ); Mon, 2 Nov 2020 01:19:10 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEB6C0617A6 for ; Sun, 1 Nov 2020 22:19:10 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id 184so15892633lfd.6 for ; Sun, 01 Nov 2020 22:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iOizdv8Buv6FfQDjIz+DCkY2/qLkv4EBJXrU3sSnCWs=; b=yC26OzffaiSXuxD3Yv3sgbPJK3Y6JOG5O1docyb2L7i9Fusu3SZVvPjm1SFL6QmlQo gKg8kmbm+baIFlSZGvEojmKv/moocE3VvivuOLidCzkhuTl81R+xiTcW0wN9w4zUEyKk +NOg638xGq5V89dcOGjCepuD7f3H54SNnwkk0pvaXbSfBHPYlpDcU+2glYbbDnITAnRv dW8HjUa8iYuhhrd8V8NNa5vcffS0r6qI3yeFfQnJtGd/xuwDz66CsVIqzXt3COTZ/x+3 lUsiJj8EzHi7IGwXAA2SqYvExzHB4sQ+MvmgCk9hJblZ3clBXKvK38cpazY5fXTxzPir yY1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iOizdv8Buv6FfQDjIz+DCkY2/qLkv4EBJXrU3sSnCWs=; b=jWm8TBXZel9bt4eOSe9NOJgKOe8YLwNwjL2Q4FVgF8b9kOdijcxy5C99VuKIOh8ny1 hLZHo3U1DyYwxx5AowtBiaLePwq63vewWbRzHLm3Vh6Bp59frZsflIsr95VRV7ov4rMC q8gpLPZrcKJBPKVaQbhZFN2vw6OSVU5uYPS0U0FslyhrsHqw0m7vdWhO44GeL0yel8/z OuqpjMA5yXN71jmgzGSd3JCB3NgBrXHt0xUp+rzIV5pu+qns2D2qMjM1Ajm1rI0NvvU7 1FfhEk6OnkPl9Dswo9fjEj6J51JFtvlCjx+sGU1mOrkhC0+QhUjX8nz3dqyelM14hCK1 6JJA== X-Gm-Message-State: AOAM530DN9lzKLJeeLG95aGpdACZ4bTayH0QDPqnvwsRTUqkYaL2q5es HaKmi1LLNTKGSVUNUbBk6XFIAlG4Qn87cmGreL92Kw== X-Received: by 2002:a19:e20f:: with SMTP id z15mr4551104lfg.273.1604297948806; Sun, 01 Nov 2020 22:19:08 -0800 (PST) MIME-Version: 1.0 References: <1603983387-8738-1-git-send-email-sumit.garg@linaro.org> <1603983387-8738-7-git-send-email-sumit.garg@linaro.org> <20201029152106.gj66mjnathsdqtoe@holly.lan> In-Reply-To: <20201029152106.gj66mjnathsdqtoe@holly.lan> From: Sumit Garg Date: Mon, 2 Nov 2020 11:48:53 +0530 Message-ID: Subject: Re: [PATCH v6 6/7] kgdb: roundup: Allow runtime arch specific override To: Daniel Thompson Cc: Marc Zyngier , Catalin Marinas , Will Deacon , linux-arm-kernel , Thomas Gleixner , Jason Cooper , Russell King - ARM Linux admin , tsbogend@alpha.franken.de, mpe@ellerman.id.au, "David S. Miller" , mingo@redhat.com, bp@alien8.de, x86@kernel.org, Mark Rutland , julien.thierry.kdev@gmail.com, Douglas Anderson , Jason Wessel , Masayoshi Mizuma , ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Oct 2020 at 20:51, Daniel Thompson wrote: > > On Thu, Oct 29, 2020 at 08:26:26PM +0530, Sumit Garg wrote: > > Add a new API kgdb_arch_roundup_cpus() for a particular archichecture to > > override default kgdb roundup and if it detects at runtime to not support > > NMI roundup then it can fallback to default implementation using async > > SMP cross-calls. > > > > Currently such an architecture example is arm64 supporting pseudo NMIs > > feature which is only available on platforms which have support for GICv3 > > or later version. > > > > Signed-off-by: Sumit Garg > > --- > > arch/powerpc/kernel/kgdb.c | 3 ++- > > arch/sparc/kernel/smp_64.c | 3 ++- > > arch/x86/kernel/kgdb.c | 6 ++++-- > > include/linux/kgdb.h | 5 +++-- > > kernel/debug/debug_core.c | 10 +++++++++- > > 5 files changed, 20 insertions(+), 7 deletions(-) > > > > diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c > > index 4090802..126575d 100644 > > --- a/arch/powerpc/kernel/kgdb.c > > +++ b/arch/powerpc/kernel/kgdb.c > > @@ -125,9 +125,10 @@ static int kgdb_debugger_ipi(struct pt_regs *regs) > > } > > > > #ifdef CONFIG_SMP > > -void kgdb_roundup_cpus(void) > > +bool kgdb_arch_roundup_cpus(void) > > { > > smp_send_debugger_break(); > > + return true; > > } > > #endif > > > > diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c > > index e38d8bf..c459c83 100644 > > --- a/arch/sparc/kernel/smp_64.c > > +++ b/arch/sparc/kernel/smp_64.c > > @@ -1014,9 +1014,10 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page) > > } > > > > #ifdef CONFIG_KGDB > > -void kgdb_roundup_cpus(void) > > +bool kgdb_arch_roundup_cpus(void) > > { > > smp_cross_call(&xcall_kgdb_capture, 0, 0, 0); > > + return true; > > } > > #endif > > > > diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c > > index ff7878d..1b756d9 100644 > > --- a/arch/x86/kernel/kgdb.c > > +++ b/arch/x86/kernel/kgdb.c > > @@ -404,7 +404,8 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) > > > > #ifdef CONFIG_SMP > > /** > > - * kgdb_roundup_cpus - Get other CPUs into a holding pattern > > + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern > > + * in an architectural specific manner > > * > > * On SMP systems, we need to get the attention of the other CPUs > > * and get them be in a known state. This should do what is needed > > @@ -414,9 +415,10 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) > > * > > * On non-SMP systems, this is not called. > > */ > > -void kgdb_roundup_cpus(void) > > +bool kgdb_arch_roundup_cpus(void) > > { > > apic_send_IPI_allbutself(NMI_VECTOR); > > + return true; > > } > > #endif > > > > diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h > > index 0d6cf64..f9db5b8 100644 > > --- a/include/linux/kgdb.h > > +++ b/include/linux/kgdb.h > > @@ -200,7 +200,8 @@ kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer, > > extern void kgdb_call_nmi_hook(void *ignored); > > > > /** > > - * kgdb_roundup_cpus - Get other CPUs into a holding pattern > > + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern > > + * in an architectural specific manner > > * > > * On SMP systems, we need to get the attention of the other CPUs > > * and get them into a known state. This should do what is needed > > @@ -210,7 +211,7 @@ extern void kgdb_call_nmi_hook(void *ignored); > > * > > * On non-SMP systems, this is not called. > > */ > > -extern void kgdb_roundup_cpus(void); > > +extern bool kgdb_arch_roundup_cpus(void); > > > > /** > > * kgdb_arch_set_pc - Generic call back to the program counter > > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c > > index 1e75a89..27e401c 100644 > > --- a/kernel/debug/debug_core.c > > +++ b/kernel/debug/debug_core.c > > @@ -241,13 +241,21 @@ void __weak kgdb_call_nmi_hook(void *ignored) > > } > > NOKPROBE_SYMBOL(kgdb_call_nmi_hook); > > > > -void __weak kgdb_roundup_cpus(void) > > +bool __weak kgdb_arch_roundup_cpus(void) > > +{ > > + return false; > > Do we really need to introduce all these boolean return values just to > call a bit of library code when one of the architectures wants to > fallback to a generic implementation? > > Why not something more like: > > void kgdb_smp_call_nmi_hook(void) > { > /* original weak version of kgdb_roundup_cpus goes here */ > } > > void __weak kgdb_roundup_cpus(void) > { > kgdb_smp_call_nmi_hook(); > } > > arm64 can now simply call the new library function if a fallback is needed. > Makes sense, I will use this approach instead. > Note that same question applies to the backtrace changes... In case of backtrace, there are already multiple APIs wrapping arch_trigger_cpumask_backtrace() as follows: - trigger_all_cpu_backtrace() - trigger_allbutself_cpu_backtrace() - trigger_cpumask_backtrace() - trigger_single_cpu_backtrace() And each of them already return a boolean and have corresponding different fallback mechanisms. So we can't have a common fallback API from arch specific code and instead need to extend that boolean return to arch specific code that is implemented as part of patch #4. If you do have any better ideas then do let me know. -Sumit > > > Daniel. > > > > +} > > + > > +static void kgdb_roundup_cpus(void) > > { > > call_single_data_t *csd; > > int this_cpu = raw_smp_processor_id(); > > int cpu; > > int ret; > > > > + if (kgdb_arch_roundup_cpus()) > > + return; > > + > > for_each_online_cpu(cpu) { > > /* No need to roundup ourselves */ > > if (cpu == this_cpu) > > -- > > 2.7.4 > >