From patchwork Thu Sep 5 11:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11132817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 663A116B1 for ; Thu, 5 Sep 2019 11:41:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BC4C20825 for ; Thu, 5 Sep 2019 11:41:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BC4C20825 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5q7T-0001gY-7K; Thu, 05 Sep 2019 11:40:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5q7R-0001Wt-Cz for xen-devel@lists.xenproject.org; Thu, 05 Sep 2019 11:40:05 +0000 X-Inumbo-ID: e3dceb6d-cfd1-11e9-abc7-12813bfff9fa Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e3dceb6d-cfd1-11e9-abc7-12813bfff9fa; Thu, 05 Sep 2019 11:39:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 926C4AE1C; Thu, 5 Sep 2019 11:39:58 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Thu, 5 Sep 2019 13:39:52 +0200 Message-Id: <20190905113955.24870-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190905113955.24870-1-jgross@suse.com> References: <20190905113955.24870-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v5 1/4] xen: fix debugtrace clearing X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" After dumping the debugtrace buffer it is cleared. This results in some entries not being printed in case the buffer is dumped again before having wrapped. While at it remove the trailing zero byte in the buffer as it is no longer needed. Commit b5e6e1ee8da59f introduced passing the number of chars to be printed in the related interfaces, so the trailing 0 byte is no longer required. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V5: - invalidate last_buf instead of last_prd after printing the buffer (Jan Beulich) --- xen/drivers/char/console.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f49c6f29a8..8df627c84a 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1166,6 +1166,8 @@ int printk_ratelimit(void) #ifdef CONFIG_DEBUG_TRACE +#define DEBUG_TRACE_ENTRY_SIZE 1024 + /* Send output direct to console, or buffer it? */ static volatile int debugtrace_send_to_console; @@ -1173,6 +1175,7 @@ static char *debugtrace_buf; /* Debug-trace buffer */ static unsigned int debugtrace_prd; /* Producer index */ static unsigned int debugtrace_kilobytes = 128, debugtrace_bytes; static unsigned int debugtrace_used; +static char debugtrace_last_entry_buf[DEBUG_TRACE_ENTRY_SIZE]; static DEFINE_SPINLOCK(debugtrace_lock); integer_param("debugtrace", debugtrace_kilobytes); @@ -1184,16 +1187,17 @@ static void debugtrace_dump_worker(void) printk("debugtrace_dump() starting\n"); /* Print oldest portion of the ring. */ - ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0); if ( debugtrace_buf[debugtrace_prd] != '\0' ) console_serial_puts(&debugtrace_buf[debugtrace_prd], - debugtrace_bytes - debugtrace_prd - 1); + debugtrace_bytes - debugtrace_prd); /* Print youngest portion of the ring. */ debugtrace_buf[debugtrace_prd] = '\0'; console_serial_puts(&debugtrace_buf[0], debugtrace_prd); memset(debugtrace_buf, '\0', debugtrace_bytes); + debugtrace_prd = 0; + debugtrace_last_entry_buf[0] = 0; printk("debugtrace_dump() finished\n"); } @@ -1241,15 +1245,14 @@ static void debugtrace_add_to_buf(char *buf) for ( p = buf; *p != '\0'; p++ ) { debugtrace_buf[debugtrace_prd++] = *p; - /* Always leave a nul byte at the end of the buffer. */ - if ( debugtrace_prd == (debugtrace_bytes - 1) ) + if ( debugtrace_prd == debugtrace_bytes ) debugtrace_prd = 0; } } void debugtrace_printk(const char *fmt, ...) { - static char buf[1024], last_buf[1024]; + static char buf[DEBUG_TRACE_ENTRY_SIZE]; static unsigned int count, last_count, last_prd; char cntbuf[24]; @@ -1264,8 +1267,6 @@ void debugtrace_printk(const char *fmt, ...) spin_lock_irqsave(&debugtrace_lock, flags); - ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0); - va_start(args, fmt); nr = vscnprintf(buf, sizeof(buf), fmt, args); va_end(args); @@ -1279,11 +1280,11 @@ void debugtrace_printk(const char *fmt, ...) } else { - if ( strcmp(buf, last_buf) ) + if ( strcmp(buf, debugtrace_last_entry_buf) ) { last_prd = debugtrace_prd; last_count = ++count; - safe_strcpy(last_buf, buf); + safe_strcpy(debugtrace_last_entry_buf, buf); snprintf(cntbuf, sizeof(cntbuf), "%u ", count); } else