Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4182378ooa; Tue, 14 Aug 2018 02:16:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzpFR8xdX0JkxCxhmQMpaRFxk/VVzqADP6p6MqVI0l2PTObow5zqnv5sU/qAcaK46dkQW13 X-Received: by 2002:a17:902:82c7:: with SMTP id u7-v6mr19537288plz.83.1534238164453; Tue, 14 Aug 2018 02:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534238164; cv=none; d=google.com; s=arc-20160816; b=bvOu6F/GVqAn88UIKatLm5ArzQfmKpPtsBTMNTpqPc+mZJDvVWlaxcYT84Bggd807c Uz/UtVSQnZYMqOKdPlbsouG3cj/dTg6kE/SRRMo2hGmMzkzJWU/Cz3QnAg8xhuAskNUr onZmltbQP0GhADbzrZ+dJkYYnnM5N9oMhgZ8Y4uKbru4SQ9AsBZa1R5xI8EZoyKkigjE sGK0NeF5dDHs7T7ZLE4JcIzY/2j9xtNUmihgtMFZu9knxA59yyhwwV6lcNXm0X9laNes dE3JujrTL4Pi5QIJhgdvmVAOAaxU4VqDnYVf1UTZ73FkphusgDRLO4cQCYWjD57AIrTI FqVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :arc-authentication-results; bh=LFSme6AsICYRC/LE+I7AB2qvXr2qjDPGNNcMTsTJ7Ig=; b=WYrNNDcZ6U8ugQEhyelg+UVslftzRKyc6VFdDrLmG8xCj9Xm844LMCDc5DLxFjVOpp n2ptLE82H++32TMAwcsalRUZwlErcflNzyxubhoF99W1Fd7XUUaHO5mdkDbk8EyYIxK5 riGC6MgH4tOoGathFr11UethB5i86vntyuxQ4k0PN5YmAzzkohn92NKBTIyh/z+Xh/rV AVZB+GafrtDcYxOm0WoYYn/i/cFHy1jcUa7oH0LYctthtn1SAxJLxTCGaL2HOKPLi3Ep TpNzY9nwzs8CIJEGOOvSdg9E6OU7ntv4OdTw3HexQyTAIotLHNkSqyhbBxNO6/LYRQ9Y Bzbg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e10-v6si20366709pgm.94.2018.08.14.02.15.48; Tue, 14 Aug 2018 02:16:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731738AbeHNLpf (ORCPT + 99 others); Tue, 14 Aug 2018 07:45:35 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:5542 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730119AbeHNLpf (ORCPT ); Tue, 14 Aug 2018 07:45:35 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 41qRNj0zpdz9tvS7; Tue, 14 Aug 2018 10:59:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id CfH2yf6B64wX; Tue, 14 Aug 2018 10:59:17 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 41qRNj0HW5z9tvS6; Tue, 14 Aug 2018 10:59:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1C59D8B79E; Tue, 14 Aug 2018 10:59:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 9LaiquW4z4NU; Tue, 14 Aug 2018 10:59:19 +0200 (CEST) Received: from pc16082vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DF7D98B74B; Tue, 14 Aug 2018 10:59:18 +0200 (CEST) Received: by pc16082vm.idsi0.si.c-s.fr (Postfix, from userid 0) id DB05871283; Tue, 14 Aug 2018 08:59:18 +0000 (UTC) Message-Id: <718cc9c9bd1d4bb2b4c2596f1a7ee00334e77055.1534192631.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH 1/2] powerpc/process: fix nested output in show_user_instructions() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , muriloo@linux.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 14 Aug 2018 08:59:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When two processes crash at the same time, we sometimes encounter nesting in the middle of a line: [ 4.365317] init[1]: segfault (11) at 0 nip 0 lr 0 code 1 [ 4.370452] init[1]: code: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX [ 4.372042] init[74]: segfault (11) at 10a74 nip 1000c198 lr 100078c8 code 1 in sh[10000000+14000] [ 4.386829] XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX [ 4.391542] init[1]: code: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX [ 4.400863] init[74]: code: 90010024 bf61000c 91490a7c 3fa01002 3be00000 7d3e4b78 3bbd0c20 3b600000 [ 4.409867] init[74]: code: 3b9d0040 7c7fe02e 2f830000 419e0028 <89230000> 2f890000 41be001c 4b7f6e79 This patch fixes it by preparing complete lines in a buffer and printing it at once. Fixes: 88b0fe1757359 ("powerpc: Add show_user_instructions()") Cc: Murilo Opsfelder Araujo Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/process.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 913c5725cdb2..c722ce4ca1c0 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1303,32 +1303,33 @@ void show_user_instructions(struct pt_regs *regs) { unsigned long pc; int i; + char buf[96]; /* enough for 8 times 9 + 2 chars */ + int l = 0; pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int)); - pr_info("%s[%d]: code: ", current->comm, current->pid); - for (i = 0; i < instructions_to_print; i++) { int instr; if (!(i % 8) && (i > 0)) { - pr_cont("\n"); - pr_info("%s[%d]: code: ", current->comm, current->pid); + pr_info("%s[%d]: code: %s\n", current->comm, current->pid, buf); + l = 0; } if (probe_kernel_address((unsigned int __user *)pc, instr)) { - pr_cont("XXXXXXXX "); + l += sprintf(buf + l, "XXXXXXXX "); } else { if (regs->nip == pc) - pr_cont("<%08x> ", instr); + l += sprintf(buf + l, "<%08x> ", instr); else - pr_cont("%08x ", instr); + l += sprintf(buf + l, "%08x ", instr); } pc += sizeof(int); } - pr_cont("\n"); + if (l) + pr_info("%s[%d]: code: %s\n", current->comm, current->pid, buf); } struct regbit { -- 2.13.3