Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2550459imu; Tue, 6 Nov 2018 17:11:17 -0800 (PST) X-Google-Smtp-Source: AJdET5d+N1AQ/5SN/7Ry1V6sIWRnw1FlLpUFhinkbzmKoKxRh4uSVvdiFzofrC2fw0KAgcUtxzzX X-Received: by 2002:a62:7e93:: with SMTP id z141-v6mr29352143pfc.241.1541553077339; Tue, 06 Nov 2018 17:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541553077; cv=none; d=google.com; s=arc-20160816; b=SuTAYbJsWSo+lc4brGu3riLMqUm7AEFMTHVymgQo/tD5V7CaOiMDw6D0GctVS0v3fh hjwN+F3DIiw3zIXWthIRvSAeaUXpJNTo5JQNtzRy0rkjheNW/QRb5Kl/4EOP6wxTcfUq hvmttolDmPGGEYDy4Zf/Ogr3QT8cN9kY/P7RcVEQPfnSnhabkSixNZWw60iwHekUh4t6 rQQ3QOXtBs76V4EVBkbMCfrvjj+mzn8ob3iD2erweYiqOK8TXYLVOMtthz41bauSTPqU waKg9oe6TiGPPGCN/vJeDrk3bltjXX1j0bag03bwsCi0NJBdRHTyOE/WI17FDuSSNN/z qoQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q1G1nbCiejA14GAk13kwpeV5uSd2+HoRj+vWp4s6EqY=; b=oKz58tF9yfKKICiHyZGX8MaNmyLH34YWauc7On52q7MA27Dx5HrhZDBwxhTzj7C/Np VlyNYYsv27lA8zcvOc8clShG04/G+753fajP8wEHG65cVsJwVWV/VP/rjqtCFAh4c2zA TnAQDqS9yAXm0PDSjRNL0ZvgfzL0H8yIsoHY8THFGNiFBPhezeh4mVNcVS69fD8/tSqe W3w0lxIM8NyjUwuleow27I6suLgC4zLGfunmqVz/oSW6kJjbJnT6ImJDeDMiPx0Xf+zO eZK0IUz7R+ps2TUaQc947dJeH1rMwiw4q6LKLEPZQ65g+VckdyGVJt5dIH5/N0o3Wsl0 PgpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eFazb3c7; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k184si27585348pgd.342.2018.11.06.17.11.01; Tue, 06 Nov 2018 17:11:17 -0800 (PST) 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=@chromium.org header.s=google header.b=eFazb3c7; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388953AbeKGKiE (ORCPT + 99 others); Wed, 7 Nov 2018 05:38:04 -0500 Received: from mail-ua1-f65.google.com ([209.85.222.65]:44247 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbeKGKiE (ORCPT ); Wed, 7 Nov 2018 05:38:04 -0500 Received: by mail-ua1-f65.google.com with SMTP id d19so3998509uaq.11 for ; Tue, 06 Nov 2018 17:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q1G1nbCiejA14GAk13kwpeV5uSd2+HoRj+vWp4s6EqY=; b=eFazb3c7zMawmEuLNjfsk/It40P/kZA634ojboNSO3So2qlyJ29LyFhO0/QW48NaB8 kbrri3Yn351FGwvXfSV9Lfr6DEeUttVtBJgkrVmcocs0A5GwSrzSsyI2B3buzW3FuyJ/ hyabXtsc8ANcHIyckTZ0GHWNuBf8WD4smIyJ4= 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=Q1G1nbCiejA14GAk13kwpeV5uSd2+HoRj+vWp4s6EqY=; b=JmYMxUEEg6zY6OaUK8/YDeu6cxccvjazcEgRjjWEjH+ayMoviF1DmImadrfUUZnJXh ZymURmSxz3JUMSkQWCdzjz6VSGWfeGEOmE8CU+CtVvI655+wk+K8PL6qzQcNdFbJgiZx qyVAS3nkbAK/jvlg+PkiMkCyASJHId1X8CI+RXzF+24YrklzK/AiAT26RjM2O/dN8Fq0 TsM50B3eGnyTBg+/sGuCtsNdYYMQek3XW8LF3YhQh7hyQhlqDEDHC8LjDczeJ0D/Ma6I 4vmMVclN4GM4bumYQUsVY7Tig8s7f8nojLng7AOP13BX1JEtGRxVwiaNnMfTkixL/SQC wuVg== X-Gm-Message-State: AGRZ1gKuweKmwPtHjG6NlomXEbZAIQ/KwMFossjA15HDQwX19v3O0BL+ bQh2IUalOWaKsw/YZ99r74sP6XKYoxk= X-Received: by 2002:ab0:26cb:: with SMTP id b11mr12305804uap.112.1541553000386; Tue, 06 Nov 2018 17:10:00 -0800 (PST) Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com. [209.85.222.53]) by smtp.gmail.com with ESMTPSA id o19sm637109vkd.14.2018.11.06.17.10.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 17:10:00 -0800 (PST) Received: by mail-ua1-f53.google.com with SMTP id x3so5271628ual.12 for ; Tue, 06 Nov 2018 17:10:00 -0800 (PST) X-Received: by 2002:a9f:386c:: with SMTP id q41mr3848271uad.27.1541552692505; Tue, 06 Nov 2018 17:04:52 -0800 (PST) MIME-Version: 1.0 References: <20181030221843.121254-1-dianders@chromium.org> <20181030221843.121254-3-dianders@chromium.org> <20181031184050.sd5opni3mznaapkv@holly.lan> <20181103104503.eftn5btx7otgufro@holly.lan> In-Reply-To: <20181103104503.eftn5btx7otgufro@holly.lan> From: Doug Anderson Date: Tue, 6 Nov 2018 17:04:39 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function() To: Daniel Thompson 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 , jhogan@kernel.org, linux-hexagon@vger.kernel.org, Vineet Gupta , Thomas Gleixner , Philippe Ombredanne , Kate Stewart , dalias@libc.org, Ralf Baechle , linux-snps-arc@lists.infradead.org, Yoshinori Sato , Benjamin Herrenschmidt , Will Deacon , paulus@samba.org, Russell King - ARM Linux , Linux ARM , christophe.leroy@c-s.fr, mpe@ellerman.id.au, paul.burton@mips.com, LKML , rkuo@codeaurora.org, linuxppc-dev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sat, Nov 3, 2018 at 3:45 AM Daniel Thompson wrote: > > On Wed, Oct 31, 2018 at 02:41:14PM -0700, Doug Anderson wrote: > > > 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. > > > > Sure. I could add smp_async_func_finished() that just looked like: > > > > int smp_async_func_finished(call_single_data_t *csd) > > { > > return !(csd->flags & CSD_FLAG_LOCK); > > } > > > > My understanding of all the mutual exclusion / memory barrier concepts > > employed by smp.c is pretty weak, though. I'm hoping that it's safe > > to just access the structure and check the bit directly. > > > > ...but do you think adding a generic accessor like this is better than > > just keeping track of this in kgdb directly? I could avoid the > > accessor by adding a "rounding_up" member to "struct > > debuggerinfo_struct" and doing something like this in roundup: > > > > /* If it didn't round up last time, don't try again */ > > if (kgdb_info[cpu].rounding_up) > > continue > > > > kgdb_info[cpu].rounding_up = true > > smp_call_function_single_async(cpu, csd); > > > > ...and then in kgdb_nmicallback() I could just add: > > > > kgdb_info[cpu].rounding_up = false > > > > In that case we're not adding a generic accessor to smp.c that most > > people should never use. > > Whilst it is very tempting to make a sarcastic reply here ("Of course! What > kgdb really needs is yet another set of condition variables") I can't > because I actually agree with the proposal. I don't really want kgdb to > be too "special" especially when it doesn't need to be. > > Only thing to note is that rounding_up will not be manipulated within a > common spin lock so you might have to invest a bit of thought to make > sure any races between the master and slave as the slave CPU clears the > flag are benign. OK, so I've hopefully got all this thought through and posted v3. I've put most of my thoughts in the patch descriptions themselves so let's continue the discussion there. -Doug