Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754670AbbGPJL2 (ORCPT ); Thu, 16 Jul 2015 05:11:28 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:35129 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753929AbbGPJL0 (ORCPT ); Thu, 16 Jul 2015 05:11:26 -0400 Subject: Re: [PATCH 1/3] nmi: create generic NMI backtrace implementation To: Russell King , linux-arm-kernel@lists.infradead.org, x86@kernel.org References: <20150715203911.GF7557@n2100.arm.linux.org.uk> Cc: linux-kernel@vger.kernel.org From: Daniel Thompson Message-ID: <55A7753C.9020708@linaro.org> Date: Thu, 16 Jul 2015 10:11:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1930 Lines: 52 On 15/07/15 21:39, Russell King wrote: > +void nmi_trigger_all_cpu_backtrace(bool include_self, > + void (*raise)(cpumask_t *mask)) > +{ > + struct nmi_seq_buf *s; > + int i, cpu, this_cpu = get_cpu(); > + > + if (test_and_set_bit(0, &backtrace_flag)) { > + /* > + * If there is already a trigger_all_cpu_backtrace() in progress > + * (backtrace_flag == 1), don't output double cpu dump infos. > + */ > + put_cpu(); > + return; > + } > + > + cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask); > + if (!include_self) > + cpumask_clear_cpu(this_cpu, to_cpumask(backtrace_mask)); > + > + cpumask_copy(&printtrace_mask, to_cpumask(backtrace_mask)); > + > + /* > + * Set up per_cpu seq_buf buffers that the NMIs running on the other > + * CPUs will write to. > + */ > + for_each_cpu(cpu, to_cpumask(backtrace_mask)) { > + s = &per_cpu(nmi_print_seq, cpu); > + seq_buf_init(&s->seq, s->buffer, NMI_BUF_SIZE); > + } > + > + if (!cpumask_empty(to_cpumask(backtrace_mask))) { > + pr_info("Sending NMI to %s CPUs:\n", > + (include_self ? "all" : "other")); > + raise(to_cpumask(backtrace_mask)); On ARM, this code could be running with IRQs locked and with raise() implemented using IRQs. In such as case the IPI will not be raised until the function exists (and perhaps never). Thanks to the timeout we will exit but we end up needlessly failing to print a backtrace for the calling CPU. The solution I used for this was to special case the current CPU and call nmi_cpu_backtrace() directly. Originally I made this logic arm only but I can't really see any reason for this to be arch specific so the logic to do that should probably be included here. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/