From nobody Mon Feb 9 19:06:50 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1567604840; cv=none; d=zoho.com; s=zohoarc; b=Q8/9H1Fqa0yZwHO7hgsQ2xyrJ0tGL5JEuGkCwGLPaJckMG48sVwFDd4Q1IopnSaeWqJzYbcN/J8ufc/fIYui1UNYnpLpEf11JBlmXVrl99dOEGW0Y0iLmP8Zz8P8lfnUiwQgcq31RbeAHjm/ZbKalxFOUpxEilKEbpWWD6jHwzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567604840; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ejj43W73NdIl8zCSW55Di0fJUW/7662vrx+azO0qU3Y=; b=X//aUeaqucmGcQg6rq9GXrwrINgSsU7rIUl6DgIBEfEmSDVOWK8xEN/joSo9TPaKIRa4WpCucoB0C3OU/qfl6xSNoOVFFW8huhArAy3p3zb49LtkHKBvTCs7IkxQj92J4Xo7j9o6qqJPnNZDesmq8uKjcOLA+OywL0D53gm1vJo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1567604840525964.9008181300559; Wed, 4 Sep 2019 06:47:20 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5Vbz-0003mT-6u; Wed, 04 Sep 2019 13:46:15 +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 1i5Vbx-0003m9-Mt for xen-devel@lists.xenproject.org; Wed, 04 Sep 2019 13:46:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5b664722-cf1a-11e9-abb6-12813bfff9fa; Wed, 04 Sep 2019 13:46:12 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C802AAF25; Wed, 4 Sep 2019 13:46:11 +0000 (UTC) X-Inumbo-ID: 5b664722-cf1a-11e9-abb6-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 4 Sep 2019 15:46:07 +0200 Message-Id: <20190904134608.18425-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190904134608.18425-1-jgross@suse.com> References: <20190904134608.18425-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v4 3/4] xen: refactor debugtrace data 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" As a preparation for per-cpu buffers do a little refactoring of the debugtrace data: put the needed buffer admin data into the buffer as it will be needed for each buffer. While at it switch debugtrace_send_to_console and debugtrace_used to bool and delete an empty line. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V4: - renamed struct debugtrace_data_s (Jan Beulich) - renamed debtr_data (Jan Beulich) - remove unneeded condition (Jan Beulich) - recalc debugtrace_bytes (Jan Beulich) --- xen/common/debugtrace.c | 65 ++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/xen/common/debugtrace.c b/xen/common/debugtrace.c index 506aee9418..8fa0e7fb0e 100644 --- a/xen/common/debugtrace.c +++ b/xen/common/debugtrace.c @@ -15,35 +15,41 @@ #include =20 /* Send output direct to console, or buffer it? */ -static volatile int debugtrace_send_to_console; +static volatile bool debugtrace_send_to_console; =20 -static char *debugtrace_buf; /* Debug-trace buffer */ -static unsigned int debugtrace_prd; /* Producer index */ -static unsigned int debugtrace_prd_last; -static unsigned int debugtrace_kilobytes =3D 128, debugtrace_bytes; -static unsigned int debugtrace_used; +struct debugtrace_data { + unsigned long bytes; /* Size of buffer. */ + unsigned long prd; /* Producer index. */ + unsigned long prd_last; + char buf[]; +}; + +static struct debugtrace_data *dt_data; + +static unsigned int debugtrace_kilobytes =3D 128; +static bool debugtrace_used; static DEFINE_SPINLOCK(debugtrace_lock); integer_param("debugtrace", debugtrace_kilobytes); =20 static void debugtrace_dump_worker(void) { - if ( (debugtrace_bytes =3D=3D 0) || !debugtrace_used ) + if ( !debugtrace_used ) return; =20 printk("debugtrace_dump() starting\n"); =20 /* Print oldest portion of the ring. */ - if ( debugtrace_buf[debugtrace_prd] !=3D '\0' ) - console_serial_puts(&debugtrace_buf[debugtrace_prd], - debugtrace_bytes - debugtrace_prd); + if ( dt_data->buf[dt_data->prd] !=3D '\0' ) + console_serial_puts(&dt_data->buf[dt_data->prd], + dt_data->bytes - dt_data->prd); =20 /* Print youngest portion of the ring. */ - debugtrace_buf[debugtrace_prd] =3D '\0'; - console_serial_puts(&debugtrace_buf[0], debugtrace_prd); + dt_data->buf[dt_data->prd] =3D '\0'; + console_serial_puts(&dt_data->buf[0], dt_data->prd); =20 - memset(debugtrace_buf, '\0', debugtrace_bytes); - debugtrace_prd =3D 0; - debugtrace_prd_last =3D 0; + memset(dt_data->buf, '\0', dt_data->bytes); + dt_data->prd =3D 0; + dt_data->prd_last =3D 0; =20 printk("debugtrace_dump() finished\n"); } @@ -68,7 +74,6 @@ static void debugtrace_toggle(void) =20 spin_unlock_irqrestore(&debugtrace_lock, flags); watchdog_enable(); - } =20 void debugtrace_dump(void) @@ -90,9 +95,9 @@ static void debugtrace_add_to_buf(char *buf) =20 for ( p =3D buf; *p !=3D '\0'; p++ ) { - debugtrace_buf[debugtrace_prd++] =3D *p; - if ( debugtrace_prd =3D=3D debugtrace_bytes ) - debugtrace_prd =3D 0; + dt_data->buf[dt_data->prd++] =3D *p; + if ( dt_data->prd =3D=3D dt_data->bytes ) + dt_data->prd =3D 0; } } =20 @@ -106,10 +111,10 @@ void debugtrace_printk(const char *fmt, ...) unsigned long flags; unsigned int nr; =20 - if ( debugtrace_bytes =3D=3D 0 ) + if ( !dt_data ) return; =20 - debugtrace_used =3D 1; + debugtrace_used =3D true; =20 spin_lock_irqsave(&debugtrace_lock, flags); =20 @@ -128,14 +133,14 @@ void debugtrace_printk(const char *fmt, ...) { if ( strcmp(buf, last_buf) ) { - debugtrace_prd_last =3D debugtrace_prd; + dt_data->prd_last =3D dt_data->prd; last_count =3D ++count; safe_strcpy(last_buf, buf); snprintf(cntbuf, sizeof(cntbuf), "%u ", count); } else { - debugtrace_prd =3D debugtrace_prd_last; + dt_data->prd =3D dt_data->prd_last; snprintf(cntbuf, sizeof(cntbuf), "%u-%u ", last_count, ++count= ); } debugtrace_add_to_buf(cntbuf); @@ -153,7 +158,8 @@ static void debugtrace_key(unsigned char key) static int __init debugtrace_init(void) { int order; - unsigned int kbytes, bytes; + unsigned long kbytes, bytes; + struct debugtrace_data *data; =20 /* Round size down to next power of two. */ while ( (kbytes =3D (debugtrace_kilobytes & (debugtrace_kilobytes-1)))= !=3D 0 ) @@ -164,12 +170,15 @@ static int __init debugtrace_init(void) return 0; =20 order =3D get_order_from_bytes(bytes); - debugtrace_buf =3D alloc_xenheap_pages(order, 0); - ASSERT(debugtrace_buf !=3D NULL); + data =3D alloc_xenheap_pages(order, 0); + if ( !data ) + return -ENOMEM; =20 - memset(debugtrace_buf, '\0', bytes); + bytes =3D PAGE_SIZE << order; + memset(data, '\0', bytes); =20 - debugtrace_bytes =3D bytes; + data->bytes =3D bytes - sizeof(*data); + dt_data =3D data; =20 register_keyhandler('T', debugtrace_key, "toggle debugtrace to console/buffer", 0); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel