From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a182850602-e5cbb570-ea26-4d45-8aed-14cb710088ba-000000@eu-central-1.amazonses.com> Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11020109.outbound.protection.outlook.com [52.101.84.109]) by lore.virtuozzo.com (Postfix) with ESMTPS id 60C4D80474 for ; Wed, 28 Oct 2026 12:38:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yPQGwDk3K4K8XGyTqu4hyYmC0jUrFNhrozAMqLsZq8VQNKvt/R4NlSI99h6uK0wrgiehwUL/J0s8trPlEBnvJtEUcOlzVOi1r1xVhJCrWL5rsc2aj+Ahp+6AMtEasHeCV4NLPON1t0UeQOlS1si/82uWAyjrL005X4WZ0LpG6jIPCutm6nfbZKLwzOcUvfXeOFqDCxxbhp6XCVD6KVE3q1vICPY8Pwhpm/zDZ45/aHneLIVz5sY/xH1fnlDxZlQXxj/agF+x45RFG81S0BHvdnpCvk8GooCZmqsOSOKrmJY7RwkZHJkLf4OpYnO5ldqCUdIOCe4lG38gUWcfg+wR8Q== 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=SXMKWsY7zBm9bhFlDGSi7+mu3WNJwOsXfvqXTVk6nfo=; b=mMnoceOh7g8bwKVmQbbRdbENxcT/SOXSBARct+z5HsBRFUIKQG6bSKcpGnmhWg7pAcLyIoEdBggek1keQ6KBRlIxzfuVO9cgpQLUHtPbrYhW1fKEqxOyHyzqbmHo2iwxWmbZuwXPaiiU3iH/1wA8UngQf7kAKpFtPnbPiT5RDGJ6DyxJW18i0aYjbcn8xXIqP/DyvLg+jsrh3ONEeQU8Ae7xyr/fWWXNSvPiHpb7adEZPdKQCxQpdy7UP0NpY26w+XVCwDzeVmjR5Sa2cgY6TCUtViUrqb3UJzndLNejmqQUKnp9WS+WxUPojTtpavHuvUd6sndp40JhCD32A3Te2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.6) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=eu-central-1.amazonses.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=amazonses.com; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SXMKWsY7zBm9bhFlDGSi7+mu3WNJwOsXfvqXTVk6nfo=; b=gvbPLB2eVxIzOtxgkTp2fFbQAnIonIc3iP7F90sIea3V5yp0Q+py+JrxqoLYy3+9Mffb00FHPewja/+uIM0LaIcgUVFuOV9tGRNN1dqPMirvMnjQHIZpE9Z4nFfaQirfgBFzE3P4FQCcUho0FMddumymb2BG6hMiyxOyfMMEKfU= Received: from DU2PR04CA0285.eurprd04.prod.outlook.com (2603:10a6:10:28c::20) by CPJPR08MB603896.eurprd08.prod.outlook.com (2603:10a6:380:20c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.546.22; Wed, 28 Oct 2026 12:38:39 +0000 Received: from DU2PEPF00028D0B.eurprd03.prod.outlook.com (2603:10a6:10:28c:cafe::a5) by DU2PR04CA0285.outlook.office365.com (2603:10a6:10:28c::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.546.22 via Frontend Transport; Wed, 28 Oct 2026 12:38:39 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.6) smtp.mailfrom=eu-central-1.amazonses.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com;dkim=pass (signature was verified) header.d=amazonses.com;dmarc=pass action=none header.from=sashiko.virtuozzo.com; Received-SPF: Pass (protection.outlook.com: domain of eu-central-1.amazonses.com designates 69.169.224.6 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.6; helo=b224-6.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-6.smtp-out.eu-central-1.amazonses.com (69.169.224.6) by DU2PEPF00028D0B.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.546.15 via Frontend Transport; Wed, 28 Oct 2026 12:38:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1793191118; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Hw9P94GWwQfZOW0EcTUF2nZmJsyP+2TIHKtIreEQBGY=; b=iS4+2CsP3M/RPtqvCN4otlsLOI1X7J2CBuH/O0RHZmAdg2xNaCh/pCgLoKHxldWx rHTuKepJt7vtPb5Pr829N9eVSf27xD0cVoJoG58rbUSO5Dw2Tk0yfv4TgpSx1N6Yx1T G+YAlLF2I4WbMMwFDBNRHZ7ofwTtvycTtSXx6EdldLYgcaFrt/zQnFmdCwSEdIadjRp NDDCN6M9OQ/r7VvtDldikCIpJoMTn9/aKpOwyKCq+4uZQquLDjHjhJ9MkauITOcKsyu wG3GGM1mIaxH9uIN8Cxkk3H0iVsR1xE1c/GdFz1DSWE0ui4hsoNdsvYqUNaybvAQfil +ygjeOpYPg== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1793191118; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=Hw9P94GWwQfZOW0EcTUF2nZmJsyP+2TIHKtIreEQBGY=; b=ZjzGr40DcBK3KUfu9UbH1uWffMskpupmVTI9L44RJkxeij+QX6uhlOrCkzNPdld4 5MnVPA5fERMQTPCy6Rvc1Bzg2e2umHwk8LM1gpTMS6K12CduaWmEmxHvJXppEvPdkAi YoiYz9rTOo+U0t7fek3i9paY3Wbg8pqzx4FURiLk= Message-ID: <010701a182850602-e5cbb570-ea26-4d45-8aed-14cb710088ba-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH hci-8.1 v3 3/4] vhost-blk: create kernel threads with the mainstream worker ioctls To: Alexander Ivanov , andrey.zhadchenko@virtuozzo.com Cc: andrey.drobyshev@virtuozzo.com, svt-core@virtuozzo.com In-Reply-To: <20261028123333.3145676-4-alexander.ivanov@virtuozzo.com> References: <20261028123333.3145676-1-alexander.ivanov@virtuozzo.com> <20261028123333.3145676-4-alexander.ivanov@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Oct 2026 12:38:38 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.10.28-69.169.224.6 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0B:EE_|CPJPR08MB603896:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 9077f64c-4523-4af9-a503-08df34f0644c X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|704161411799003|48200799018|376014|32142699015|61400799027|9140799003|261026140227099003|4143699003|5023799004|56012099006|5063699009|261022105027099003|261009223027099003|261009221227099003|261022075727099003|261021121427099003|10067099003|55112099003|4113699003|18092099006|18002099003|261026121527099003|6133799003|5113699003|22082099003|16102099003; X-Microsoft-Antispam-Message-Info: b6amyZFeX5fG5bIP94ldidR0kyfvbVSMGGymcIwVcH2Sd6Dh15Oemxg6+1fMoK8DuuwRxgZX8Awt+8lCDOy5T1trBJCoSTuqdwj61Vzmh7amE+sQfHKxcjSUcDTM6plaoeT7tlPjCVgLp676Zo1rp+n1ve7G41pTqgtOZ1v1LnIJRYEbOeNCFmGvIpV1P0JoIVLHPD4E0IKnBfEFzujZlU+YQQ+7BdYzpuf1J3is9KpqofLNYKYIWceHBzhvWfxWZTWdJ9zcm9x/AB2M2+DMrLVE44mibaZRJ5mryuiFB6HlxXIcDjp9fe++wkScMqaTyZ1rfa0TjWzA4Z6J/Jm0+fSEjIVhkqzpH00KCJKOMn1z5h82voLMMDgaicwKnQA2t3Ent11HKTjs1H2m7GInY8nyh5FNiskaVy+Ey/hbpIlqEY457Ba2Sxutub+spPm9JlM3t6PpViKkMo227cHI3uKyvUQcg19bfGxZSpSEBNO4bRMfWTQOZAxoaMOwHWvDqzzvTuSFTeqkfRd6LNKRbtVRkXt2SNPW2bKgPYDH/HDMm+wuvJqeagwPtlkeYtDfswMnlMsjgr4viyWjq4+i1Kqmcqg+tlkkB74ZcC37c53q7qJgrfjo54IbzxsYwiMuXpkREyaIK1DyJTK7P+QLRr4uLyblvORA+phPDsbNvwBAJ+ssax9c8Zjh5OkKMYR5fSpCAqvCTQPkMDOS4uID3kQEIGU4i0mGvHAIolncuxAoWuGJSSQq1prFA/mR6IuQWmncf83Icb8/XfmGBVBgERUtg0Dss9zuh/0GSJFe3oU8unNKWHbPZZJCTZFD/BR/hAdyBr83ZvAwbxSRvmrz/MjtONEhTfE/CGoLe/qWLZ6gQaopX3njrFLGNpb9IHe9sKPfq3ERYdkmmz8X+XI6e+Xt/pPujq6RdQExA8nFgmE= X-Forefront-Antispam-Report: CIP:69.169.224.6;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-6.smtp-out.eu-central-1.amazonses.com;PTR:b224-6.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(704161411799003)(48200799018)(376014)(32142699015)(61400799027)(9140799003)(261026140227099003)(4143699003)(5023799004)(56012099006)(5063699009)(261022105027099003)(261009223027099003)(261009221227099003)(261022075727099003)(261021121427099003)(10067099003)(55112099003)(4113699003)(18092099006)(18002099003)(261026121527099003)(6133799003)(5113699003)(22082099003)(16102099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DnuUcgT0PfEOnKEEAbNMjnBGIRceHTK/hkVk9LIdo3WN01A2Fp6D8NhhOsxLYBFFIW6meJDJk3FEWMNy0MN5Mv66dx9iA+iP9xTE8/HxYe1WgxgrAu/m6hLG5oDHiuFlYsrztL/52jCUJZWBf7Ku9umImcaoJJ3xx79OvwtbUwH3pG5EfbHgSjbuYcHNavksB1yI4nvXS9CpUQRJYWlNoZQT7h/JXWAX/izZc8JbkW/ZTzyMJorsGgd5QCrBlX7v7nKktacpuK0tFUpGSH3oDHbbeNCqvAfTaMu5kKqbL3dTg7Hk5d4JxpOV3YFVYgzSGg+AeUKbWVcM4+X58EIrE5RNJ6uW+2zQr8+T9Jyz83Psw6Xjowv/WA0GpfXgftPpx3X6MBdoXpvBbA8IbVWuHS7sBCaw/J8YzTdMI8Gs1mxP3qH2YtjPveJe3yJxXaIp X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2026 12:38:38.8557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9077f64c-4523-4af9-a503-08df34f0644c X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D0B.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: CPJPR08MB603896 Thank you for your contribution! Sashiko AI review found 3 potential issue(= s) to consider: - [Medium] vhost-blk: single-thread fallback only handles -ENOTTY from unkn= own vhost ioctls - [Low] vhost-blk: ENOTTY worker fallback leaves device in vhost_task mode - [Low] vhost-blk: num-threads=3D0 silently accepted as a single kernel thr= ead -- commit bce7b559a829ea8e18f3184e167eeedc9027e77f Author: Alexander Ivanov vhost-blk: create kernel threads with the mainstream worker ioctls This patch replaces the VHOST_SET_NWORKERS ioctl with VHOST_NEW_WORKER and VHOST_ATTACH_VRING_WORKER. It creates num-threads - 1 workers and attaches them to the virtqueues round-robin. It also switches the device to vhost_task mode with VHOST_SET_FORK_FROM_OWNER before VHOST_SET_OWNER. If the kernel lacks these ioctls, it warns and runs a single thread. Link: https://virtuozzo.atlassian.net/browse/VSTOR-107537 > diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c > --- a/hw/block/vhost-blk.c > +++ b/hw/block/vhost-blk.c [ ... ] > +static int vhost_blk_set_workers(struct vhost_dev *hdev, int nworkers) > +{ [ ... ] > + ret =3D hdev->vhost_ops->vhost_new_worker(hdev, &worker); > + if (ret =3D=3D -ENOTTY) { > + /* vhost-blk predating worker ioctls, fails on vq 1 only= */ > + warn_report_once("vhost-blk: kernel does not support wor= ker " > + "ioctls, using a single kernel thread"); > + return 0; > + } else if (ret < 0) { > + error_report("vhost-blk: unable to create kernel thread:= %s", > + strerror(-ret)); > + return ret; > + } [Severity: Medium] Is -ENOTTY the only errno an older kernel can return here? The fallback to a single thread is taken only for an exact -ENOTTY from vhost_blk_set_workers()->vhost_new_worker(). Any other errno goes through error_report() and fails vhost_blk_start(). The same applies in vhost_blk_start() to the result of vhost_set_fork_from_owner(): ret =3D hdev->vhost_ops->vhost_set_fork_from_owner(hdev, VHOST_FORK_OWNER_TASK); if (ret =3D=3D -ENOTTY) { ... nworkers =3D 1; } else if (ret < 0) { error_report("vhost-blk: unable to set vhost task mode: %s", ...); return ret; Both go through vhost_kernel_call(), which returns the raw -errno from ioctl(). The comment in vhost_kernel_set_features() says that for unknown vhost ioctls the kernel interprets the argument as a virtio queue id and most likely errors out validating that id, instead of reporting an unknown operation. If VHOST_SET_FORK_FROM_OWNER falls through to the vring ioctl handler on a kernel without it, could the result be -ENOBUFS instead of -ENOTTY? In that case the commit message promise to "warn and run a single thread rather than fail to start vhost-blk" would not hold when num-threads > 1. The commit message also notes that VHOST_NEW_WORKER fails with -EFAULT in kthread mode, so the errno is not uniform across kernel configurations. I couldn't check the kernel side, so this is based on the in-tree comment. > + } > + > + return 0; > +} [ ... ] > + nworkers =3D MIN(s->conf.num_threads, hdev->nvqs); > + if (nworkers > 1) { [Severity: Low] If num-threads is 0, nworkers becomes 0 here, so both nworkers > 1 blocks are skipped. Doesn't vhost_blk_start() then silently run a single kthread with no diagnostic? The old code passed num_threads to VHOST_SET_NWORKERS whenever it was not 1, and failed with -EINVAL if that ioctl failed. vhost_blk_device_realize() validates num_queues but not num_threads, and the num-threads property is a DEFINE_PROP_UINT16 with a default of 1 and no range check. Should num-threads=3D0 be rejected at realize time, or is the silent fallba= ck intended? The commit message doesn't mention this change in behaviour. > + /* > + * VHOST_NEW_WORKER needs vhost_task mode; our kernel defaults to > + * kthreads and VHOST_RESET_OWNER brings that default back, so a= sk > + * on every start. Must precede VHOST_SET_OWNER. > + */ > + ret =3D hdev->vhost_ops->vhost_set_fork_from_owner(hdev, > + VHOST_FORK_OWNE= R_TASK); [Severity: Low] On a released vz10 kernel that has VHOST_SET_FORK_FROM_OWNER but whose vhost-blk lacks the worker ioctls, this call succeeds and switches the device to vhost_task mode. Later, vhost_blk_set_workers() gets -ENOTTY from vhost_new_worker() on vq 1, warns, and returns 0. Does anything restore VHOST_FORK_OWNER_KTHREAD on that path? The fallback then runs one thread in vhost_task mode, while num-threads=3D1 runs one thr= ead in kthread mode. The commit message says "With num-threads=3D1 nothing changes: no worker ioctls, kthread mode", but the fallback case isn't described as differing from it. Is that difference intended? I couldn't confirm from this tree whether task mode matters for vhost-blk on those kernels. > + if (ret =3D=3D -ENOTTY) { > + warn_report_once("vhost-blk: kernel does not support vhost t= asks, " > + "using a single kernel thread"); > + nworkers =3D 1; > + } else if (ret < 0) { [ ... ] --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/2026102812333= 3.3145676-1-alexander.ivanov@virtuozzo.com?part=3D3