From nobody Mon Mar 21 16:35:15 2022 X-Original-To: freebsd-xen@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 36E241A260EF for ; Mon, 21 Mar 2022 16:35:26 +0000 (UTC) (envelope-from prvs=07205606a=roger.pau@citrix.com) Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.hc3370-68.iphmx.com", Issuer "HydrantID Server CA O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KMgG51J09z57HQ for ; Mon, 21 Mar 2022 16:35:25 +0000 (UTC) (envelope-from prvs=07205606a=roger.pau@citrix.com) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1647880524; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=4VoKZEzqd6KygRoTSBDEPZCNcXnZ7j1E/vDDTineboE=; b=enZ6FY0sbWcuQ4iTbGlarB0ue8P0BbZJKNELkhtSf2kXXULRLPzPfmEU Lm6I/DfVvIrtFtyYRB9EhAW6EiXN09BsdDPdlUxuhdxo5tK/L7I1T/L98 jo+bl8aI3FcyaLX2PXG3JEpTaeVyIqWK7g5p4fLdXlSlvxTWTNzuxspt9 k=; X-SBRS: 5.1 X-MesageID: 66240405 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:i1fv06h9fLWeefNUXtnfRNp2X161YhAKZh0ujC45NGQN5FlHY01je htvCGrXM/2KYjD8KN8kOY+08kxSupPcmIBrHgc6/ClkFCsb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M78wIFqtQw24LhWFnU4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4tgPO JbAtRD4b7LfClHZKTBkXCF+r8bqbHtmsDY5ts2jU0dNT2CA5sQkTuRYTzrdHGeKjM2YabQQ/ Gnl7V6TnebCDwqR/X+IkNAc/nIptXNmp6jSRkaByQ/4A3LqT+z8rb1HzWRwx9bClp0sP0f2F mAtza8yrSosvm9xBOZ/2jP765OkN+k7tdYHsSDhuUcNz2poAe1Y4ZKXaGEoVkO0aqSwWdvtO OJjwYrPsx15X+UVmapoSH10w2l6zoq42+K8y7uvVLT5ejCAB4qActIgoxUNjHD7VA7gd162K VXm0qEqpt+F3r77WvAzumNcysvulu/oHIkn+JWpWdYS5EiZLhYqpFa1F9JEa0HADnx5OkcYa VT5fnnlbdrmG6hHjDkVjEF+q3uYp1zJGbKfqE6gL3a79AM90oJjXfxx6Qk7wM9HdwGOtx5Dt //Q9dVfYF1P78rhJ1GdZU8qOuMexrwqEH3QSuvyWqOLtBzB5uKke+y3IkI X-IronPort-AV: E=Sophos;i="5.90,199,1643691600"; d="scan'208";a="66240405" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYvS4egLn8aiWUowiHFNU3n1V+lSfxODJqk7Nq0I2Q0iJpW61AIV+qQQLOeXMdfSpAMtBSsswS1z1setm2lLGZg1GQ/ee/z0TdUIHxpsrv+H+Lto8eKhsqxoqBHN9u0OonkkVjuTLmUDjStlsqHPC5nn7I1LpvZ+S9IVArsQIwTqEzppV9l5/SRlISlolwLSk16pp7O2RbLAKCGmLmXy3RJKniFJBZaatIxFR7HE1so8QBXPJcSMo4331aj+K9my3aZuOFo86yyIvSwAEx6pSN8H30fcAdjRgQken8/QKmR26qR103ne5/23CM2WNHWxEsixkkqOavsCYAy7a9HtUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=45pKe3cMg46l9FVP5dLUyCg6MQOTI5AOZov18GHoSM4=; b=LrvpTg+ZqRgW9i7g6TLRsXAPffBelSyQJqYAy8obut6Tsmf3wyGE5NFVOErpRRSpIKLBhFADGSfQ8OvO6uAoWHUF0wJyIlaEqV/x7yNEsF011tGWDy+NY7ITLluKj7OsvTnYoEm6h3D6Oukyma0CXfMDq2S3LEc/65hf4/qngP71ofFjFT6ORGKMRxZFwSEPwFPsgD3gW4/ls1M0LvgHA3/TsgDtP5hls76SXmMSs07xNVWY8bjPMwlSCYhFzNvEeyTl22aS1ENMWoXKR/oFmkm6BJEYCkgPIZvMOGmUbR9U+2pEb0Sx0yq7hswGW3PI9EFRw/e2jOqhOxVACXvxmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=45pKe3cMg46l9FVP5dLUyCg6MQOTI5AOZov18GHoSM4=; b=bWO69Gqfl9aBGy4Rh7QLCXY2OxM8gPfNckBz5RtzBSPFsaEZXYDkjS8EVeRe/Wv21CJuvry21ODEcLoP8KRXkBSYhtMLvg5+gqTyGEanpdbUMIPCzOFd6w25YSBg0Hs/lDRR4qbANJkkIG41+7LEme6PINl/8hqu8DvYAxV02K0= Date: Mon, 21 Mar 2022 17:35:15 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Ze Dupsys CC: , Subject: Re: ZFS + FreeBSD XEN dom0 panic Message-ID: References: <5dfdecd5-f94d-29b4-791e-0adde5405cf5@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: LO4P123CA0195.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::20) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) List-Id: Discussion List-Archive: https://lists.freebsd.org/archives/freebsd-xen List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-xen@freebsd.org X-BeenThere: freebsd-xen@freebsd.org MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0320a9ba-3536-465e-a23e-08da0b58ca05 X-MS-TrafficTypeDiagnostic: BN6PR03MB2531:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sb/3I5RWhFpRe4Xlisk7JnPGvHGHKgduGB+r74Wy7R4/RqI9J1s/mwmdeOkopxT/SjevIOqXmlyiDKtGzKVMIw9Nd+DRyYkmPhklrnhoq3RQSzwLft7Im18Y1isQ95aU6N4+ZhHKuBBR+bgpAGKwSyusQECfoPNFhiEoPuGu2zaG28rwi8BNxjThDJR6Gr4qo1UND90aFPj4/vplyq6eJjYm8/x7o7siuuWj2INSjiDOJeCsrc0/u6J3MHXid+66OOKGbxrOpvYj/M7XfwnnkOKBrf/3O0PnukfQeGGLEq2W95BD32SiyoLQq5enUyyTzJPnm+vVLOz0enN+SzPiE9uheA/T+BD8Dqr/K+Cf9d2PLirnklBQkEjQFAgueOjX2nVnrSubOflXVUkl9yPBp1T8uWeYDr9hwFDgnmS/NkiprGaZeQToA7OrvwlNF6l8QPuN5GV+uZOPGjCZPxoSRo/h9A57GQ3LsQXBoeaXTtH8tl/pPaG3wEfxOLQvxCjN3uOBYGT7MMXpx4CBlhGcc/79hkEC6IEeR42D/jXoLHE3l8lsHD61Rp7MDVHVezkPwsgUN9hXqK0cLDfZnXhZnotiU9IQurDDjpHF4PkhtFc5QijFRmU0XjwuaAx4n6TlZT9vs7FKu5F0M/TEmEFkqw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(4636009)(366004)(26005)(186003)(83380400001)(4326008)(82960400001)(38100700002)(8936002)(6916009)(5660300002)(66556008)(66946007)(66476007)(8676002)(33716001)(2906002)(6666004)(508600001)(6506007)(316002)(9686003)(6512007)(6486002)(85182001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QWlZUFR6eXFPbTl6WXY0MkJSZlFHTHZtbGUxcExhSkVUTDRrTWpMUnVGWkRj?= =?utf-8?B?dnkwR0dWMldLRUU2eHRlL2RoSFIxNmtibUVsd1NJVGdCTDAzckNqLzhVb2M1?= =?utf-8?B?allmSnhCbXhMdHVPNVl5VWJJVWRUZGpSbzZFdDZxQVRjMFcvZS9yRFF0YjVM?= =?utf-8?B?cFZpRmMzbUNjR2hJWXRMUHJVdXpsRTFKY3hsdE52bk5tVmYxMEwrRmRFa1FW?= =?utf-8?B?WFEvQjhmcDdiS2V4VndCNWdYRVE3bFZ4b3JjZXhCUGFmMXMzUW5wNGhDOFlJ?= =?utf-8?B?cWJTamtoOHBWMWVOSHoxWnhNYkNycm9qZ1ZxUGw3aUpOLzFzYXhGUTR3eEIy?= =?utf-8?B?YU9Xd3cxNlNlckw5QjJudXgxTEN5YVZHbVRabXdoWENRVWJDczEzb2tYMFBk?= =?utf-8?B?K0tMcEJpS0dYRnZPVXgvaUZoNGcrc1lzOUNUKzA0NkNMdDlNT3F6Y05MNHI2?= =?utf-8?B?bHM3a3lSVG4zbUJGcVJOYVNjQk1Id1NFQzBNNkUrYnc3WGJOVjVkajFCNzUr?= =?utf-8?B?V2VxQjQyVDU3T2ZNSnpZbWlYSmt0VmFBcDJGKytyTm1hL29kTDZoQ0V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Tc2WUJReDZ6RXRwUUFMejZs?= =?utf-8?B?REpGYmZtckhsN2F4VmFkUjhMZ1FMUU5hd1o5TzhhVHYxb3lpYVBjM3ZlaUFa?= =?utf-8?B?Zm9Yb0NxMkU0TjFUblJtWFpUZlVMVStYQW1tUkVMK1F4SFBjL0haT3dEV2hU?= =?utf-8?B?L0RwVVhqNWJSQmM1eFpjQjlBTWs4MFZiWERzSFdDMkh1NFFQQTJkOWFtNXQy?= =?utf-8?B?QWtnM1NJWmQ1cVQrbGgxTmpkMTV1dk0ybVVTcUVUK3ZFM3dTNWtLY21Ob2Vx?= =?utf-8?B?ZVYrM1gvZWRJcVNWcmhjeGw2dXZWUnQrWTBqbkxMdHhTTm5MYjZaOS96dkpm?= =?utf-8?B?eVBPTnlWam9pd2ZIKzNhU1M0NGRFL29CK1NycEFtaTM3S1hFVFV4akNsQ3lO?= =?utf-8?B?YmFZYkoxTjdRcG9jQkxJa0FSTEg5RXlzVnoveXlUUHUzVHBQYmZmc3d1cFNR?= =?utf-8?Q?b5A3C2ETgEf9EkErMQ7UCuujkPh5hATQ?= X-MS-Exchange-CrossTenant-Network-Message-Id: 0320a9ba-3536-465e-a23e-08da0b58ca05 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 16:35:20.2147 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xv4Ovvs59Cuvd4ODmdDlgs0WDsA+W0nJuCf748U55yBp93FqFXgud6veM8dKQMtsnLssC9Ssxu1v6ynU8oUBuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2531 X-OriginatorOrg: citrix.com X-Rspamd-Queue-Id: 4KMgG51J09z57HQ X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=citrix.com header.s=securemail header.b=enZ6FY0s; dkim=pass header.d=citrix.onmicrosoft.com header.s=selector2-citrix-onmicrosoft-com header.b=bWO69Gqf; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=citrix.com; spf=pass (mx1.freebsd.org: domain of "prvs=07205606a=roger.pau@citrix.com" designates 216.71.155.168 as permitted sender) smtp.mailfrom="prvs=07205606a=roger.pau@citrix.com" X-Spamd-Result: default: False [-5.64 / 15.00]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+exists:216.71.155.168.spf.hc3370-68.iphmx.com]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; RCVD_IN_DNSWL_MED(-0.20)[216.71.155.168:from]; DKIM_TRACE(0.00)[citrix.com:+,citrix.onmicrosoft.com:+]; DMARC_POLICY_ALLOW(-0.50)[citrix.com,reject]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_COUNT_ZERO(0.00)[0]; MIME_TRACE(0.00)[0:+]; R_MIXED_CHARSET(0.56)[subject]; ASN(0.00)[asn:16417, ipnet:216.71.154.0/23, country:US]; FROM_NEQ_ENVFROM(0.00)[roger.pau@citrix.com,prvs=07205606a=roger.pau@citrix.com]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector9901:i=1]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[citrix.com:s=securemail,citrix.onmicrosoft.com:s=selector2-citrix-onmicrosoft-com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FORGED_SENDER_VERP_SRS(0.00)[]; DWL_DNSWL_LOW(-1.00)[citrix.com:dkim]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MLMMJ_DEST(0.00)[freebsd-xen]; MID_RHS_NOT_FQDN(0.50)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, Mar 21, 2022 at 04:07:48PM +0200, Ze Dupsys wrote: > On 2022.03.21. 13:14, Roger Pau Monné wrote: > > I think the problem is not likely with the xenstore implementation > > (ie: xs_talkv) but rather a race with how the FreeBSD kernel detects > > and manages addition and removal of devices that hang off xenbus. > > > > I'm afraid there's too much data below for me to parse it. > > Understood. Sounds more tricky than i thought. What could i do to make data > more useful? I have another patch for you to try. This will make the system a bit chatty, let's see what you get. Thanks, Roger. ---8<--- diff --git a/sys/dev/xen/netback/netback.c b/sys/dev/xen/netback/netback.c index bf54f3a2f28e..f49b6baa90a6 100644 --- a/sys/dev/xen/netback/netback.c +++ b/sys/dev/xen/netback/netback.c @@ -99,7 +99,6 @@ static MALLOC_DEFINE(M_XENNETBACK, "xnb", "Xen Net Back Driver Data"); #define XNB_RX_FLIP 0 /* netback driver does not support feature-rx-flip */ #undef XNB_DEBUG -#define XNB_DEBUG /* hardcode on during development */ #ifdef XNB_DEBUG #define DPRINTF(fmt, args...) \ diff --git a/sys/xen/xenbus/xenbusb.c b/sys/xen/xenbus/xenbusb.c index e026f8203ea1..767175d7174f 100644 --- a/sys/xen/xenbus/xenbusb.c +++ b/sys/xen/xenbus/xenbusb.c @@ -254,11 +254,15 @@ xenbusb_delete_child(device_t dev, device_t child) static void xenbusb_verify_device(device_t dev, device_t child) { - if (xs_exists(XST_NIL, xenbus_get_node(child), "") == 0) { + struct xenbus_device_ivars *ivars = device_get_ivars(child); + + printf("Check device %s\n", ivars->xd_node); + if (xs_exists(XST_NIL, xenbus_get_node(child), "state") == 0) { /* * Device tree has been removed from Xenbus. * Tear down the device. */ + printf("Delete %s\n", ivars->xd_node); xenbusb_delete_child(dev, child); } } @@ -454,7 +458,11 @@ xenbusb_probe_children(device_t dev) continue; } - error = device_probe_and_attach(kids[i]); + ivars = device_get_ivars(kids[i]); + printf("Trying to add dev %s\n", ivars->xd_node); + error = xenbus_read_driver_state(ivars->xd_node); + if (error != XenbusStateClosed) + error = device_probe_and_attach(kids[i]); if (error == ENXIO) { struct xenbusb_softc *xbs; @@ -509,9 +517,9 @@ xenbusb_probe_children(device_t dev) * that can receive otherend state change events, * hook up a watch for them. */ - ivars = device_get_ivars(kids[i]); xs_register_watch(&ivars->xd_otherend_watch); xs_register_watch(&ivars->xd_local_watch); + printf("Added dev %s\n", ivars->xd_node); } free(kids, M_TEMP); } @@ -907,6 +915,7 @@ xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value) case XENBUS_IVAR_STATE: { int error; + struct xs_transaction xst; newstate = (enum xenbus_state)value; sx_xlock(&ivars->xd_lock); @@ -915,31 +924,37 @@ xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value) goto out; } - error = xs_scanf(XST_NIL, ivars->xd_node, "state", - NULL, "%d", &currstate); - if (error) - goto out; - do { - error = xs_printf(XST_NIL, ivars->xd_node, "state", - "%d", newstate); - } while (error == EAGAIN); - if (error) { - /* - * Avoid looping through xenbus_dev_fatal() - * which calls xenbus_write_ivar to set the - * state to closing. - */ - if (newstate != XenbusStateClosing) - xenbus_dev_fatal(dev, error, - "writing new state"); - goto out; - } + error = xs_transaction_start(&xst); + if (error != 0) + goto out; + + error = xs_scanf(xst, ivars->xd_node, "state", NULL, + "%d", &currstate); + if (error) + goto out; + + do { + error = xs_printf(xst, ivars->xd_node, "state", + "%d", newstate); + } while (error == EAGAIN); + if (error) { + /* + * Avoid looping through xenbus_dev_fatal() + * which calls xenbus_write_ivar to set the + * state to closing. + */ + if (newstate != XenbusStateClosing) + xenbus_dev_fatal(dev, error, + "writing new state"); + goto out; + } + } while (xs_transaction_end(xst, 0)); ivars->xd_state = newstate; - if ((ivars->xd_flags & XDF_CONNECTING) != 0 - && (newstate == XenbusStateClosed - || newstate == XenbusStateConnected)) { + if ((ivars->xd_flags & XDF_CONNECTING) != 0 && + (newstate == XenbusStateClosed || + newstate == XenbusStateConnected)) { struct xenbusb_softc *xbs; ivars->xd_flags &= ~XDF_CONNECTING; @@ -949,6 +964,8 @@ xenbusb_write_ivar(device_t dev, device_t child, int index, uintptr_t value) wakeup(&ivars->xd_state); out: + if (error != 0) + xs_transaction_end(xst, 1); sx_xunlock(&ivars->xd_lock); return (error); }