From patchwork Mon Sep 9 07:35:53 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: 11137377 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 C97BA76 for ; Mon, 9 Sep 2019 07:37:30 +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 AE74B21A4C for ; Mon, 9 Sep 2019 07:37:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE74B21A4C 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 1i7EDS-00053F-K2; Mon, 09 Sep 2019 07:36:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7EDR-000539-DW for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 07:36:01 +0000 X-Inumbo-ID: 77f7be9e-d2d4-11e9-a337-bc764e2007e4 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 77f7be9e-d2d4-11e9-a337-bc764e2007e4; Mon, 09 Sep 2019 07:36:00 +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 7D50CAC67; Mon, 9 Sep 2019 07:35:59 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 09:35:53 +0200 Message-Id: <20190909073557.16168-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909073557.16168-1-jgross@suse.com> References: <20190909073557.16168-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v6 1/5] 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) V6: - instead of moving last_buf to file scope use a boolean for buffer invalidation (Jan Beulich) --- xen/drivers/char/console.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f49c6f29a8..11e1db5684 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1173,6 +1173,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 bool debugtrace_buf_empty; static DEFINE_SPINLOCK(debugtrace_lock); integer_param("debugtrace", debugtrace_kilobytes); @@ -1184,16 +1185,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_buf_empty = true; printk("debugtrace_dump() finished\n"); } @@ -1241,8 +1243,7 @@ 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; } } @@ -1264,8 +1265,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,8 +1278,9 @@ void debugtrace_printk(const char *fmt, ...) } else { - if ( strcmp(buf, last_buf) ) + if ( debugtrace_buf_empty || strcmp(buf, last_buf) ) { + debugtrace_buf_empty = false; last_prd = debugtrace_prd; last_count = ++count; safe_strcpy(last_buf, buf);