From patchwork Fri May 22 14:55:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 187155 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2579595ilb; Fri, 22 May 2020 07:55:16 -0700 (PDT) X-Received: by 2002:a1c:2843:: with SMTP id o64mr13481908wmo.158.1590159316218; Fri, 22 May 2020 07:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590159316; cv=none; d=google.com; s=arc-20160816; b=Ey/RnooWyLHrr2pWm1ulWEXccHQFl2NUafJZaBCFrDu4ERah0Y4roKFS2l+svfX3E/ QwfwY82z4KIluGQun0VgKFrdd/bOPIYpMmjoj3EZnk+k6LbJ4lFVmJ0Kf+MBvz+/IXkH tYWgkd/y/Sb7sunynxXm5POn7YuvltYSsbfN2t6WkAcld5YAcHij6LWRmqbbLw+zMmFZ xDKrIQDpwe36DNOp46K5ZMzV2LkYcFza0No/G44Rx926TuXUA1ne5Kg5PSk8c5q8HqNL kvvTgf23R7+mP4GA5SAT1imxSBHupq3Bskzf/DD/AOUH/0gfWcSMzFXYNFzmUqGqNQnt V2Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Z2JTvHuqFiAH+e0uHvAv7QUdItZgp1++hBsH29TGAGE=; b=t4xPWGQnwu57CKAYdG4rOt+Wc6Ry6OSNrjaoyROuMbmxU5bMv93xKuLLaYXztv9yw0 6cO7iEkkgX/hOJM1rgVvoONFRg8nb27eBviJIn8pfy/fj6cyBZAf2w/oVqjVNfK50n4f KQzfhb2AO/xw0IQyEHPNq9ISAkjJiMOoxs7KTG7+PcmhRDATYW7MKniWHlFAeStDIXpk jbG1CIJiQDo7IuyYMP0g3syMd3d6CXqAuYjQnSmHGLb7pmx7M85cq+xNgAXchZPeWllq 7eKsdtUab5+niW4jw+zvfGJlXoR+NJ0Mxye/K1q4gmORsr3GhIbsXPq9fa3uplCwrHCA 2Sug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RH3hJubU; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h13sor404884wre.23.2020.05.22.07.55.16 for (Google Transport Security); Fri, 22 May 2020 07:55:16 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RH3hJubU; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z2JTvHuqFiAH+e0uHvAv7QUdItZgp1++hBsH29TGAGE=; b=RH3hJubUWGtSNW24GhTx6ufaJ6TRraOrbbB6edaZ1SxjVy3F3fER9ye7M9DV2/koq2 WolLZoTDKPlKaRDouJvsUsCVShp5GvsPjxVf/vBlD/kFDBl2QP/5obzIUP+C/DliXKFe vWBbx3oaBCHHqGyG00lPrlsfgZua0ucfU7gneN0OBBm88TXXdm3WRzT32ng9qk+9ZzFh UvzEk05phTl5Vurl2f8gX/swSGoyVuEc8AtTZnZIAfWIo53XvjMUP16u91mtv7nQ5Dsd C/dtaKrFdXg8UuWpnXiR/uEA3LADGd0mTIdfzp1TkIHIRHLFSVWLPTxxG9wU5PP1z82f I9EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2JTvHuqFiAH+e0uHvAv7QUdItZgp1++hBsH29TGAGE=; b=iPDtHh0tIznFNY7TmtcWb2kEQqTTua9dLucTw9eHwVepI0y9EFwP3qwjastBLGaAkP BizPjjxVMzwDA+jDKXPPYAGuS1JsoLlpjc7N6m2L3lMX9JR4T4DQ9Fi9RRXpn13tivL2 jcY1s6Zx6/keXdwtLKRzaMmsRw4mfflq2j4I3wFZDZDH3Y1WcY42/Yslmu3TXTKTtw/x T2Fw1Gl1Pz+DlkSdajXoHCM/lmApeCAi8ZMPAluwhREAWL639N0T6wer3YMIRkqCSl1/ uAF9XpyaA1LtriN9iXDGgkGPt2A01CtA1zTUMhwv234Rt5LvfK6kNW33OJJ0W7IDbNQ9 FsFA== X-Gm-Message-State: AOAM531KrKDXZO1nFNDDaHknBeUH1hok98ggMLREOwTTPxD+DkwKi1BM eltjMJfFej12HEKmi8yf22EEfPG0 X-Google-Smtp-Source: ABdhPJzVBNmBWWvQ9nOtr1g+uNGIt9/otWbCh5kkWpEi6Kn9nuax/sD2PRXbA3VTqgPQqIPvlzBrKA== X-Received: by 2002:adf:eb08:: with SMTP id s8mr3721175wrn.361.1590159315732; Fri, 22 May 2020 07:55:15 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id i21sm9746911wml.5.2020.05.22.07.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 07:55:15 -0700 (PDT) From: Daniel Thompson To: sumit.garg@linaro.org, jason.wessel@windriver.com, dianders@chromium.org Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, Peter Zijlstra , Ingo Molnar , Will Deacon Subject: [RFC PATCH 1/2] debug: Convert dbg_slave_lock to an atomic Date: Fri, 22 May 2020 15:55:09 +0100 Message-Id: <20200522145510.2109799-2-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200522145510.2109799-1-daniel.thompson@linaro.org> References: <20200522145510.2109799-1-daniel.thompson@linaro.org> MIME-Version: 1.0 Currently the debug core takes and releases dbg_slave_lock, knowing it to be uncontended, as a means to set and clear a flag that it uses to herd the other cores in to or out of a holding pen. Let's convert this to a regular atomic instead. This change is worthwhile simply for the subtle increase in clarity in a very tangled bit of code. It is also useful because it removes a raw_spin_lock() from within the debug trap, which will make it easier to introduce spin lock debugging code for the debug trap handler. Signed-off-by: Daniel Thompson --- kernel/debug/debug_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.4 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 2b7c9b67931d..8f43171ddeac 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -121,12 +121,12 @@ static struct kgdb_bkpt kgdb_break[KGDB_MAX_BREAKPOINTS] = { atomic_t kgdb_active = ATOMIC_INIT(-1); EXPORT_SYMBOL_GPL(kgdb_active); static DEFINE_RAW_SPINLOCK(dbg_master_lock); -static DEFINE_RAW_SPINLOCK(dbg_slave_lock); /* * We use NR_CPUs not PERCPU, in case kgdb is used to debug early * bootup code (which might not have percpu set up yet): */ +static atomic_t slaves_must_spin; static atomic_t masters_in_kgdb; static atomic_t slaves_in_kgdb; static atomic_t kgdb_break_tasklet_var; @@ -615,7 +615,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, dump_stack(); kgdb_info[cpu].exception_state &= ~DCPU_WANT_BT; } else if (kgdb_info[cpu].exception_state & DCPU_IS_SLAVE) { - if (!raw_spin_is_locked(&dbg_slave_lock)) + if (!atomic_read(&slaves_must_spin)) goto return_normal; } else { return_normal: @@ -677,7 +677,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, * CPU in a spin state while the debugger is active */ if (!kgdb_single_step) - raw_spin_lock(&dbg_slave_lock); + atomic_set(&slaves_must_spin, 1); #ifdef CONFIG_SMP /* If send_ready set, slaves are already waiting */ @@ -741,7 +741,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, dbg_io_ops->post_exception(); if (!kgdb_single_step) { - raw_spin_unlock(&dbg_slave_lock); + atomic_set(&slaves_must_spin, 0); /* Wait till all the CPUs have quit from the debugger. */ while (kgdb_do_roundup && atomic_read(&slaves_in_kgdb)) cpu_relax();