Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6439444imd; Wed, 31 Oct 2018 11:43:05 -0700 (PDT) X-Google-Smtp-Source: AJdET5cvV2iaSWZlDjz49nuE8U9qX421prkLOj4IHPekHtFMXp2ewovstzLW5clzyihxl57I9sxN X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr4224188pgn.334.1541011385029; Wed, 31 Oct 2018 11:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541011385; cv=none; d=google.com; s=arc-20160816; b=MbdAxFmsUbPiVqPgrczciClk33fno3RKucsAInsy2gh/8ETTpk4igNDT+H1zzHv26P Q157KZgv+mz8GEGEH/tPIcxwxj1f5g5iLZ0QlixKfHWBI5roCm0lqaHkpPcaDA0bV7Ct dU91QsTB5wMPfFCZ9MRYS8kxm7oo7y4VyALOgTcFU6XYvedOLHPho17Ci3wN5j9Ul1w7 yLLL4pPzgSrPU0puHK3X4qTf6pbGWUYndr6XMHc9Mf6yPQ1yJ/LM6bmqUO4T1lfYqhJk M2nfEHPAZRHPTy6AvzrzmXu/COjD30vNS0e3XBytk0dB2aVDfxbzi85n82DX56slpe3W HGCQ== 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:dkim-signature; bh=WtYS++Eq2aKwebxiYSlbkwQV34nMjfy4iBCJpS0awSw=; b=oaJ4cR8zupfIcxh+5HIZ8hSNSKn15Iyy4ChnFH1waUopvyuOxrOsJixjECS4oOKVrp 6Dfv/35x/7quuj/8xaPRUaPapv1ZZSN4TaB/cF8PWa9BpFOz6OmvcEl5VV1BYUFByeGK 72GEIGbn6MQ+33QpOSAwXLFuayjvqbtI36ll/IKpIGbd6lGSuGFnFn+RUDIMIsAlrg8v ObJVzzPHoO2pDhTD+cOh/1evXTNkDqZ/M5DXiVNIHS+K3MDYD2ugL1OiKHCf47Zt50ng bAlMU5BDToLul454wPG0Bb+Wm2wMceSX85YzJhS+ueRmo41h9xZllqM6TzmHHGghQGk5 ajCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hdQ/nyXb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2-v6si11256627plh.157.2018.10.31.11.42.48; Wed, 31 Oct 2018 11:43:05 -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; dkim=pass header.i=@linaro.org header.s=google header.b="hdQ/nyXb"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730199AbeKADkL (ORCPT + 99 others); Wed, 31 Oct 2018 23:40:11 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36898 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729785AbeKADkL (ORCPT ); Wed, 31 Oct 2018 23:40:11 -0400 Received: by mail-wr1-f68.google.com with SMTP id g9-v6so17620406wrq.4 for ; Wed, 31 Oct 2018 11:40:55 -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:user-agent; bh=WtYS++Eq2aKwebxiYSlbkwQV34nMjfy4iBCJpS0awSw=; b=hdQ/nyXbfRzLkuTjrCs+yt4AzN38RVEgQhSi/O8VUC5RcMchuISzBsyZJL1VYH2Frd EEOj3uIby+3hOsmcYzl+uFlpUahxCiq5zKOrtPNCdr3QyOddDFKIJ4zqQT+lvmodn2nu ORdFQfg5/C1Cx0QHT5BZWjF6cV+MJh4h6LW6U= 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:user-agent; bh=WtYS++Eq2aKwebxiYSlbkwQV34nMjfy4iBCJpS0awSw=; b=K+4ajdq0gcy61XVxS2BGa/gcHmL3EVI3PqNjq3UFIG+Qcunjc+1bNadXHS9jbuE+T4 Wvzet6a/gXvY5YdcqsJ7D2JTGFiOJLTdd0XcD0A4nLznckLx8F6iraxtyAkadTLtD7c/ gMKFaYnjiZkfcklaBEjfKFMvilzq7SPbPCEuzrxplgIX1IoIwKr2/kvA8LlLLv0otDku aYidA+/uupTum48vlseskMuTs2ybheomy07nVg1xD+m0NZY9wAtJKbJhqiyGbPgwWIA5 fBhfH20g1wAauQBwGI/YGXADTGIZsmciIN64mfkECWSk8O4Wv1m3sKnzYnMcEtM0mFUc NY9A== X-Gm-Message-State: AGRZ1gLcvrBr41HCG4sKeVYSjou5iZb/5qSiNeFxM6OeJncFGJgwvR1B WxC/fnF9aIGPqlA4YgjazvoTlQ== X-Received: by 2002:adf:8909:: with SMTP id s9-v6mr3821947wrs.309.1541011254757; Wed, 31 Oct 2018 11:40:54 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id 191-v6sm18863435wmk.30.2018.10.31.11.40.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 11:40:53 -0700 (PDT) Date: Wed, 31 Oct 2018 18:40:50 +0000 From: Daniel Thompson To: Douglas Anderson Cc: Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Peter Zijlstra , linux-mips@linux-mips.org, linux-sh@vger.kernel.org, Greg Kroah-Hartman , Catalin Marinas , James Hogan , linux-hexagon@vger.kernel.org, Vineet Gupta , Thomas Gleixner , Philippe Ombredanne , Kate Stewart , Rich Felker , Ralf Baechle , linux-snps-arc@lists.infradead.org, Yoshinori Sato , Benjamin Herrenschmidt , Will Deacon , Paul Mackerras , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Michael Ellerman , Paul Burton , linux-kernel@vger.kernel.org, Richard Kuo , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function() Message-ID: <20181031184050.sd5opni3mznaapkv@holly.lan> References: <20181030221843.121254-1-dianders@chromium.org> <20181030221843.121254-3-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030221843.121254-3-dianders@chromium.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote: > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c > index f3cadda45f07..9a3f952de6ed 100644 > --- a/kernel/debug/debug_core.c > +++ b/kernel/debug/debug_core.c > @@ -55,6 +55,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -220,6 +221,39 @@ int __weak kgdb_skipexception(int exception, struct pt_regs *regs) > return 0; > } > > +/* > + * Default (weak) implementation for kgdb_roundup_cpus > + */ > + > +static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd); > + > +void __weak kgdb_call_nmi_hook(void *ignored) > +{ > + kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); > +} > + > +void __weak kgdb_roundup_cpus(void) > +{ > + call_single_data_t *csd; > + int cpu; > + > + for_each_cpu(cpu, cpu_online_mask) { > + csd = &per_cpu(kgdb_roundup_csd, cpu); > + smp_call_function_single_async(cpu, csd); > + } smp_call_function() automatically skips the calling CPU but this code does not. It isn't a hard bug since kgdb_nmicallback() does a re-entrancy check but I'd still prefer to skip the calling CPU. As mentioned in another part of the thread we can also add robustness by skipping a cpu where csd->flags != 0 (and adding an appropriately large comment regarding why). Doing the check directly is abusing internal knowledge that smp.c normally keeps to itself so an accessor of some kind would be needed. > +} > + > +static void kgdb_generic_roundup_init(void) > +{ > + call_single_data_t *csd; > + int cpu; > + > + for_each_possible_cpu(cpu) { > + csd = &per_cpu(kgdb_roundup_csd, cpu); > + csd->func = kgdb_call_nmi_hook; > + } > +} I can't help noticing this code is very similar to kgdb_roundup_cpus. Do we really gain much from ahead-of-time initializing csd->func? Daniel.