From patchwork Wed Jan 7 16:15:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 42837 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B1882055F for ; Wed, 7 Jan 2015 16:16:17 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf838798wgg.0 for ; Wed, 07 Jan 2015 08:16:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mC1cX71NTMo8CjSBY53jUQRL81MJG0d4mFF3NG1Vgwg=; b=ExVA8C2+llOGxUrQifOceVO3yDGbV76UEVwGFda2JiORB/pBLz87Tfs5x4dMq54zYf G8XO6pNnbFVMgxDjAF9eHTmX/dTBWXGfuaBm/mAe2XOVJJtJsjI5ofzGv5J4vE2Tymex zd7NCrjnbzLd+8bd06/AjB8IxQxYhf8rBHLFjpyMwG1CjSB8StjrNuWQDFZ3HKbDsrLo Wc0dqSwbhLWVdCdkI6kWPWviGRyh/ZvaynbQddVmZXhV6SViKS2IUdTDUquja51xGvlS x7qNVBS4GRwFawjz2WcjiSOdAzBOKI2esF/uiYzBG+f+zicFaNGnCmJAaKrWhk3cEXw9 0e8g== X-Gm-Message-State: ALoCoQmRpsqVFgoh2qJbGLoPqsMVeGlUeBiX9AEZHe32Li7n9ZSgdPJukvrXZ3JgOk/ZLmw6umHR X-Received: by 10.112.55.105 with SMTP id r9mr8392lbp.23.1420647376573; Wed, 07 Jan 2015 08:16:16 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.73 with SMTP id o9ls175957laj.65.gmail; Wed, 07 Jan 2015 08:16:16 -0800 (PST) X-Received: by 10.112.134.37 with SMTP id ph5mr5928780lbb.27.1420647376436; Wed, 07 Jan 2015 08:16:16 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id mr10si3717495lbb.61.2015.01.07.08.16.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 08:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so4334220lab.13 for ; Wed, 07 Jan 2015 08:16:16 -0800 (PST) X-Received: by 10.112.159.136 with SMTP id xc8mr5948416lbb.98.1420647375983; Wed, 07 Jan 2015 08:16:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1530953lbb; Wed, 7 Jan 2015 08:16:15 -0800 (PST) X-Received: by 10.152.27.228 with SMTP id w4mr5921533lag.75.1420647375264; Wed, 07 Jan 2015 08:16:15 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com. [209.85.212.178]) by mx.google.com with ESMTPS id c6si6046021wix.107.2015.01.07.08.16.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 08:16:14 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id em10so1954114wid.11 for ; Wed, 07 Jan 2015 08:16:14 -0800 (PST) X-Received: by 10.180.126.99 with SMTP id mx3mr8992162wib.66.1420647374519; Wed, 07 Jan 2015 08:16:14 -0800 (PST) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id fp2sm18403432wib.8.2015.01.07.08.16.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jan 2015 08:16:13 -0800 (PST) From: Daniel Thompson To: Jason Wessel Cc: Daniel Thompson , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal , Mike Travis , Randy Dunlap , Dimitri Sivanich , Andrew Morton , Borislav Petkov , kgdb-bugreport@lists.sourceforge.net, Ingo Molnar Subject: [RESEND PATCH v3 3.19-rc2] kgdb: Timeout if secondary CPUs ignore the roundup Date: Wed, 7 Jan 2015 16:15:58 +0000 Message-Id: <1420647358-8901-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1415728232-9954-1-git-send-email-daniel.thompson@linaro.org> References: <1415728232-9954-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently if an active CPU fails to respond to a roundup request the CPU that requested the roundup will become stuck. This needlessly reduces the robustness of the debugger. This patch introduces a timeout allowing the system state to be examined even when the system contains unresponsive processors. It also modifies kdb's cpu command to make it censor attempts to switch to unresponsive processors and to report their state as (D)ead. Signed-off-by: Daniel Thompson Cc: Jason Wessel Cc: Mike Travis Cc: Randy Dunlap Cc: Dimitri Sivanich Cc: Andrew Morton Cc: Borislav Petkov Cc: kgdb-bugreport@lists.sourceforge.net Cc: Ingo Molnar --- Notes: Jason: v2 of this patch is already integrated into kgdb-next. It's probably best to nuke v2 and replace it with this patch. However I can easily provide a diff of v2 versus v3 if you prefer. Just ask... v3: * Fix an out-by-one error in kdb_cpu(). * Replace NR_CPUS with CONFIG_NR_CPUS to tell checkpatch that we really want a static limit (Jason Wessel). * Removed the "KGDB: " prefix from the pr_crit() in debug_core.c (kgdb-next contains a patch which introduced pr_fmt() to this file to the tag will now be applied automatically). v2: * Set CATASTROPHIC if the system contains unresponsive processors (Jason Wessel) kernel/debug/debug_core.c | 9 +++++++-- kernel/debug/kdb/kdb_debugger.c | 4 ++++ kernel/debug/kdb/kdb_main.c | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) -- 1.9.3 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 1adf62b39b96..f21580b347cc 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -471,6 +471,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, int cpu; int trace_on = 0; int online_cpus = num_online_cpus(); + u64 time_left; kgdb_info[ks->cpu].enter_kgdb++; kgdb_info[ks->cpu].exception_state |= exception_state; @@ -595,9 +596,13 @@ return_normal: /* * Wait for the other CPUs to be notified and be waiting for us: */ - while (kgdb_do_roundup && (atomic_read(&masters_in_kgdb) + - atomic_read(&slaves_in_kgdb)) != online_cpus) + time_left = loops_per_jiffy * HZ; + while (kgdb_do_roundup && --time_left && + (atomic_read(&masters_in_kgdb) + atomic_read(&slaves_in_kgdb)) != + online_cpus) cpu_relax(); + if (!time_left) + pr_crit("Timed out waiting for secondary CPUs.\n"); /* * At this point the primary processor is completely diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c index 8859ca34dcfe..15e1a7af5dd0 100644 --- a/kernel/debug/kdb/kdb_debugger.c +++ b/kernel/debug/kdb/kdb_debugger.c @@ -129,6 +129,10 @@ int kdb_stub(struct kgdb_state *ks) ks->pass_exception = 1; KDB_FLAG_SET(CATASTROPHIC); } + /* set CATASTROPHIC if the system contains unresponsive processors */ + for_each_online_cpu(i) + if (!kgdb_info[i].enter_kgdb) + KDB_FLAG_SET(CATASTROPHIC); if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) { KDB_STATE_CLEAR(SSBPT); KDB_STATE_CLEAR(DOING_SS); diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 379650b984f8..0c1dc7fa2e58 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2157,6 +2157,8 @@ static void kdb_cpu_status(void) for (start_cpu = -1, i = 0; i < NR_CPUS; i++) { if (!cpu_online(i)) { state = 'F'; /* cpu is offline */ + } else if (!kgdb_info[i].enter_kgdb) { + state = 'D'; /* cpu is online but unresponsive */ } else { state = ' '; /* cpu is responding to kdb */ if (kdb_task_state_char(KDB_TSK(i)) == 'I') @@ -2210,7 +2212,7 @@ static int kdb_cpu(int argc, const char **argv) /* * Validate cpunum */ - if ((cpunum > NR_CPUS) || !cpu_online(cpunum)) + if ((cpunum >= CONFIG_NR_CPUS) || !kgdb_info[cpunum].enter_kgdb) return KDB_BADCPUNUM; dbg_switch_cpu = cpunum;