From patchwork Thu Nov 6 15:27:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 40321 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4DA3320C4E for ; Thu, 6 Nov 2014 15:27:32 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf809262wid.8 for ; Thu, 06 Nov 2014 07:27:29 -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=IgG4XbHyEaB1F64TexpHMoHykMmW+Zx+VVnDMiCF0Lo=; b=hRv4H+JVgJ7EcTqF3YyJc6+l4ix3GhcHxs3A9Kbht0kS/72aa9CbLl0T6yjd+539jb Et3/ZABfzUI55TCto+KjGCZzWtOdHs3K62NEVnh9HaHPOs+IonSdQTy8ChoumyHnFZZQ Rsp4IKZ/J5FbsxXhKB1xJ4CBLqno+fFPlfxQ3aE3bIHWWNl6Shd87a9ujhqq+kb29rSG 04KQgt9ms71iLinkYr5V+AU5kTuGMeNDubrBrZT64ThpeRvrRdXXtDGzjYkna/v/yrmT cjjRC8GI+KdK8oPE7yDnLt19M+NEjV4Tf+6qYQrbE70+Tk8BGSkHC5WYlMouemBUos/t mOIQ== X-Gm-Message-State: ALoCoQlTiha28kQeDRJEXqRiC/CEMF23GL2jDlMe83iQUl+DCLJ8cVH/irJgEIQXG3vrJ2gHUHBc X-Received: by 10.112.180.71 with SMTP id dm7mr92661lbc.18.1415287649316; Thu, 06 Nov 2014 07:27:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.225 with SMTP id bb1ls79168lab.47.gmail; Thu, 06 Nov 2014 07:27:29 -0800 (PST) X-Received: by 10.153.6.9 with SMTP id cq9mr5537669lad.79.1415287649088; Thu, 06 Nov 2014 07:27:29 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id y9si11810163lal.60.2014.11.06.07.27.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 07:27:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id 10so1105334lbg.35 for ; Thu, 06 Nov 2014 07:27:29 -0800 (PST) X-Received: by 10.152.120.199 with SMTP id le7mr5473509lab.67.1415287648989; Thu, 06 Nov 2014 07:27:28 -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.184.201 with SMTP id ew9csp61554lbc; Thu, 6 Nov 2014 07:27:28 -0800 (PST) X-Received: by 10.180.19.234 with SMTP id i10mr42915627wie.28.1415287648382; Thu, 06 Nov 2014 07:27:28 -0800 (PST) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com. [209.85.212.182]) by mx.google.com with ESMTPS id gg7si20286283wib.11.2014.11.06.07.27.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 07:27:28 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.182 as permitted sender) client-ip=209.85.212.182; Received: by mail-wi0-f182.google.com with SMTP id d1so1825471wiv.15 for ; Thu, 06 Nov 2014 07:27:28 -0800 (PST) X-Received: by 10.181.13.20 with SMTP id eu20mr41519740wid.36.1415287648126; Thu, 06 Nov 2014 07:27:28 -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 dw9sm8712079wib.0.2014.11.06.07.27.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Nov 2014 07:27:27 -0800 (PST) From: Daniel Thompson To: Jason Wessel Cc: Daniel Thompson , linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Andrew Morton , Ingo Molnar , patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal Subject: [RESEND PATCH 3.18-rc3] kdb: Avoid printing KERN_ levels to consoles Date: Thu, 6 Nov 2014 15:27:06 +0000 Message-Id: <1415287626-25802-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1411555097-16924-1-git-send-email-daniel.thompson@linaro.org> References: <1411555097-16924-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.217.176 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 when kdb traps printk messages then the raw log level prefix (consisting of '\001' followed by a numeral) does not get stripped off before the message is issued to the various I/O handlers supported by kdb. This causes annoying visual noise as well as causing problems grepping for ^. It is also a change of behaviour compared to normal usage of printk() usage. For example -h ends up with different to that of kdb's "sr h". This patch addresses the problem by stripping log levels from messages before they are issued to the I/O handlers. printk(), which is used as an I/O handler for logging purposes, is handled as a special case; if the caller provided a log level then this will be preserved. Signed-off-by: Daniel Thompson Cc: Jason Wessel --- Notes: This patch is tested both on arm (kgdboc=ttyAMA0) and x86_64 (kgdboc=kdb,ttyS0). kernel/debug/kdb/kdb_io.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- 1.9.3 diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 7c70812..381f297 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -691,19 +691,22 @@ kdb_printit: * Write to all consoles. */ retlen = strlen(kdb_buffer); + cp = kdb_buffer; + if (cp[0] == KERN_SOH_ASCII && cp[1] != '\0') + cp += 2; if (!dbg_kdb_mode && kgdb_connected) { - gdbstub_msg_write(kdb_buffer, retlen); + gdbstub_msg_write(cp, retlen - (cp - kdb_buffer)); } else { if (dbg_io_ops && !dbg_io_ops->is_console) { - len = retlen; - cp = kdb_buffer; + len = retlen - (cp - kdb_buffer); + cp2 = cp; while (len--) { - dbg_io_ops->write_char(*cp); - cp++; + dbg_io_ops->write_char(*cp2); + cp2++; } } while (c) { - c->write(c, kdb_buffer, retlen); + c->write(c, cp, retlen - (cp - kdb_buffer)); touch_nmi_watchdog(); c = c->next; } @@ -711,7 +714,10 @@ kdb_printit: if (logging) { saved_loglevel = console_loglevel; console_loglevel = CONSOLE_LOGLEVEL_SILENT; - printk(KERN_INFO "%s", kdb_buffer); + if (cp == kdb_buffer) + printk(KERN_INFO "%s", kdb_buffer); + else + printk("%s", kdb_buffer); } if (KDB_STATE(PAGER)) {