[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH Hyperlaunch] xenconsole: Add connected flag


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Tue, 17 Dec 2024 17:24:24 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L8xuwI0/yejCLIWz0+Qwjv4SG6qlHBSVP/vH0Ki1GMQ=; b=o1OsAFj71hsGW7QcXlLRZmIB4yGeS0MD0or7ECPyzxlCox9fedJ4+FrWhP6Gl4/T4plFOFBHP0lJAzZsWMo7E4cpVN5TBV2Fv66Z58PG4Y/uKTCjrQ2z9R6IxDI0GW3GbX1p5pVSHfAxvpHL2+2ZrVbI3q2JT7AmYLwHz4oxM+k6Pl5iY77kQxPfXyrFMNndbuGAU01iioS3htoeT/L575Mq07I3yhCxjCEcJ54hWLjjUisAJn+3TH2PpVMrOWRESpUFNyzs8qRIf96hIg4ENNuV3dG+O5xAcHoWHuNHEFN5mBxgPMH6j2gM3GgZlb4Ti3FRqziYNKs9UtSzadxG0Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TJthO2heabp6ruxHX3uxtScD71O0mcMnc4ky6o7UfG0y/bip+7NHFdaNQto9d9/iiupH1PARUvNU87AlewG5qLcjxGKO4VDqYI6/jvmGAafVlybmmTJtVIuWipySkMVLkk1BBA3bc11YhqJeUzcF2dCs7lFFhQxZ6TWqLE6V/Cg5aamfjSue0RUoh/wZ0csD+vQq8WErVYQ6ZX65KZxNRtCVSkvucUR1TPC+TQddPFpUgIFysX/WxsunK8Q0YnHh9Wh7LJbi7Sz8hSH9s7mMxlzMo/ZW0Y0AmswZ11LqUsQ3YhdAtzRvG3bqXQJkFH7CzmPu3cNP1220pgzMyHCSzA==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Tue, 17 Dec 2024 22:25:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Linux will spin in hvc_xen.c:domU_write_console() when it fills its
console ring.  This blocks hyperlaunch parallel boot since the domU
won't progress until dom0 sets up xenconsoled and starts draining the
ring.

Add a flag to the console ring page.  zero-initialized, have xenconsoled
set to 1 when it connects.  Also send an event channel notification.

The linux domU side can keep using the console hypercalls and only
transition to the ring when it is connected and won't fill and block.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
In domU_write_console(), __write_console returns 0 when the ring is
full.  This loops spins until xenconsoled starts emptying the ring: 

        while (len) {
                ssize_t sent = __write_console(cons, data, len);

                if (sent < 0)
                        return sent;

                data += sent;
                len -= sent;

                if (unlikely(len))
                        HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
        }

This patch is similar to the xenstore late init (though the flag is
reversed).

The idea of the event channel notification is to let the domU receive an
indication that xenconsoled is connected.  For xenstore, the xenstore
driver owns the event channel/irq and can rebind it.  For hvc_xen, the
hvc subsystem owns the irq, so it isn't readily available for rebinding.

I had the idea for the kernel to use a static key and switch writing
from the hypercall to the PV ring once connected.  It didn't actually
work in my short attempt - I think changing the static key from within
an interupt was wrong.  I fell back to just checking the flag directly
without an optimization.  That would work and would make the event
channel notification unnecessary.

 tools/console/daemon/io.c       | 6 ++++++
 xen/include/public/io/console.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index bb739bdb8c..2a7ecc6369 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -731,6 +731,9 @@ static int console_create_ring(struct console *con)
                con->ring_ref = ring_ref;
        }
 
+       /* Mark the console as connected */
+       con->interface->flag = XENCONSOLE_CONNECTED;
+
        /* Go no further if port has not changed and we are still bound. */
        if (remote_port == con->remote_port) {
                xc_evtchn_status_t status = {
@@ -780,6 +783,9 @@ static int console_create_ring(struct console *con)
        if (log_guest && (con->log_fd == -1))
                con->log_fd = create_console_log(con);
 
+       /* spurious notify to check flags field */
+       xenevtchn_notify(con->xce_handle, con->local_port);
+
  out:
        return err;
 }
diff --git a/xen/include/public/io/console.h b/xen/include/public/io/console.h
index 4509b4b689..2b408f92a3 100644
--- a/xen/include/public/io/console.h
+++ b/xen/include/public/io/console.h
@@ -19,6 +19,8 @@ struct xencons_interface {
     char out[2048];
     XENCONS_RING_IDX in_cons, in_prod;
     XENCONS_RING_IDX out_cons, out_prod;
+    #define XENCONSOLE_CONNECTED 1
+    uint32_t flag;
 };
 
 #ifdef XEN_WANT_FLEX_CONSOLE_RING
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.