From patchwork Tue Dec 7 02:51:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B6A9C433EF for ; Tue, 7 Dec 2021 02:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbhLGCzF (ORCPT ); Mon, 6 Dec 2021 21:55:05 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44836 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbhLGCzB (ORCPT ); Mon, 6 Dec 2021 21:55:01 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5HmN012536; Tue, 7 Dec 2021 02:51:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=JGPKg5pR9JfEbo2Vntm8ShT4Bu7HYXnrVufWNfM16FQ=; b=Hlxki2aXLB9Fha7e3KM8dueLE5RzPkLQmg9lgfg8dGI1E40l+a4Af+/N/YVwTj9A4ADV G/qfalP/rdoqMNv3yvVT5tIvax/21o+nei1o0o2cQ+M8l30buDzZaq2cmgJ70EK8SsHJ UFZsen6s/upEEqclcSWpdTjYOg2kqi/uyzPmnnjBFUAF3gxduR7MrgodfokxPR8EoQXI +O0B0bZi6bGCJ21BmD0FT5pQVG51voIW1znr1SUm7ryJ0s28t9Fw8227ufEh02Be5eyA j+KF00Uegp1EhxNBNvmleRGM2auxYCMYzHo2tDb0lwmGdPC6WyiiYmEbQujHMWNsuc3J nQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csc72c354-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:28 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglW153019; Tue, 7 Dec 2021 02:51:27 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iswVlnbeV87E4HdLfchAiU4m1jSHmDx2ZCCF9FRRI37ht9oDOoAKOJO3yC8LHI8pndMpYZmWrfTZUXiqRSlNy54GFmdLgqDiUd7f7uSwinEWmIxzdjBdgEsO2mjWAGS9SfndnF0Nj4epZZaEY2z5GsNCA0rBMq9Ph/IPe7JGYn/O+I/6CdRsPqHYcsdEsCy+IrG04L87VRVt189iqZKB9cTFU7V28INzqbVWvzZ5JGdWac4Q3HbAaLLCFbt6P5EYIGeNvZN0JJOSZTyiSmb03uJqkCDhcXAELI087/vbJL4+N/Fi5WEgmuDqBfNSXyXR5XJDGR16P+YxttAYGRDIVg== 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=JGPKg5pR9JfEbo2Vntm8ShT4Bu7HYXnrVufWNfM16FQ=; b=DXJk8GXZx92Tgtl7bgtNeE38r9QMsZUj+Qy1jexsbwgEMNzEGYSHDb0xe8hg5tdZufCKKxcN+klS5VaQ4cntcOrtCxU0NwyH0bi8gN1l8VMxV8rvGztLRYDwbT7Dhve5rZw0brLs7o9HnIsyFi9dGAW62ldejpYSo8cGqnBXNMrleLW6Ne8yptRY59R+VM/DLLWBc3YnJ+qJg9yY9VvOrWVF/lLXzbbEwyOdbLPTz5dUuKOMlQERrsb37INYHBIv1YQM5CCiO4LCb4ObZhfvzW74+P2qohZQqcizQBfw1nrMpn/46LSskCJZBHfUu6kV0No63sLkc0LIJEkgB4YdpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JGPKg5pR9JfEbo2Vntm8ShT4Bu7HYXnrVufWNfM16FQ=; b=nqCqS5WsUUc7Ys3l/KJ+e/5+BJTiS8apoYHlnssWKeYjh4vUobWPExabRu3zmT8O6lUk2xHWpYUjTncReIUKM72inVufw1+Tx8Lokbml8TIKuNcnA3HoTESEOty8fMRjIFyyEYui8Vhm2tyBqXyFk4udZzgH2gMVgRVvSTYqBIA= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:25 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 01/12] vhost: add vhost_worker pointer to vhost_virtqueue Date: Mon, 6 Dec 2021 20:51:06 -0600 Message-Id: <20211207025117.23551-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec105093-91f9-4111-51e2-08d9b92c75ec X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +eLMtsR4jlP3KJxT6hH6qK44zkjyyoz9rGUP8MaBhsGOLyNksDFz7835u/rB6ckar4WgHzgjD8/Ls5U10Tfrg2Ns8mhDkN2Xn/+8uqSGc7VzVt9a3CBNReQLhynHWs0wehOJiW/inY2raZe82wKnWbR9Etku7JeBO0X44DzLuPXt9SRWGqi+rDXvW5g3WJqhX6BpAmKVAtSX+lnK5+go1bsVFWo6oKQeq3T0Ay6ILkDtTfC5MUoEYEfL+UeOlB11eanqip0RNfsQWDGMjr8PnZlLuHbpwR0YpndQTUKZI21tvLFlduMOq7WvZbCVGFb8D5gUpX6kz9XDF1+0S7wiP5PFlZmKXrXjpKf8liuFRnIK+yNBEfJWznTvCAhi0bh13XujF5VqLd5rZrWyzTFnyXFammbqUP3cGxQ4DzQk5N8R4tQU2+jDjoaeRBJweT40OIrpMbvStEXETZ/n3/CUzvmkzsefXDzWa+hPQE2FnfejOIEUx8AG0A6LZV2ZuWCYom/794gJT6OiRwaedwnxT2hXkHvJ+GMgmU/QhjKC4m4Qplk99NoBsgTyHn/ki7apn4GiXs85wfxzzvScp/cN70q63friUNPyuTb1YXCNmiTncS+NWhgbTgMHynWcbaPweq5OgDC4G5vD8Z43MjNSOFGtcQHecllFsDEZAfZQ6COvBZAQwgL25i3DiU+At0Mlfm1CFniOCBKKUKdIDBoQ+A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mo73JLi7lKwodgHCMMFjw67t/mjSIugC/Wpc3U0UpREiysK88VAUFtgYPupX/+oiEZ1DrNAxiXRkXM3IRTdEFzLBPxYeeUmmzwFnF2gQrVpGtNlCFN1p7SKiL29AQql2JSgZNTAdZWCuxkwlUDz8buw1sU1lmDDLm5NSXf+TEfm0Q4th2UawG6b8ioFG0tsi2rB/86+0JZ35ill6WmhiOJpQsxaUYBsdbFbmfBsOZYOeQE7XJ83dJU8Lt+feDfB4C2Fd06DQTllrm9DDAdi3vrKLJc/dnbjv2flTnzU2wWPKDhlmoLkpd8DD6gT7R4jgSVypc8C6wrUPRYhzZSsTE4OUoGNMVlCxVPdiWbFCY2XGXHICV1W5QGtutd9tXdcwrgOl95jekOOW7MNotq+RHAvzt17M8/oElBjxDcB0SG1EyeN1rSXGa+00wxTwSlZ7zB3vCEUgHQuPEA+ZDYBqRuCM3DgsHDPoM9no7oV8xVblvRi86aebGDq+8CosP8N+UPq1GP+HpZqGnO/SU1NkMo/W5UGY/B49EIzJW3ScLC56sGn9U2L3wHgmeeB2m0kfQ0PNgq5HKk8qN9pJpClN08ge69pNzp+K7CfVTRoF7HNyA4esM/NVtb2NFeot0wecmoYAttZVym4PBOgIBMSKrjorxHznhlOsSuBfumqAEgsQNfDkGzrKKsYxe7dFIgZ0MNUNbThioEu/VTBaJbMJAmtIs3nz16Ti3f1CZ52fiPmNAJgq+3jAiyxhQyPgEsoqC4RWHWqcp/7CIt5sRr9m7suBKSB4F0zUPfUZNCQ0oEvi6j0usxY4O3YwigIQrqIYc9kTe7EYhqlfJFanHbxK39llMZdMFXMkLGntU73ub9j6SFm3UyFTDIw1DAWxr9jVzwO/hWFVKdyyVyUaxHAohNNjdLgJaig/ucbgPkCnbSBJlS0q1mmme6C1xE0PREMtrzIh18yOWv2/DEHd1Owv2mllKdKQacbGqxPDKVxoHL2uDMvMM204nT6DTh1B7C6kqegG11bGoOlp+jaZXOFQTiRx4hrI5zXFO7gCFCHWn92pEyp/iefRbk+0SdWkDVcCjYBeUmZ4FXa0KjahU7EY3A8KMSodtaKIkAhEw+0npariDUK3KOCuRB1OnDeGOOz76rlS2AyUskfxfZ2njYFaMF59XJ813chp/W6ZJxt13WVPl00Kf9bodInRkp5rn41DN5rsZj1K8Hogm8EKU+3e5laZXzQB+rXGwxyvCJI771t7qEvlIiiZtvpZANt3woQNPIIKKtyD3aVTagX5tAD8Z4t6piEK8VpAkD+hZD2AKdwp9PGpgKfz/4v2BuBGqDB0Xlkbgkpfy086VQfAriIVjVLJWpi4tNC+vZFIiAIPA9iuu+QNyFnQt26tCXATgTKi/jdiF8iMtXQrJv/9EXH2E72/zVt/MTJOzfDf6K+SOAH2GykWeFxDUupPR/Qg7jQoXBz6J2uU0XVk496tITBn8aPUkstzz/Pv2UArRH9teUr3nh58siBqS0FRe/FIsL8zjf65OxQWkf+k6Y7K5Y/QaBMeu4JxhrJowAXMGvMY4bxQSxYbKHjh/dnZrJYVAPsOvmq+91fPS9jXcpJwE72g6vVhrtpYtWBuxcjeqIdq7eo7IRHm0O1FTv1Sl7LcGxtb2h6yT5RVLDagYJ9aJTgZSg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec105093-91f9-4111-51e2-08d9b92c75ec X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:25.9126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sUANM54RfDT47YhRppwo2TqAOFn1SRrCL4yk4wNJcDYuMhlxa1i9Bvfv/N1HT3iYb6eUDlCjKv7/i+nz5RHeleHLy5a7wb4MUJHguJGNfag= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-ORIG-GUID: uk7zEP5tgM5C29OZuVq-uOWDQaPALIXx X-Proofpoint-GUID: uk7zEP5tgM5C29OZuVq-uOWDQaPALIXx Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patchset allows userspace to map vqs to different workers. This patch adds a worker pointer to the vq so we can store that info. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 24 +++++++++++++----------- drivers/vhost/vhost.h | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 17e5956e7424..a314f050413a 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -488,6 +488,7 @@ void vhost_dev_init(struct vhost_dev *dev, vq->log = NULL; vq->indirect = NULL; vq->heads = NULL; + vq->worker = NULL; vq->dev = dev; mutex_init(&vq->mutex); vhost_vq_reset(dev, vq); @@ -566,15 +567,14 @@ static void vhost_worker_free(struct vhost_dev *dev) kfree(worker); } -static int vhost_worker_create(struct vhost_dev *dev) +static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) { struct vhost_worker *worker; struct task_struct *task; - int ret; worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT); if (!worker) - return -ENOMEM; + return NULL; dev->worker = worker; worker->kcov_handle = kcov_common_handle(); @@ -586,25 +586,24 @@ static int vhost_worker_create(struct vhost_dev *dev) */ task = user_worker_create(vhost_worker, worker, NUMA_NO_NODE, CLONE_FS, USER_WORKER_NO_FILES | USER_WORKER_SIG_IGN); - if (IS_ERR(task)) { - ret = PTR_ERR(task); + if (IS_ERR(task)) goto free_worker; - } worker->task = task; user_worker_start(task, "vhost-%d", current->pid); - return 0; + return worker; free_worker: kfree(worker); dev->worker = NULL; - return ret; + return NULL; } /* Caller should have device mutex */ long vhost_dev_set_owner(struct vhost_dev *dev) { - int err; + struct vhost_worker *worker; + int err, i; /* Is there an owner already? */ if (vhost_dev_has_owner(dev)) { @@ -615,9 +614,12 @@ long vhost_dev_set_owner(struct vhost_dev *dev) vhost_attach_mm(dev); if (dev->use_worker) { - err = vhost_worker_create(dev); - if (err) + worker = vhost_worker_create(dev); + if (!worker) goto err_worker; + + for (i = 0; i < dev->nvqs; i++) + dev->vqs[i]->worker = worker; } err = vhost_dev_alloc_iovecs(dev); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 67b23e178812..31d074724fe8 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -79,6 +79,7 @@ struct vhost_vring_call { /* The virtqueue structure describes a queue attached to a device. */ struct vhost_virtqueue { struct vhost_dev *dev; + struct vhost_worker *worker; /* The actual ring of buffers. */ struct mutex mutex; From patchwork Tue Dec 7 02:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 800DBC2BA4C for ; Tue, 7 Dec 2021 02:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231830AbhLGCzH (ORCPT ); Mon, 6 Dec 2021 21:55:07 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44990 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbhLGCzB (ORCPT ); Mon, 6 Dec 2021 21:55:01 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M56v3019273; Tue, 7 Dec 2021 02:51:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=mm+tnd27I62PkwCFrmS0IZJOW/0jGEC/8voBbiTgtAM=; b=qnz8NTnWvUzPhqwFMURsk4IYuTBrFa7H2PsarOK7UhVac4bzWyk+Pjwsnz5yAXL2855q f9jNY9aqQInHVpUfCjPDFddHCFEqioBlMTls/TBBNJV3ta6PUVOhx+p6idXAyC/e8uUZ 030C390IvOJG6ZEhg28/wJGsKPTI1QWqR9n9HrsdfqVGB77MF2X8jJQsH9s7i4QTL6TU C33JAxULhLuC7jQh1CBGX0zjnfl2xEsd8xgRSPtFVg2auoRGYQtOcKGb8e96g95VbYg0 SjhIWNAAlS9YGWzFUze67N+9+nBK0shL5R4KZjdJScVMRFldVMx7vukNzccvi5Z2JfI1 /w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqmef9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:29 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglX153019; Tue, 7 Dec 2021 02:51:28 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vg81HeVUoEmV3HM0OhKJTdECzUjzKoxtmsY/Rz1r4Gkp6saWSE2vLImSwiAvTmgk55KrW4H0kfSrUmcP57mRxwSBrLrQPC/BHYIsO283/1uenwC/PcM7x57v28pVUkhPJypGGKXPeuRgWJbhItgIpWqVSg/Zf0wFqGC2yUv9EDIK365ZKsoQYo3vcLIMjUrjuQVlbLbVmIYcw+KwnR9KaLfc2Ts6BYdImJa1DjzkJaZ5ucUuUr9IXoATdjUyqkVzPX8LVvLmIBDou4gOGDPRExTU4tuWy8ObKfmzkLkG4en/s0xS4Hlin/sQw5tFlY5k+U7VNJo7Ms1eHhE7cT1xUw== 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=mm+tnd27I62PkwCFrmS0IZJOW/0jGEC/8voBbiTgtAM=; b=U7BSDhJglvyiCHC1lUEvvP/iGbICX7wdvqZqizmEjMkOuugnS93bcjAH8BJTXBgmfJQIrp7FYJ4AcT2tdSuSoouOfOYnA0cGME3wmezgfb1cbKpCx7ApBXYD7jeP4va3nuthaIZS9VAOOEOuKgC3eIXdraPY0orF43y0rhRIGZpIYpNx2hoJhKzmIDYNjOBSjiTC/tiky1AJ6HPxQc82OeKDYSyrKNn6sJMptzhIgWe60NmVWl03Qq8EPOeRDnT2EWrPFupzB60tUaSv15m0ldO1e8Ljm+c+Z29Q12GuVfLCF6Kbmx2LtEm7Zg36U64jn332UYLI55QvJZgCYhwjlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mm+tnd27I62PkwCFrmS0IZJOW/0jGEC/8voBbiTgtAM=; b=FGSiQV9UrzJa30MX6Ezz10t80W+v8fVPtCpiIw1eTnfla+G2RDP3hBq+zxsx/Id3iLvav80wCUCPPMt6GRBEwXa9i33ERGxfkxZPKYuQuzIpIiKmD4wJHrsvuy59e8UDTY8neHt9Z3NY4TpDfHhHf45FpYrXcPvrweGg2JmqHFE= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:26 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 02/12] vhost, vhost-net: add helper to check if vq has work Date: Mon, 6 Dec 2021 20:51:07 -0600 Message-Id: <20211207025117.23551-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de5552e4-6c14-4095-aed0-08d9b92c762c X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9R7cr696L5PzYkRTVkR+n+pw0c4t5BTRPVrlqq4lTGcIYuj51yGsihClK8LtoXgNhn4mXSSI/O/wUaA6QMBBlkeW7feID8DKrBvRlaj/hStx2dW5qMcnrzzvsAsJMl0bx9+hL8UOx55WjJtgOZzPYbHN0M4AgWj8JLVtY3dWFtyFrDGh7fD+fCvXJ1+YNpF0LOjdwkSVoYVS3+2HyJXSYR7huahBYymB7jX51ZMLN+MZXNjaPPBkyLUdvWOpfJmqIlzMfk37pLaLeWyyBV9Nex4jDmdNdts8Kcme5iHAtwYCPOBUYW2DP1NSypyEibrZt3wSGx+naWt4aC2+19PMKNExl/8vmuQyYThZNAzzEOE6fkKUjdbFSk3QEZDZpMjyg+PdWUafMMtKykhqRKpqq7LCaIA76g8VmImiYCY/9qxgQk2SkyOFxMuJJZ2oCQUgiB+VDJN7G7G833OdGrMXCLyeA6OqZjZJ6wUBsCWTDlm0pQewTFaAD4hbl84vEcGLJ66uaaAlv+AyPg1XalF/zwHrB2icFTlUy9fvGRSlOUBlMG7PeEGF0BDFDJOpcqKSTYt2WCEKQZkqiUOqpUpJIRIPMk1yRCqhLFUL3+iCmMXCA55UWhznRcLX7o3DPlvOnMYNIshJK1us2DmgloDCpmDmhn2fKTdr5RjdJzOS4iVnVCPBvBcfcfNG00494fysnEifAA24ITW1Uq7DwTNqow== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VhLc5srRCAa8WaFlFhji3XfW7fwnYwOqc8PSFU/GOD9dl1XteKbCxAVLR6BKAx8UKtTe+v+fOdm8H3Tzi8lqYQkku2t/sfn1NLcoIpk6tD8/4zuDpQv/Zb38VOn9PrIz/mQAd73LwEBaVbZRSCG1EGF4+8mSZBszPEp547PZPWEHMj9MkZD6/Z2WWDehYJbZ6tCG4wgRYrAWcEUS7IQ2RwaOEjs2Gi3WeQ94P8c+4MhefADeqIZfVPvelm0xIosa4m61bCNODz1DOa2OyvYa/TXWl6uJcL+91A8G2z+Wvfk7U5HFC/XNe+Gk95leMAZxUA28T3K3r+kzLq7bfyDJuegnWNU1BmxM7Xz9ihjOdIASN/dQZ55ZZyTBHsR4I5xbMqdHkcuO1DBEFgUQXXNc0TJvQB+fX5vHvMkE37a45YMawY/fErw1UA9mqtad5v0twyfTzlbCWCdua/2NPuAu9veNSX9D9OL7EfCWv3FmssCk3a4dr5HHMtH3Or5d2Cw8q2qZ3NfYJdCRMST5HMbAmRKxpJzTK7w98iV/FgL637nZOIjKgvT1BI97ruiXLGA0b27DNncl5aMRNrNFF5NNfZRYyGYiwfk4ff8/Oc60wGyX4j8METzJr2aK6mJSKmLdyGssKLTFlhyfl7j0lyahx3aMNhqBn7RGVNBvnAPZdXBNMG96eGH9g8U8lStfgUyeyMSjI4uUJQPO8WEIxCxZkiOYczuwZIFIiL4r0BpqpWC5ioeP8Mz8UexwLGKk361eQpd4vgYd5Jw0ITxYUDu3KK3byarw/Gtr2+zNHSO+iuYCq28GffsPHc2ksAzCFOVPkaInODtuCpcDo1eh3Ai9iKOEvKxx29MmFHHb8wCGpTMyeIbF8J64eG5bfnQW8CjKPLKcZ6Z553CCcxuaXqbb3Uy36LJr0brQgnTb1+8uD3JoB1+zc0tAizy1z8LreVF8gchMfe4ALmaA8/6jKGwjOcqZSy/fPag8KiH9wyQX/ulhOTtUzsb/V/nitichnvrgZ+sQaYkzKIFlVsi1zzLnbaRyO+lfG4EjaHdOGc5LllU34ksGQt8YYmluKT/ovGCa20m1pOn0VGHcY8ANIhwruMd4TEepJAQ/76HUdFoefYPN0w4BAUVNgM0WYVs8h7E5BIUxMcWVE5v0pKPQCAOWW/A67whcdyO67dR18SaFZt3wY0X1Z4zvlbuEx7fzwjODL+RHdVuYDevSy6mNe+zK1CQIaNWoHAYcUTmOdOU411uooI7ppgkbVT/Ldj7ReyU3nZi/yoyROVzK3rlMP58/dXFZx0LdXnkrYxEeFL/9QrVIIE/R9BE1zMncizuX37tjxSmt57XJ8dCr8v3SYQW5RvO0qqxteekGjZLIjR+nJ+E551HpwaVXrUp9OIrRHnMuDCz9c5DKXYht6/HWlDi3XL4gCMZbueN29LRE/atRr87K6OZYSpK1qftK/+nAreeh+YMHrczBkxfZfLCmQaM9F6rgJnuMQoqoi2ZwsDe7VodEO3HENvzCMMZtz71j3lRKTkcuY8MGye7gyjjEyey8S+gZ28fMJY+uB7bW80DlJzGfE/mT4Yy9uMZxfTbfIVsJqzIpuRCPRmNU2gAXUmh2UrEzxs4WwZMZEnqpGn40x4V0xgKr2cIdSNUHnp4pON198mA3+gqmaMjAqKTKupEo5Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: de5552e4-6c14-4095-aed0-08d9b92c762c X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:26.3224 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rXKvWeYZ089nDYgcEy83YfUoRq2q5M4LiistznZKMHQevTMrenpzsVCDdGdxVn9HczqM+IbSi9fb93opTiPMxsF+S0UhHA+kJjJFI2pATGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: kWGfPVaZgfCNpTT6HXEE6Ije65hDEqC3 X-Proofpoint-ORIG-GUID: kWGfPVaZgfCNpTT6HXEE6Ije65hDEqC3 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This adds a helper to check if a vq has work pending and converts vhost-net to use it. Signed-off-by: Mike Christie --- drivers/vhost/net.c | 2 +- drivers/vhost/vhost.c | 6 +++--- drivers/vhost/vhost.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index b1feb5e0571e..f225cb9dcb10 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -543,7 +543,7 @@ static void vhost_net_busy_poll(struct vhost_net *net, endtime = busy_clock() + busyloop_timeout; while (vhost_can_busy_poll(endtime)) { - if (vhost_has_work(&net->dev)) { + if (vhost_vq_has_work(vq)) { *busyloop_intr = true; break; } diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index a314f050413a..2fe7c2e9f6ad 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -261,11 +261,11 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) EXPORT_SYMBOL_GPL(vhost_work_queue); /* A lockless hint for busy polling code to exit the loop */ -bool vhost_has_work(struct vhost_dev *dev) +bool vhost_vq_has_work(struct vhost_virtqueue *vq) { - return dev->worker && !llist_empty(&dev->worker->work_list); + return vq->worker && !llist_empty(&vq->worker->work_list); } -EXPORT_SYMBOL_GPL(vhost_has_work); +EXPORT_SYMBOL_GPL(vhost_vq_has_work); void vhost_poll_queue(struct vhost_poll *poll) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 31d074724fe8..f0f2fb334b13 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -50,7 +50,6 @@ struct vhost_poll { void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work); -bool vhost_has_work(struct vhost_dev *dev); void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, __poll_t mask, struct vhost_dev *dev); @@ -199,6 +198,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *, struct vhost_log *log, unsigned int *log_num); void vhost_discard_vq_desc(struct vhost_virtqueue *, int n); +bool vhost_vq_has_work(struct vhost_virtqueue *vq); bool vhost_vq_is_setup(struct vhost_virtqueue *vq); int vhost_vq_init_access(struct vhost_virtqueue *); int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len); From patchwork Tue Dec 7 02:51:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0CDDC43219 for ; Tue, 7 Dec 2021 02:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbhLGCzE (ORCPT ); Mon, 6 Dec 2021 21:55:04 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45776 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbhLGCzC (ORCPT ); Mon, 6 Dec 2021 21:55:02 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5CPm004499; Tue, 7 Dec 2021 02:51:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ZpTkDwAj5vNW70NlD2fHUkhqvz4i7Ob57i5d9YIkoWg=; b=BU2d3/fNXXzffBK3mEYwetwJXjbT7ZhEkBrO0pK+CLuBlOCdyH8n1Q0EkPJeT9DjQmwM l1VCJQDEtisLJxwhB503qGPtFvyNphzTlGteALb2kgyXCKtoTHeFfuNmFzpQYLzK150U 5SdCk6z91y/bgz44Z8VZI8NXB2yMB9ImJmWHs61jprj5mUWX4UCRIW70A8DbXngdtQNG lTZDr2VgReYi8BKmjlKyiHKW17U/gYIGFLEVk2yPjiiAWnYSjFYfwu+9TodGKhSmOxc3 qlpbn+PjfHI7X5pHDeaWTE/D4y+AV6IzrHuEiBR7h+cxx9HHpKO1Co1vbXWGwuqpUZYr kA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csdfjbwyh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:29 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglY153019; Tue, 7 Dec 2021 02:51:28 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VbUOXP7kXglO0H1CSkpSLJIYy1bmvzRlwzq8aVS6ztJlyOdeHfbsiSAe5oBqVEwJXITI+pYQkUXPeSUPJJK3Jv3TwqP42uLB6XMzW92ENlNV8Mi/fkdIdw7/eTQFIMta2d0E6nwmIfzoHpJyST2HbI+jL1h/P05PKx5LkttyECgruEl6q/BqaWm9ywoM5BKBXtFkrlxwTfSBcLBr1X2/XPNc6AAQI9kTQvEL1WXdjHu7ebLPNJeB/Ml58UWHkjkEbeN+UiDXQRQkdhcBQbTwWWKhzlfBcfEcb150PJfCOBaZbufaD4cdEDVkQFLF+6+sjpQRDvNwQdWCTD6gRWMtjg== 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=ZpTkDwAj5vNW70NlD2fHUkhqvz4i7Ob57i5d9YIkoWg=; b=PATHQqs1XYjaVdvI1bZBFfaviXQSDDdudGWJYzHjn+ZDuW1XPHLr6+wkiOLDeJnatH+k0bWy/Ih9oyqcxrJUy6RqDpR2SxJ4/zAOpGBRNe1iBg/7tOwH4NmNyAK5UjN0La6Dv2sjT3qr81AdRjyLuWLxNEaCXrFEOX/AYCyX0i6d1Js5+YUOW3Xl4y5Ahrq8A8lYicoqLIuZ4K/POWKht7+EKhMG7BVtubvNlxt0SSrSZ1jvAlmwLFaqeOjU/dIFKgpuSHOXXS8e2iyziOv7Iskk3rjWicjqAkmVSZdqFWdapsmb8Ja7sNkq43+9EMgu0BJmNLOfNW3nxGcZZcksdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZpTkDwAj5vNW70NlD2fHUkhqvz4i7Ob57i5d9YIkoWg=; b=UHcQ0ajRshSqf7mc9+yeqkEWYHbVCaunbVZArfYRWXTdiBNPcfAwmBvw3VC01uvevRHlE5rZP9ZODDPQzeZfsU+MqO6tZ6Bw7f92cJpEZitxAgzTXFJ1qB3dUzDMMYLYV/dgXdD3ytDn7k8LZrIhgyYaq/+/Un6jwZsr/rZZEnQ= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:26 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 03/12] vhost: take worker or vq instead of dev for queueing Date: Mon, 6 Dec 2021 20:51:08 -0600 Message-Id: <20211207025117.23551-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fbc36b5-c2c4-4500-a7ef-08d9b92c766d X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fKzeTDTt9uZb+HjUCuOT4Ebftdkc7puRHTX3jWMe84ZaiU3xU/g+D2JsU8w3kl7F0hoaUd810FhSW4ujY7M+r4pJKSikWmZJ0rdYxVdZx5YThMUTucQkBbgufbMhWsfIzK0pLfGbo40yKBS/d7GX+M5QcjMOixRcYiTDoyEUQ129cmxWPRE4NF8dZJNA/QKb5xQByOt1Thi+6MxLpclmHze/VD6eLa7t1we51hr82MwCfvH1s2FRKO0A6ytqSF3LdvyMfZgMRo32DR6UcG6aR0AIXmGkZ5FN9X0fheiaYI0x/Ns8+g5F9Kp+yQLkU0LiTOIZ+JJ2Dko85vemB2+wMSJDbWM4RQRHEvlGE6pPu4OFvY9f2bEtsgWaNWeSf3ZFkzZJUtlxsanfny32SVI+9wJeeJqNZaSvM8D0LSeA8sAAumr/fCXZvTeADQD4xJhJFgUaSnpFdSKgtCwzLTF2bd5TYocurIIwfM4W58AoCpErjeL64ope3iUcBZ4VWo+74LnGQzoE17jPLw9+JkPZH9UcVTU+vS0tqIabH6Fw1CT5e0pRgKRj5PKXEXqhtcdUoLSet5mmYk/OUw80aINGjgLXxvZI6SSEa7hBouHkgrhdY0f5gM8wivcqv33ZV39DZkjSLK9jlim3SloKeHyLvLgkQxZ2nddSU61pVD0PdRUq2qaO3E5sYPqV/8AoUz8M8oPiDCbuUtXnSnAmQRwweQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qZQv7PnncDamDfa57EVx8g1/qIK1grZ/6zFz9X2mG/Fs7mLb0xkSvKPwODOaTaUG8aGJvR5tnN/GeQxMtY/kIDRBK6jXLEdWQoYGmw4Pea8Pk7zpFYO6z/B2eMmXBfNtJBPZI0VS08IL12rSoX9pAFHSFHDHu1FyK8PcDRYqAEHsCFdZucFxQ7sxzayrN9T9vnHkMO6/MSVJulFNfT9lftwrmKqMZfPualCHdd5QayyOxJruWfb8hkDdy69S/spLIvuaIGDTOK9RJMUSJxmF+s9dHkXDQABQaeRg/nnJ049RqcNiQghBNkJuOugzClwxkuBDydQwvijzCtJw3lNFHZjA+g8qUiOpkGsqANPMAEnz8wW6NUAdIZJjvN+jL2vAJM6votCB0IT/hinuOxtQhDEiJAzNPPKHIHDJRWGcV1yfFUu1Yrcd4ePcGN9UAgwaoi0tRo1vQQPwhwf2U+8xUYRqQglOQFVMQlgtUQPj2G9Hezw4OxstNURxSLfO1pHx6SZzj/0e8/Uy73YFWIdo0gQpD5mgXm5+tOMYt8d3pYNVZa7QC3QY9dbzpojwdkISoW0oYPE2YHe0x8uonSnJpb8pJ98hIQGT/m6VdzquKFL9tsjGqVggGNrnEza27OF4Sxze3BGkC3XMZ+NpKGERFBbowN+Kge60h0KxfU4S1guDwP4shzzfCYgVqTJJrwVnfbtrWaexfNa63uW13g6FPUdZ19KXwyZj5Jf5v90RyMiNoki8sVhsaCq/mNuzvv7lFBA9ImAdr7vFI5SCeHZHrEAZfZKfAbfs8Ka1CaOsqZjmm66mtzmGPRa6AtThFvhGVTIxn6LmqWRML+d81J9bDVfOc15WyQUf0T8HcVnLc4ujpXPytHB6s5fEYVVyabhXmzDUH4KYT1xrNxHuzk47dE36vdPFsVX4secS+7AUx9Jf82d5XE0PUhSQ1dFYJvSfHbMuSINzNJUdYvSPUxRnXD35k3X2elYvnCtosUIsAzTyVEIShFRGW40I5xD7vy9lgI5u2WCwvAOo6LXSTSMGvytKQKFnheTCLECrTCO4Nv+bCtlHJyo84weiODhgwqxf6kgp+Zx1WInqIMjRKw6O7rjIVKqPtujRIKa6GBukRutZj+VbRnhm+XTuBvEB5yhohnFmoQz3r5x4qYS5SnC/LXK1UeAgulFTqZCg+tYAtv9f34tJK6ZPfdNw3eliSumdQ9TOmEn/c93RnfggNfFzM8BzKF5e6phjgx6LvRGCivrxfYkqjcfmNxM83hT93SoDGqhPvHJtKmjxwPX9wK8qAylVoBL/KviW2r46LGG6+Yk2MdiDtmeRXc5PBaD8VR0RNVFnejRWGqVc1zPZxRhV7PPNmTt4b79eWvfYuqo7/1bzuvnWaBG4QbtqdKwUAyv7s1w2kgVg00ae9PyuvsF1uurXJBqYmKtse9v4cOYl55ATPDPazw+VDFxA/H5La+vwANi+vCW6JeGmqKntxb53eu/0141IpVmuhOJ0K8mr6+Vig8FqwhuzqFi+CTouDmXDRRnY/4M/BYo6itHufBqiV8lVMyIyZ3y1BVtRVqRBOh/svgAuJ17zs1Dk/1tGaStUF0C0Rggw7xyp+rMZPMsXwcAZWYbM5D1am/hy1jUdXIMRZBHR1b3hsBqQgYoNkpKaszdtZ8pGD4bJylRbrwN7/g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fbc36b5-c2c4-4500-a7ef-08d9b92c766d X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:26.7772 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DhZj8z+PVmRnzsbECdH17QIimAPzBfOUtUXTYSzAduhRjnTOJ0mduzSPXEX0kbJQ4963mI6OWrfgVuw0cejHSpp6UaQTgBV8U3LupVr/GeA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: aYhxXl4Y7ZSLU8nUEaEce9bBbEkV_6Ec X-Proofpoint-ORIG-GUID: aYhxXl4Y7ZSLU8nUEaEce9bBbEkV_6Ec Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch has the core work queueing function take a worker for when we support multiple workers. It also adds a helper that takes a vq during queueing so modules can control which vq/worker to queue work on. This temp leaves vhost_work_queue. It will be removed when the drivers are converted in the next patches. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 44 +++++++++++++++++++++++++++---------------- drivers/vhost/vhost.h | 1 + 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 2fe7c2e9f6ad..86192e1658af 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -230,6 +230,34 @@ void vhost_poll_stop(struct vhost_poll *poll) } EXPORT_SYMBOL_GPL(vhost_poll_stop); +static void vhost_work_queue_on(struct vhost_worker *worker, + struct vhost_work *work) +{ + if (!worker) + return; + + if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) { + /* We can only add the work to the list after we're + * sure it was not in the list. + * test_and_set_bit() implies a memory barrier. + */ + llist_add(&work->node, &worker->work_list); + wake_up_process(worker->task); + } +} + +void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) +{ + vhost_work_queue_on(dev->worker, work); +} +EXPORT_SYMBOL_GPL(vhost_work_queue); + +void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) +{ + vhost_work_queue_on(vq->worker, work); +} +EXPORT_SYMBOL_GPL(vhost_vq_work_queue); + void vhost_work_dev_flush(struct vhost_dev *dev) { struct vhost_flush_struct flush; @@ -244,22 +272,6 @@ void vhost_work_dev_flush(struct vhost_dev *dev) } EXPORT_SYMBOL_GPL(vhost_work_dev_flush); -void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) -{ - if (!dev->worker) - return; - - if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) { - /* We can only add the work to the list after we're - * sure it was not in the list. - * test_and_set_bit() implies a memory barrier. - */ - llist_add(&work->node, &dev->worker->work_list); - wake_up_process(dev->worker->task); - } -} -EXPORT_SYMBOL_GPL(vhost_work_queue); - /* A lockless hint for busy polling code to exit the loop */ bool vhost_vq_has_work(struct vhost_virtqueue *vq) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index f0f2fb334b13..f5251cf902ce 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -198,6 +198,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *, struct vhost_log *log, unsigned int *log_num); void vhost_discard_vq_desc(struct vhost_virtqueue *, int n); +void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work); bool vhost_vq_has_work(struct vhost_virtqueue *vq); bool vhost_vq_is_setup(struct vhost_virtqueue *vq); int vhost_vq_init_access(struct vhost_virtqueue *); From patchwork Tue Dec 7 02:51:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED4CC4167D for ; Tue, 7 Dec 2021 02:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231788AbhLGCzG (ORCPT ); Mon, 6 Dec 2021 21:55:06 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:46450 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbhLGCzC (ORCPT ); Mon, 6 Dec 2021 21:55:02 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5HmO012536; Tue, 7 Dec 2021 02:51:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=ptj4cR7uVbc9x64500ivlUyYaZ5mnIiFPGGDSEMpyIo=; b=qMQJMMvBDQumDrkQ6VVytFMOj3fA0IL3JEVHhKHfVPyK4r7gDmoNQCEiYU6RarLGygdb e0kp9tD2FI6V1MbwCf0aFxD7pZXEUtGm9RY5vG2MQtjGXHsLONfeovikmhUVzqsoKtgl /WtNZRGbRhB1edMu/gOU2hM9OwiDm42WDxpWNFo9lxXYULYd8aUKwrHcbxSwoFwjZLCb GjpHBDai+TadD6OAh/m4DgwsWsNhS6BHs6IXZiou+M+rJz67M0PydHfdsnmhEsn9N1C7 Ed729nrsUoht4jF2tEHtOSsT8ncz4xW/ZeRlnK0e2oSQ2MSxMlakqJU7Y5+gYK0sf3RO mw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csc72c356-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:30 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglZ153019; Tue, 7 Dec 2021 02:51:29 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQRDh+Q8X2ba30Vv/SqfFoAw7c+Dw0UfkZ5vfgr7qatvNH1QGchXcP5cJRyZwdRTYWQ3aPNEdDNB8T83ehfRntcchE4U3cAR4VGEimfoHYtqAyzpxL5jkI8z+XLKYbuMSRogAM6TQetOjx27D0QbJEu93EK9n4QcrDOKfgwJTQhTu6IycrK/CrCwWjA6isTadCpgCO5ugTG1E4Bgq0yvMEftDd1wwUGzYRx/1mZG/JhOFQmJC4rGxYBm346g6Q+08BPX4V2+IsZKHN8x+QLz8kxes9q+GrOXKsvDsT/bx2KnkEZkmJLal/q7NORm9PDpkPIERsHvmKfqKWVcJo2g/w== 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=ptj4cR7uVbc9x64500ivlUyYaZ5mnIiFPGGDSEMpyIo=; b=P/DDf6RcTdX4ZyVXIxwFpVIbrgAcZRsLrHo+NoLvB2t3+7cmfhZ9dF83im0UsPdM0qYbpsTnbLo3SpOP2hDbAfM8c+Tq3m1HEBVUXG2T7H+038vyuYG2jxRnLs79NRRHritgkNve++eU1qrWZIVjV0FPrISxZQrEs1tTQ7s6rATAM/JDXY+Nvn3rcXeDSeIJRxBP4TOYsN4/SCLclN5qWW1CfcMBi/Jk/FMAUGlHmBI15T14D3pKVBefS16bgxGFb1KLQCV2UqQdfP87RBeiVeB+Zy2PWsKoRK1zCe8rv+n4GihYuLIgyQkcFWapngWcuEj66qX9jPkEoo4jMfCHaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ptj4cR7uVbc9x64500ivlUyYaZ5mnIiFPGGDSEMpyIo=; b=bz2Lyv1t8KPvVV254Gs+KC6BLXAkOlL/2MnmPrVnzK+ub72qyhY2Sv5DhDq+4Aq7ChJg5fvfOiUnvYvLyr4bmLWvTeSpdow3MKBLmvdcF1vYY5Br6VYzzSYl6o+cpsR0JUWpvAVXvOjcM8u3BjpdfuGC7x69a494Rh8DBOUxg+8= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:27 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:27 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 04/12] vhost: take worker or vq instead of dev for flushing Date: Mon, 6 Dec 2021 20:51:09 -0600 Message-Id: <20211207025117.23551-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd89ed49-cdef-4fa4-45b4-08d9b92c76b4 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Wg+OlO0otT9swI5E8ZIu+UvNvHY0nFR42a7tlhidKwMsQcS3qxs3CVciwJAABt4n5WmBY+hd0lYH8zYh+t3+dj4xl2sg6J50sLIDY8SGgxnjyFuDInYqYa28YJ/ouLMj7H4YTDLlowFsYUza2BRw8gjy+9zxPkqF2stLSck7anP3etFren5mCwv3ddXnUTcLhxJhCf3HImjjPdfaVmXvVdry/9/0Tm9hbzUduW7xlYqxjnUg8Q6k9x+eMKh0CQ4fWE72+2GXr+hZzf5uWjVx2uTbT+hnr40u53jlb9BD1veCYXBoeTa/vu8YGgfZiEbPusbG+34wuEWsRQDJjfxZSnHfWyf03oxathh1q0ZrfSLVOoVv9cE84cRC7SFoZwAFEoAl8U+e044tyUJMigZHrje3aju9ZyP66K6m4JkslMPaJOB1h6+6NnKqROoTcZQAFUjNX9u/5+64vPmJ7Mv/p/lVeliZVXyqaeXl44DuuXgKEobmVFKcwfD2KXKnrIU/EeqDIvhknx1lT+0HsIvNWbxZBcQHR/itxxF++I9wEQjjV5xaOkfh7zu1bjOyUKYeZyUTeysKSGS+pQFh5z3saf81KgEWhWUcGGXPTKuFe/BdM7ZIZc1DWFA/ONjzk+XOf80xgk++Xj24hUpK8Px63ZGQHOVMxUW1RxdTXRVmHiUWT9rxD11mlqqZuN1ZBzKtKxhF3qeJoF9dwJcqtzKkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gv7Sd2WuEOnS3ZHfj1jp4thQJB23oIujNdNZ6HZoz31Zw4/STOMUTMOvBMDJTcS5uQgRm7aNQ+PpYVA0EouJu0QONu6bRdZRnjFkFQUCILZ5Plj9dOc34tYQo7l6aKDFoVt08ifxE8MmSyg6YOlQrfBVXroPGiYJPfgUj7F9y7l+pcV5joGGm0dGYeHv6d1whtl7opvDjg7QlMfjbwpEcbd82Rg5SOKCOxE4GVf0A+jYrTNr2L62JtM+TNYeQLJtnY7X6km9RKUBcs5yQ1bB8iKEnm0ipOaF/oZnW0FWauBykglkUy3igZ25TsAhlNFHM8uWba6IrONQkNSf0L3JdA9ous3FSk0vbxZAy8XQ72kMOl8ZAtEXtw6HcS/LU9Gd27OOjPUamgyJPvRA17HEmW0GA8eSV7M8uRcY+slPXOn407YaDZyP2lsSqNM72eOeCtD300wg7tQZmsnuqy1dZ7l+xvzL9MCuloJmhLygLN+RhDAQlFRMU0kK1zNWg6EI0TdiSOUkzpbPECtiMBwx1Zg7WUNba/5Mo0FaK0i+Fcv4Lup3ezDh0tx22sB8+6OmOhrbRosan6t9+LbyIXyh3F7VqHQXOGFvlBnEnvSQef7mKwemIt7SdsjE7Ls59NZLrFUiJYv5fmd6+AtJRk/OJmxqr88SSqojgFGxX0KiDLy5Skd3NGgkLK9YxjTwbvXCCHCYROqvgNBxUSlqQrB2hli6qd0zXPoN/N8d84PBWB2NV8pRHIUv77jvHiP7CqVq1ECvJ6ZGOafym73zKLJhNXQTVLaevoV+nu5E/Eu0vVDt1BMGCLVr0F7DtktbbUQs540edav7fMF3HLVF1U4fgHTZzJqt/gD30RlphTJ0HTzdUClA3wDyB2hOXYuDjdc6HzmA49DUr463dhdSsP8qldCjzDdRitjh/qESKaRJof5nZQWorT48SRK8mjQSMOrs3Yo6DtomLlVDKFLMwwOWEuc00cm3HwuZSSmGScuHJ3NDiCQRpUIh14sbaDvB+aqdrDHdqswe22ZTTN6muEkN8ptmKqHVJ7Dw3sNmT8nq9WfOEnrC4xn9rCGLQg76tDD2rzQ6XyCexq8N+5x1ZOLw3qZavrfbqjXmJ+CVlmNqqqztQvgqqY6mcIm8BIT/dAjjzl+WpVTSjWaivqpizcCtMcIgVy/i8IwGk1TDu/763DWmNi0BTNq24VDab53qdZYNlegfdiYmPLNyGH55tOaxC8QZCi2nyHulWWrOIbDkJh1yzwYPBb20+YCYzjCy5GegHmb4pMEQwXhZh0tUOcKRxAfNTDc4WW5TcC6devW0OReccueqDASs2v69L5XfsqvYxWV3Aj/V+CNIQqmiCuWuYGZ9yyE6efFbD5S53eYN3zLqYVbL9P1n2Bwa6vd/6n9TuPk1Bfy/2B2C0dZrimPYInd0xdJ+jsHn4+YWZe4hydPgj+ZLD4bbqC4TUFEFAjhAm0r+Dwq9xy9nIqSPvEEct63+39szNqKdYEhC+oM+GoB5EXFDKP1gXgd0+jrlGfS5TPkeeBnsycvxaHjlUevOYHLg+7xTj9A7c+kKMblBFx9cYy44B29pik3hsM47M+iHXpTBgw9EzzoFh/ap4Y+bAo9fM0PiPEEebJBsPX2K6fDEILyLCA6gJ43sh6LXr/hMUnNDjhMLaTDaWk+hIwQvMg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd89ed49-cdef-4fa4-45b4-08d9b92c76b4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:27.2440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vbG/jQ1xEgsw7ZiVHDYXMM88mPHQZfkk5S4AbPTm43EfOsBZQvfeP16mL0fCIRYGTRABOHqffWICrdnDxkn9PKFv2eRwRLy33wzuLPEjqaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-ORIG-GUID: 0iVbFU53UJBdLImQRpzDoG_EbYF8NV8X X-Proofpoint-GUID: 0iVbFU53UJBdLImQRpzDoG_EbYF8NV8X Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch has the core work flush function take a worker for when we support multiple workers. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 86192e1658af..e5f5acc7e648 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -246,6 +246,20 @@ static void vhost_work_queue_on(struct vhost_worker *worker, } } +static void vhost_work_flush_on(struct vhost_worker *worker) +{ + struct vhost_flush_struct flush; + + if (!worker) + return; + + init_completion(&flush.wait_event); + vhost_work_init(&flush.work, vhost_flush_work); + + vhost_work_queue_on(worker, &flush.work); + wait_for_completion(&flush.wait_event); +} + void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) { vhost_work_queue_on(dev->worker, work); @@ -260,15 +274,7 @@ EXPORT_SYMBOL_GPL(vhost_vq_work_queue); void vhost_work_dev_flush(struct vhost_dev *dev) { - struct vhost_flush_struct flush; - - if (dev->worker) { - init_completion(&flush.wait_event); - vhost_work_init(&flush.work, vhost_flush_work); - - vhost_work_queue(dev, &flush.work); - wait_for_completion(&flush.wait_event); - } + vhost_work_flush_on(dev->worker); } EXPORT_SYMBOL_GPL(vhost_work_dev_flush); From patchwork Tue Dec 7 02:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A069BC433FE for ; Tue, 7 Dec 2021 02:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231826AbhLGCzH (ORCPT ); Mon, 6 Dec 2021 21:55:07 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:47342 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230427AbhLGCzD (ORCPT ); Mon, 6 Dec 2021 21:55:03 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M56v4019273; Tue, 7 Dec 2021 02:51:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=TvoMJoiphXhAX84Y0IH80GMqhjqUhR7mOvEu4dNx8K0=; b=VEX943fT/ZBaFSKA/hJ449awj4z9ftmIUh4MSQxJ03F0eALoj/cIcb7yrI727pybXP9q OUng/F3m57TbYzWS6A85OUluHLWxYg/+Muh775s7jsvVBrs7KBfyE6/swOqRiHQCkFE+ 2BlLMPStpBRbdc9Neo9SJrAygJH1WDLdubGweyBv8+nyvpG7tYyF3DUZnNZ2TgwuKw9s 4y0FH779oLdtnhmCd8PSE5xyZ+/5PCNARGppElqy0jVWQRBxi/dN1LwHh8y4jwb0OA0e 3GV4D++ZEvxusnUeG4SW7gqOEYnXYcpyf9zX8NwNd3fTVM8Bj+92wPdHwux9oT1uC8tc kw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqmefa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kgla153019; Tue, 7 Dec 2021 02:51:30 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UVZnUvUfe9na/hfr6nOxO96vR60Nh9iWkD8tJaqbJA5XmBgg0z04o1XMX48RaFCCbnCYrh66+eBNpqbXHur32737RvdxtDPEhGybF5f4kyTTLuslRj4u4b5C3HLZIeYXZy8YUfEkxvqOdxK3W7DqZyALAX1zB9zcYUlTSt4ok/en5rKdkiiLY/93r5amUHnJnzsAQ7DFwznzpfdRowvL9EluSxcBmJlpc8FETNkhmKBsQN4DiSKPWi02YeihClIfUaXDw9HD4ZyjzemP9UEVQSM9xUm4Pld1BEXG4eQt1N5jcUUvM+jjec545cWxifdVt3GzUc21MycZt9IOnVEw2Q== 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=TvoMJoiphXhAX84Y0IH80GMqhjqUhR7mOvEu4dNx8K0=; b=nCK3rUkllVIoc4V7xu0NiczLDENEiOV+e78QpfLkjerq3lq/Q10axU4bADvGsTmb0b/PmYUxAMb/rk5T/8nXP7PLRH2DaOIBtC7DDkrKOmGsVpX7N626vUijXT6wFycsPlJsR3iY+To7njNokcWpDLlVp+W1Fl4SVsnB/mmQQxgSkdeMD0oQ413SuFeiWQ3Bm8JUYchI1PYxY3Yi0hZIqay/Zj/zzVR859xFFojwkBDf82BMADgF8Bh0QR8Twb64CwyB8LKRCAfjBiOSgJlwjck34WsH9+YDiZ1A8Bg8lnnTACuEdqzg3k7k6mBMygEEB5a5XAOPTgZvifLdbEwQjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TvoMJoiphXhAX84Y0IH80GMqhjqUhR7mOvEu4dNx8K0=; b=kaZGlAEV5iAl/JLp8PFI0jrlMCKi98D94sdRaSkT4cHAD0EsLNdlwlxKc06Q0gu+480fPV0C4J0Hdp3dcrX0Qj+ZDmbzY6BU16EG/GAKgmzb1qIqQqGUKhgxKlqFJx1rpifs9e3U4x9jJvQkxoBa3qdhP6E0CHHQLO3zS5jicCw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:28 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:27 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 05/12] vhost: convert poll work to be vq based Date: Mon, 6 Dec 2021 20:51:10 -0600 Message-Id: <20211207025117.23551-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f241fe70-d75e-4f15-3e7a-08d9b92c76fe X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pDRyKnV4+cSBlCB5h4no5Zqy4n0TVZeooGOriiiLXCL0zkVv49Lr1DFMfKa1ZEwMSyEq+RKyY4bGMbvHjDxO4qQ5am9zqd/m0NXqnEUjgoYYoYPGQsp1RkhjvfozuHE1UJ7YD2Wemwspaua/ppYVipQE69CuLpRC9mBZGv4WWc33h58uNjnlkYljv2rxJlmw+V2xEWhg/tZhWZGmWv2t1SFE4aP/NpPx0VADSbKDTwUo4tUiGGbOLTkk3CvvlORGL7OdC4aWdJXUiVg7zMXqDQ5K0wpMSH9WBXaMlw3/zPyo9Pu5d5Pt8stqiia0Mrylh3id3eZ6X+e68Ssed09g9srPC/WHEdwYL0xEZQT6w5U1OUgr/ugX/NHZsJIaqN2PAuwrCi3isnqWIBEr4O7qbfJucfbRpjWZ7+q5ErU1LpMuFwRSa7mfk/ASRjjDTlj8WrR7O6rrO+ZApZhRrDJIjixk67t7IxUsnyIqteijJZmBvdNpwlT3veE0524TBE5s4HP8I1TuEQrRf8j0qy13DhQDMKhEmDJfTaNEUmsukTz5IhBkGQTsahg08pE4ilygTWQonLwoJPTnjmsUiIJU6LUL03D3YX75/7TgntEB2mMxPs8GS3hUEixqfiKIhDoT1OTmEBsbeOVAGSWvphW+AJ+PsvAUcwxtQwtBpC0xav2nSxbW3CN/4dnce0/E+ElZRuO78moLQrS1+SNp6Z7vsQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FA0QWYRZNT2+kowBHx/PuCwrnAidII7dGMpmUOCL8qMFB07jsPwL77RCoGybOMBAV2yM2bBnRzXSPV+mtSYDm2zjzqitQ6B2ryh9bLDOK16FS/58LDmsLzF4UDI2LW0KvQN5SGdWnJVCEylDcmn/bRQ3mVATRyJ4ltanegBABkBCrRi/NWt7zcRraS6mC4FF6zmHtfoJBQSTKMN4SOH42w4COgELnspb9fOqRSgbHFQMVhZ94QS0DYQiPKHCoaQP8jfItfHO70nIZJsl72ZXpP21ykItSiihSmAfYCjVYKtmy5iFeLVaQDi75Q1vhTyeDvxhcwU6Y45gUQ66ItZ6xiGNqcE3vloPgh4ht98+CfjqrF2YHnvhJFHAWIaJLlEh5pTkQMIJICWEhIwTFCMaFVyFiey70X9m11Tx0PXYYgwBQmRgRnTOEx6t2jkxk2Bm3+V72IK0SHgoZHwukMsxzDlf2hg1AEPkKBIKm55hN4qGLPnf5QVeATOYaHI4psGdiRuyxupdOFguXnxbpPQf3x00kowfUGE2uv89XF7G36+yDDJ0KmCaJBxAiyRSkYcjYaTmAM1sFMpQhZSgiANJHc790e6CKJOWa060nZpJFF4WxGWG0RheFoNADeRB/wMDzgcSZjoGQvrbYkDADCs79lXTRYAqXx66Z9TZ/0DdEuPpL6MABadR/jGJwOlMFkVDKN6nGIL2VawMNTDD7nfoW4W5h1+DI3q1cr5JY0RRJ35pQn02my2v5V+X5n61ZHMy2V3NjYoK673cSSNV8S9qFtKBYgXQ+cW9CudSuBk5Zr78nwJLzENM8jDzbYLDZYDkxOXmzGFHAIAC1N7y/WMoLhPN+hMkrrfSzsqDZbsgmD1zjLeiqNiJ9kdmr2Cep6dGUd7CIdHQ1Z3ytdZdh/2+VWXrNnu8eYLnG+9L+k9B8sLo6RAgmOPTzCl6I4sYVTou0kg95OjZ+KFcIrC66P8U114nWA3MOuc2s6OZdaGW8X/H0PL3Xw6B19Kw4/PdZiIInwtcu3JqU69uijRmNIJ3k3XRBzp4yH+Yeqq2MkFYpPpK3zpS+/53ECPTAJTX4u5WTBao8oC5WBmmd75AL59ZVMgXxsMLeWGHxP47JzztlSrwR841NBWcaJKMk4zpR3e1wZSRQ5B7oP9zS5cJYI88I4PFrgtdMQFU6VmhBnqYET1pDOY46yXHHxe7yz5elMjY2M3ZgGlOuXZ9CW98e6sEGkT5eCNkcfHqZ1VLJ8jxkEgEQZDnJaFAfiRI17O7zjPgMi9e3xA+ehYjdRtrYPEp6lREuicLU62FgFpx2HVDifDarpcWmTC5kHgbEG1DdjPn33Mhhud5kE5MmDSls/wZAhTc0ZK8LexssHqsyXQMytS+sp5U/5aXWbwcMrK/5qFk2E1VY/7KAUivkqoRLe6FOoNFlFhyok5hIBzCFZGG8aJG0YJOpMJK8tRwBJBTsiSXLnd5zXph9oKKHjTqCmPYB7g8qMQ2MImxWFOZzizXtTq9WkbCt8zbDc8x1W5SIOmDR0vUEif2HsZ4cWmBbdhP71wpFSVVWNQT6iMj5tYAL7MLIb4BUu2QhAJxjsZCOIo3Cl+MIIopU+AUJh0u64l5HIY6tRAkfViQ43DzLbnmx6QnmKSFzxkoA9UITfdkSFBnpxP8+GDAtr8KL2cFHDAaOQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f241fe70-d75e-4f15-3e7a-08d9b92c76fe X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:27.7938 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T+iaXx/BHCxJyjAVcMPyjjLoNVqer88mdsoE4EIdmIshA+u/pT7XF5Fw2a4SePJng1kHJ7tEWxicUHj1AuQ3ZcYoPjnSExJ1iXChxeqCWLA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: MFfM8a35uiWFJpnPmCoYPR7KTUQjrDbk X-Proofpoint-ORIG-GUID: MFfM8a35uiWFJpnPmCoYPR7KTUQjrDbk Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This has the drivers pass in their poll to vq mapping and then converts the core poll code to use the vq based helpers. Signed-off-by: Mike Christie --- drivers/vhost/net.c | 6 ++++-- drivers/vhost/vhost.c | 8 +++++--- drivers/vhost/vhost.h | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index f225cb9dcb10..6e2b1670ae51 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -1339,8 +1339,10 @@ static int vhost_net_open(struct inode *inode, struct file *f) VHOST_NET_PKT_WEIGHT, VHOST_NET_WEIGHT, true, NULL); - vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev); - vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev); + vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev, + vqs[VHOST_NET_VQ_TX]); + vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev, + vqs[VHOST_NET_VQ_RX]); f->private_data = n; n->page_frag.page = NULL; diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e5f5acc7e648..e9f78f0d72cb 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -186,13 +186,15 @@ EXPORT_SYMBOL_GPL(vhost_work_init); /* Init poll structure */ void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, - __poll_t mask, struct vhost_dev *dev) + __poll_t mask, struct vhost_dev *dev, + struct vhost_virtqueue *vq) { init_waitqueue_func_entry(&poll->wait, vhost_poll_wakeup); init_poll_funcptr(&poll->table, vhost_poll_func); poll->mask = mask; poll->dev = dev; poll->wqh = NULL; + poll->vq = vq; vhost_work_init(&poll->work, fn); } @@ -287,7 +289,7 @@ EXPORT_SYMBOL_GPL(vhost_vq_has_work); void vhost_poll_queue(struct vhost_poll *poll) { - vhost_work_queue(poll->dev, &poll->work); + vhost_vq_work_queue(poll->vq, &poll->work); } EXPORT_SYMBOL_GPL(vhost_poll_queue); @@ -512,7 +514,7 @@ void vhost_dev_init(struct vhost_dev *dev, vhost_vq_reset(dev, vq); if (vq->handle_kick) vhost_poll_init(&vq->poll, vq->handle_kick, - EPOLLIN, dev); + EPOLLIN, dev, vq); } } EXPORT_SYMBOL_GPL(vhost_dev_init); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index f5251cf902ce..58032429bd05 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -46,13 +46,15 @@ struct vhost_poll { struct vhost_work work; __poll_t mask; struct vhost_dev *dev; + struct vhost_virtqueue *vq; }; void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work); void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, - __poll_t mask, struct vhost_dev *dev); + __poll_t mask, struct vhost_dev *dev, + struct vhost_virtqueue *vq); int vhost_poll_start(struct vhost_poll *poll, struct file *file); void vhost_poll_stop(struct vhost_poll *poll); void vhost_poll_queue(struct vhost_poll *poll); From patchwork Tue Dec 7 02:51:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD93C3525A for ; Tue, 7 Dec 2021 02:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbhLGCzI (ORCPT ); Mon, 6 Dec 2021 21:55:08 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:47686 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbhLGCzD (ORCPT ); Mon, 6 Dec 2021 21:55:03 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5GGY004565; Tue, 7 Dec 2021 02:51:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=MwZRw6oDUAORsomxtWes8Zatl7shBgHayG0LrD3NZiY=; b=CfToDDpv+ZjnXKHxUplNodAl7JyGXvdEqcNBPUdm7F7QFgi49RZ045+y0zJLokAlft/J XTHNPvPL7kS9vtx4DEF5DbNDybdiXM1Kj2gFac+UK35hT7DWhT30TmYsUH6gKCDIW3+s XFSa0Bc/MfUk8P6BaRZb6AQMQKMOwcyI/s9FVwW4IYLnr6tCL9LYIovgmyu8OVpg03gx KP9Xlkb0ueyvA7Ayj8i84jPCu7InFB6pTm1sYR32drSkeMY0gbQs7eKl6pvbEqNa+hGY jFqouKZqe+mUJj09ANH2JwvorQlKLEXx9fgKldz5T+3cGKpt7UDvns8I35WVcqcANnkO zg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csdfjbwyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglb153019; Tue, 7 Dec 2021 02:51:30 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ViwFcRD7sHhcc54LlkmWZUZ38uveKrzvEpyDoSnjuYUaMTHDgq5LCGZvotiw2jd4wXHT3bn6uxOLbjoA6HAKhygq98I/ycdg3+dz3CpwpZBz7wqWDv8OiUBqebRU/tco2l6XObfI0sz4s8cS+onYwfxpU9HbuzhwXl4idhpwcRTyvmMHKyzquwDezmkYc8OEew1YpHNbucb+Ncwn/2U8+GA5gjP96Gf+YGGySGqQckwGZsZhl1nPjgCsmkVdlUqPRwcmKW8o+kywJVYfp5Ns3rbmHHGZzfjJD60JF4SRroQsJbQGxHq0u0Tvua5EZZNPc/XpOE7lfwWfQBWmx38Gjg== 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=MwZRw6oDUAORsomxtWes8Zatl7shBgHayG0LrD3NZiY=; b=MflkoU8f0Nicq6gWxoS5OjEOJIrlJLyGWC8VytyyZgJppLOYwDW8gmTV79AhfyNl9f+1152AEPBjjdigRuxXFSeEgw0eNbLOIbNAjOTJ6N/lhe5yCB/NmbANntMVPhuqalKkiYqWLM4I3/MseKiLDW3/6aU1pwFfa68qgUrzeoDc+oJZbRGMwUVSa0ZGOWSDsGnATvIEWvg2eebF8YYNxQ6wZtL4bOLy4VQnlSp0ISHqlMZ8Ng7NRTxQE/WfMNGUJemOphM8HIBr6rGZf/70uLUhiSaOgPkKCpPUhcQlNH710m2yqWtOiyttwx5BzK+6qx+MsfszZFHJXnNZZkDbzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MwZRw6oDUAORsomxtWes8Zatl7shBgHayG0LrD3NZiY=; b=nU+PPJNpvuKhUDDCqQg8kNI3MdYFMMtEZ50mlwONQsa8ibQnAEcHVscIYR9dKeQq5k4ZFGgeqBKQvA3GNDA/cG7LksfVJ0Asri1RsF8jFtSbJknaVF2mgj/k+HerwXV/nyBCJLNszZCB+QfG3odTep9kZfgxR5op685bo0uc4Qc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:28 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:28 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 06/12] vhost-sock: convert to vhost_vq_work_queue Date: Mon, 6 Dec 2021 20:51:11 -0600 Message-Id: <20211207025117.23551-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 113ebff9-0986-4c46-d312-08d9b92c7751 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G1QaOqRlEMz6dMfXXjoRNc+dAQ7yYnvQA346IN3T7q/MBdZRIZhDloBlF7VZ+aNEqclhu8RVTKpjoPCqQ4IerD9B7uZyNNhaalYgcYnfufHyU2RPPeuFnHytPGWHFbth4/fSKOx9vSGn2KxrNRhnWJpcxeMKti6tOLynKiqezyIF+1nTDINVmiHsEq74RWeR1Hpe0eHFGUTnEdMFcYqV6yPOCFft7zEe2lz4R4KeZXHTe3alt9bNJfjuf2zr35r8FZXa8Bk/i/F4bB1nX/McPOO4+RqOT/sfYIwL/T8G0KiScgVj0m32goukiD/apkZd9Ao81OsX2p5bTqB/RLjhC3qOznttXhyFQPaeuqGA5CC/X7ByuQt6A4c69BFuAAhFZAGQghIWAgj1vP/vgoe5Y6bB66Gxh9xoT/IOZJOluyIiK7Y8ALW1rTR+CeNp90OmXCJakvxuiOE+xRxa7IBwc82oBLfBgnE7gsVdrwuuFevgQJpIRZLL3FUW9JIxbioed9osnu6mHuMB0aV9r5IiJJufwdeQ3BSxooTPPAw3DMKp1gru45UYKI4Mj5mg11FKANu95JHCrxqEL8MEYESkVLkDbATooLThDs8M6fiPpW3xN8UOUMcSDtcjo4z1W/+w6tOB2hPX5PKUT+JYp/8yXRvP6QRro4JCYphbue4wBraUrpeCsN6h+3AHzfKheWXM6rEQlGJbC/0xGNbsRYz/uA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6c48UqYskyQZUXippFYYSCM2yC974sYj65Q9Sl3m982qsIjDM3ABibM4R0zIKY/UnK0xmRKzikxSRXpEaEL/I8fBCeE3NQJMqI+m0UI/oG3aV46izWadOD/a7qIvsermXHdW5KpKS91fDx0/boEG0c+a0NcNFX8n21eX4SMc25OusSxeOvQKxVkQivlBgSuuLyqN2aonbwIOtfcyCP7ReBiwz+p5+GzlDgcL4jNbm86FOw6PtuvPmYQMSI/dTxDBuNmrl7cW8rb1pQfTIsEqvnZ/s3c5XWeoGr+2FIxYybX1hg0jvwbxkA9ypECXScrF2jqH47SKj6+T6mruKBKvtHEAOQbt+ziTnVVfYo+DfAQr0e4NqlPm9m1m0ThLWdZWKYv2QaVeZwZ3tub77Xoi9mrC7zOue06C65gpyHd1uPU7lu8iBV+2CuLi9WrvnJeyDhzGNbJYUfiml/Y+wcGTZiqQY+CdJIrYPW91G0e/pFOsXJI+AosvWIxZUc8caBkLjFAy5zxHoHpmxMbFsrm90THy8143mOaoMndDPvoaWP/mx/HSY3IIhYkO5x5eIi6sHUC11OPwcMr2MeED9yjq6nCs983Vue8kvRNoBslAnuAvhhCrcxvycAMnh7X1ZBeqvCBys20rm7j989CF8bdf3/lgstpP50zVUrLHOpdr6b8HGbb9fVfO7A4lXAUvqVjNNsX2o3xY4cv1s2HO+mP+hW7IFblHHOFAdyGam6NdIZ40escWFnMr3A1plYbFFQNtXx44PxuahwxIAl7x8mZiB6vNH2Std1A+KSXtbjndO08A72o6+eGrxMJGQGRJ6VFqmczBheoRoo5JmeUpd2plI2FiKuWGO/K9eO7ClQ9vvUdVc/Fgfl/lszsSn032nlhlzEfG2wCGfPK9XVV9xEupB1tpUAeeT1y0qQONPEE58xmKu8/FnFmdC6+LAYiQBWX/e0iDVPlrsd+yVSoWSo/ZVMPbsVLvwUquzFmj98oA8QbfPhUI/rCxk01sGrXIbEqTRz6wkH+n7t9U0y6Lsdr7L7L8vuzt1C2LoheDYK7wnlY/QhpgTJjlc2j7FSqaZi0dtkAcHd9lgzrssi45v67Ns6wDom257plvxJpUITwTz1iTOWAjgN9gdkQIgFrER4xmseUq/ZVjt6nAgKHBrCN2FuI5UNoG/8HOe+WDlM9cQ7akuEF0aq+Cjhb1B10E9xSIY+As3chbala5L/7YPQaIv95g8JF1M/437Lqlvr/Np/iQ3mF3dfIwzQn2CEdE5ozvrZGi/p8TH4j8ytFZH9bDRf8hHznaApYIA+2zZbkU1uLpd+8UpjMVicMvTiVOnuZ3wdOxVpijzPUJ0HJqnwWps/0beOjiECAVv8W/Yj2bZGqQFg7nl3al0QrfgW+N4vd+dLOLD7t0w7tHw7UYUDvWZwmsdRQFeyszIkbXcZIglzIVUzsRHdpnciwz9zgI8z19hLxVz9ReP8cgSflJmMraqeUwzKRgB1wnJsXWff/o4cmpYVEo06opIF9elh+f8dP0MHTEAs6qIafFIsgwI8anCM3pAedxKZ9uBQsJXlTI6deGSKwnvx1A9I9wIFKIXlR2ExqJr4poYHJCObcjEgv3B0hoPQaikSb9bA4uVHxMiGqxKwEi+sWkn+GNJOLFT/ByMBkmcck+3MwnynfFF63TTA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 113ebff9-0986-4c46-d312-08d9b92c7751 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:28.2705 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c/Hts8e+PjjVBo37baC0AUgXDe6yqFnxUwEHs7YifCP/Pkj+kcHZ1PFUsxjAQkTA5PHpnVv3r9SPWH9/acugtTJVGh3kdK87A1LN+/Qeobg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: 4vlhbb4SQhC9CTe8Bj7yyVoNnJVicZDs X-Proofpoint-ORIG-GUID: 4vlhbb4SQhC9CTe8Bj7yyVoNnJVicZDs Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert from vhost_work_queue to vhost_vq_work_queue. Signed-off-by: Mike Christie --- drivers/vhost/vsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 1f38160b249d..068ccdbd3bcd 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -300,7 +300,7 @@ vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt) list_add_tail(&pkt->list, &vsock->send_pkt_list); spin_unlock_bh(&vsock->send_pkt_list_lock); - vhost_work_queue(&vsock->dev, &vsock->send_pkt_work); + vhost_vq_work_queue(&vsock->vqs[VSOCK_VQ_RX], &vsock->send_pkt_work); rcu_read_unlock(); return len; @@ -608,7 +608,7 @@ static int vhost_vsock_start(struct vhost_vsock *vsock) /* Some packets may have been queued before the device was started, * let's kick the send worker to send them. */ - vhost_work_queue(&vsock->dev, &vsock->send_pkt_work); + vhost_vq_work_queue(&vsock->vqs[VSOCK_VQ_RX], &vsock->send_pkt_work); mutex_unlock(&vsock->dev.mutex); return 0; From patchwork Tue Dec 7 02:51:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6392CC433FE for ; Tue, 7 Dec 2021 02:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbhLGCzO (ORCPT ); Mon, 6 Dec 2021 21:55:14 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:48696 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbhLGCzE (ORCPT ); Mon, 6 Dec 2021 21:55:04 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M56Al019276; Tue, 7 Dec 2021 02:51:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=sptFC9ACWeJehv2+iivuW6IYYpR4vhUSH/F1E0l2eC0=; b=lleM+2fFToXorRgZqgr+WaAQicnRjnMs5RbXx+ioU2eIbcFVwFP0tOtN1J/HCe9ve9I+ GXxnF6f7o1UJA4zjGs3z9yuvD96pFRMXh6CgJ/YMCYz/F5EQbbTHTSJLStfmgiGtLB8t FF3ayV9azluJt39WWnmpSziG7JGptGLGRdNQw0d+QqpBcVg+pSOCwTxokDGLdOmGAeX4 jdcndGNW3th+yfUcXcrfpEe9T+J29vxV4FYX3tzdtuTP4Bly1VVMDJamAn/70T8hm25A KodX9NG5by1R5FXOD6gTc3Hn580NXhnl3s3CZl/htd/krl7mq+zd9a4XdcIpOCtLvDqL +A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqmefb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kglc153019; Tue, 7 Dec 2021 02:51:31 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PrF8TquI90g+lpJLo3YH94gOVmDp5sZ2SkUSTRnhFe9Mex/6n6XEm79Pu1gRRLU3z3MI2Lb2Klzb9VYFjphDiMiHXqPi5gwIs+9/cS07H089Q3WhtKU6siIpIuOHSrgwk3R6yfiGknuaV+CeZVwkXdpRjZvnkvMl4bfohyPYPkrXi56vsYVZTkwnVteJ6clemZPxYf2tAcN5dJp6Y8MHqITNr0NPtQBVW7/VNXhZZSalmop0HUckixL6PrdoXnjAeAcEwmbQ2fwihkhEumKuzum39o2kZS+u0A8McT1xZF1XljFd0QD+gvJl2OgXJWXn/XJwPyAnloXP1wTBugX8Lg== 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=sptFC9ACWeJehv2+iivuW6IYYpR4vhUSH/F1E0l2eC0=; b=Iu4U0lM1BbCtgTauatGUzTxG6HlDF8yTnJEI/pUuB0ZluRko3iiiQzhjn10cugSWK6Htlg1F4tXcXisDp3pcI6OWghke2Un2/a+2X2queIoOHdjo23QsavcwpCGyjxUQl9PYeZ5g7GRHu+qcmWidrQgjXkl3M3p92f+xzp7m/fdioa9yJiIq8hy1sTn03KuWYtjFhGJb05APRLUyciifFP4gA0POBhb/4FKikvWQi1WFeF2zTAj1P4ebZLHoGdOF2vyj4BUJS585tVm0cuZPRHdiGH2plkW62cHq6eQgOjgtM/z1e/0UBHLTY1Kc1v81m7tI37bhASXMinHEnPYwjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sptFC9ACWeJehv2+iivuW6IYYpR4vhUSH/F1E0l2eC0=; b=et9nF7ZGjnWdfUro2x7/DxPV/yZYJa4qayArO+kPZcoVIvUelvNhh+FPPox1HwW0Ra5PmTED72V0/eM+0MFsCYl0O0F7ZuQPNigxIbkESLtmZCmeoIwmatancSoSPiD/ylBpKMq0VSfcDUA/tqPR2yoKwppA2D0TiYvOVeFN3eo= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:28 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:28 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 07/12] vhost-scsi: make SCSI cmd completion per vq Date: Mon, 6 Dec 2021 20:51:12 -0600 Message-Id: <20211207025117.23551-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 739f537b-ac60-4a6f-56b1-08d9b92c779b X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1+ZWNJLzCbbR4qkBYf9A7SDWgpsrKBuR8ZcxtXfs7smP9pk/nDGWW+l+9UTL0L1CrE8DZLzeDgOruM5LhufAp6YVuNDCoVRdk5y89uDLc9jdDmrzWDUDdQVxZw9WB/8YaS3RFhcRtpz5a2xqeCpLYfFlhzMZNpGyy0MHXwaDpdQy6o5VrvXclHMHPfmCQyfvVYZXQFHRryqC7sthhiZ5NPaIr1rkMNnz5jyz8knwqBzGD5ZajuAaZ2F+tFsQBvGxQOBsCHiEdK577APApjv1S+PXMP4GHqiE7uzW8qjmMLDl0H1D3j7EIHW+9R/i/bmBVOCP300H+u7t2YFiS9Vxd6PUUgReJSJYS/qacNerdNgOzrn8tghWaughlr8UJLHyT6uaOw0A6MNd7QbtTsEmAfoMDKxvuL3dxU4skjfrPbymwqX33s4gXIfon/nrpuXGpdb61b46EYfmNTRxSh7VMagm+E7a4wCV27D5yWCxq5P/m3Y8SV0hqVBTZd5flL9ZNU3rpjNUEwZvidHsfkIQgPx5XcVByIlbjvZs9UfAcug84wChh3fjM8rRfD4kbzuHm0Ufvi9zGJxtjKp/SMseiKgUyA0CRw5U6YZJ+PLJGM1X7r1lrjF/ebNikgeIevL3YXupzvwWSZfcJflZP2SfAh1837aVzJ5ujB+A5ohcvqVlY6I/BlxkGPrLCdxQOIccluVVo0GAGs6ng4xQXjNG6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IL9GLv7sHaIrn8werNniT3lMuEjSwQmoWiM/Km09pcSQIboewnVS9Ah4500Gk+CFHI07m+TGAVlixSahYvVJ36HI7KX2yNXMwkh9/0Sg4hNxOTk6dPKLPlR8AFY9oZlL/4df8FtjvJokXQWsCt1L73NwyuELbAB+cnRZBsWvt8f8avizP+lN7RVAvPNjtxDiGrSR4TqwPM9vWMP3EzDN6EXm1LU9upUCwCK19bSU9u152du2MN46FxQUO16rh5SdOFRZiz3b/qnniOY3N0Z7BY1+pewOr9+/fO2OHAYRr+ss+vBuOAJMk7JICtKKffrT/PW2WdliyEMUOOiSktY0K5WSJdbYQ1RVstqepe69GEETtgmb+kOU6pUjWONmdwWxl8/imNmfRtqw0FcGVch3DIxiadqMos365U168YdOqtFB38o5eKPmlBZ/MriLcnQEcrIVmn7EEb1pxnYLwBnuG4WvS29W1wCI92mGWOPSPFWj5ErfEMkntco1EmLdoKq8EBuHN+XGhWvvIIGeR2CIRzsRbB9lv0feWrHxuf4KnFRbZDueGlHI26+jsBqtQQf2h0UcT3+/zTQIpdrAVGgLnd95dT/SZ1oxH3zVszET8jQ4AVhx/t7EeHCWpaRd1irg2GWa8bMbyUwM6blfw14XuoU0NMt6V4M3AkpCSO8swoS0VH4ResgLhjtfgj457pbs9zZW945CR+y6XYpOMvn4anh9mjLTrDGkrb/gH6aVb2g8Dc6uta4UTwH77Ou0MjqUP87MvSoWnmYJ1LvvGDXQSoJxPIcWEnaVBRa1QdR+nVEBCABPaOEdLYx91NBuTj4Omrh/YF1bymtnu7rHdH3FVVbaKzhKrTQ/BSfksKKeM+t0InUj5b2biB5iTqPbF0uE5MhNKf/9T2zvjIcu584wWR9AKcAbRtCgEGotl+lsT10dcH4kgj51eG246UHInqnMevNWhTmBfmF/gIWca0Zzg11R0mI80vnGTXGr75RT2Pn1arwpUm6YVV4fd3LJFh3llSP5Z94HEq4mqQVJIkIrT09lSD8yNBgbQLVtBd8UnKiOf+Sak0eZbNlQDC6fZRT33nAxGUxkYSopljyl9FA845GC2oNyETUyQOXdUq9zyXpHr/PIlfAaBBn1M524wXbBLDyOQnQ+qxO/7UVbifLH2/qz4m8qJ6RGNqfp/hkVJ02uRP6ksqQqc4bAX8Xtxl14UcnjEhuiMbuNCAqpyymFJUNwzapDwPgEAmw+Z2Y9fWOnrzk1S893ndTMZyRt9dPerrv37C+xzJyD2DvN1Xg1liq9GmLa8eJH/1vFTc4uheoEI6faHzyi3GKk+BsJwS9NkStdmv9uKvMmGM0yIe5ZlH1I9zB6A1mt6Nqy78cnIvjSFUkMrqQ71uEz+2UtkqGv07FQcL1bAEU2fijc0cYK57G4zqafbADLXtEAHjDGmp3zwCzmtPLvUBciWO2WtFI4lF7PjyCb6ORcHc4KXgvlS1+j71c9jqfSiLFsMKouv2NgAU4VnJ0waNRLxqv6dYwbIelm62MehV4Y4jxUVyWCJhHW5MYutWVSlPQmmG/trwpJTf5dX894bUkmL7vZwvU59NoPdincy9lRPS8IvHmqpAYM1otEdyBjWRqnohcHxrSmFqvDa/eD0NtCkb7p4YkOWfbgK0c9ZAeWKHSZ7ahVFQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 739f537b-ac60-4a6f-56b1-08d9b92c779b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:28.7173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KORstit+rqtEEVTTRyBATLIgEi+oith2ZJwb4ibHlSLQJ+ZCoznEzkMkHM/Gq2kVMbfo+VsYvmlqGsePLL1Q/wRMUt95voBEmNXSIx2uYkA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: WrUqxNC-YwCC7GdWsSIh43xpxrKtc3Me X-Proofpoint-ORIG-GUID: WrUqxNC-YwCC7GdWsSIh43xpxrKtc3Me Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch separates the scsi cmd completion code paths so we can complete cmds based on their vq instead of having all cmds complete on the same worker/CPU. This will be useful with the next patches that allow us to create mulitple worker threads and bind them to different vqs, so we can have completions running on different threads/CPUs. Signed-off-by: Mike Christie Reviewed-by: Stefan Hajnoczi --- drivers/vhost/scsi.c | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 94535c813ef7..b2592e927316 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -164,6 +164,7 @@ enum { struct vhost_scsi_virtqueue { struct vhost_virtqueue vq; + struct vhost_scsi *vs; /* * Reference counting for inflight reqs, used for flush operation. At * each time, one reference tracks new commands submitted, while we @@ -178,6 +179,9 @@ struct vhost_scsi_virtqueue { struct vhost_scsi_cmd *scsi_cmds; struct sbitmap scsi_tags; int max_cmds; + + struct vhost_work completion_work; + struct llist_head completion_list; }; struct vhost_scsi { @@ -188,9 +192,6 @@ struct vhost_scsi { struct vhost_dev dev; struct vhost_scsi_virtqueue vqs[VHOST_SCSI_MAX_VQ]; - struct vhost_work vs_completion_work; /* cmd completion work item */ - struct llist_head vs_completion_list; /* cmd completion queue */ - struct vhost_work vs_event_work; /* evt injection work item */ struct llist_head vs_event_list; /* evt injection queue */ @@ -365,10 +366,11 @@ static void vhost_scsi_release_cmd(struct se_cmd *se_cmd) } else { struct vhost_scsi_cmd *cmd = container_of(se_cmd, struct vhost_scsi_cmd, tvc_se_cmd); - struct vhost_scsi *vs = cmd->tvc_vhost; + struct vhost_scsi_virtqueue *svq = container_of(cmd->tvc_vq, + struct vhost_scsi_virtqueue, vq); - llist_add(&cmd->tvc_completion_list, &vs->vs_completion_list); - vhost_work_queue(&vs->dev, &vs->vs_completion_work); + llist_add(&cmd->tvc_completion_list, &svq->completion_list); + vhost_vq_work_queue(&svq->vq, &svq->completion_work); } } @@ -531,18 +533,17 @@ static void vhost_scsi_evt_work(struct vhost_work *work) */ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) { - struct vhost_scsi *vs = container_of(work, struct vhost_scsi, - vs_completion_work); - DECLARE_BITMAP(signal, VHOST_SCSI_MAX_VQ); + struct vhost_scsi_virtqueue *svq = container_of(work, + struct vhost_scsi_virtqueue, completion_work); struct virtio_scsi_cmd_resp v_rsp; struct vhost_scsi_cmd *cmd, *t; struct llist_node *llnode; struct se_cmd *se_cmd; struct iov_iter iov_iter; - int ret, vq; + bool signal = false; + int ret; - bitmap_zero(signal, VHOST_SCSI_MAX_VQ); - llnode = llist_del_all(&vs->vs_completion_list); + llnode = llist_del_all(&svq->completion_list); llist_for_each_entry_safe(cmd, t, llnode, tvc_completion_list) { se_cmd = &cmd->tvc_se_cmd; @@ -562,21 +563,16 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work) cmd->tvc_in_iovs, sizeof(v_rsp)); ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); if (likely(ret == sizeof(v_rsp))) { - struct vhost_scsi_virtqueue *q; + signal = true; vhost_add_used(cmd->tvc_vq, cmd->tvc_vq_desc, 0); - q = container_of(cmd->tvc_vq, struct vhost_scsi_virtqueue, vq); - vq = q - vs->vqs; - __set_bit(vq, signal); } else pr_err("Faulted on virtio_scsi_cmd_resp\n"); vhost_scsi_release_cmd_res(se_cmd); } - vq = -1; - while ((vq = find_next_bit(signal, VHOST_SCSI_MAX_VQ, vq + 1)) - < VHOST_SCSI_MAX_VQ) - vhost_signal(&vs->dev, &vs->vqs[vq].vq); + if (signal) + vhost_signal(&svq->vs->dev, &svq->vq); } static struct vhost_scsi_cmd * @@ -1776,6 +1772,7 @@ static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features) static int vhost_scsi_open(struct inode *inode, struct file *f) { + struct vhost_scsi_virtqueue *svq; struct vhost_scsi *vs; struct vhost_virtqueue **vqs; int r = -ENOMEM, i; @@ -1788,7 +1785,6 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) if (!vqs) goto err_vqs; - vhost_work_init(&vs->vs_completion_work, vhost_scsi_complete_cmd_work); vhost_work_init(&vs->vs_event_work, vhost_scsi_evt_work); vs->vs_events_nr = 0; @@ -1799,8 +1795,14 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) vs->vqs[VHOST_SCSI_VQ_CTL].vq.handle_kick = vhost_scsi_ctl_handle_kick; vs->vqs[VHOST_SCSI_VQ_EVT].vq.handle_kick = vhost_scsi_evt_handle_kick; for (i = VHOST_SCSI_VQ_IO; i < VHOST_SCSI_MAX_VQ; i++) { - vqs[i] = &vs->vqs[i].vq; - vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; + svq = &vs->vqs[i]; + + vqs[i] = &svq->vq; + svq->vs = vs; + init_llist_head(&svq->completion_list); + vhost_work_init(&svq->completion_work, + vhost_scsi_complete_cmd_work); + svq->vq.handle_kick = vhost_scsi_handle_kick; } vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV, VHOST_SCSI_WEIGHT, 0, true, NULL); From patchwork Tue Dec 7 02:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14E7BC4332F for ; Tue, 7 Dec 2021 02:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbhLGCzO (ORCPT ); Mon, 6 Dec 2021 21:55:14 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:49260 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbhLGCzF (ORCPT ); Mon, 6 Dec 2021 21:55:05 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M56v5019273; Tue, 7 Dec 2021 02:51:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=n9igVpBgk9JOAb2qnFZRgyxT2Xy2Czyi0qJcVvkU+qg=; b=PuFS1pdx0/A7nGWqCcsuiQp24SFXfc9Dtv5UdxyOlwh1BZsChpRSqhJFaAdoRqu5dRmO unWTM9OdLUeDs+vVRNF6NMkx6f+m4vid4buKMHznUTP3ncwDN6uYlMeRHk708GNAfeHE bPC1VDKRa/2icBc8ZP4VMg3l3RoZPjZgYIhTZkekwSpKpnhqMN+0g3H0USlcLKEPrDDu jBzNIf1GXqjb11PKbGuZyKO7FBuGH2zCmvOELtBvxLik5SsIMIjp0BU3gc07tb5QkjOr GFLapearbzmZY8jaHpMJWcJ7LIAEQr2lLd8IWiVx3nuCaidaGZlUhWy22WNEKY/u6dcQ Fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqmefc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:32 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kgld153019; Tue, 7 Dec 2021 02:51:31 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fU9EFChevjslWzDWF/wEQ3PkGtqtgs3eDjK2h/5t0630B56GnCo+2G4aycrjA2lORSQS/2lUOOHUgoFqK5vHjas6qOD2282PEKCTGIavi34bdOJwaWV1JErmvS15Te1UiCCBqWbhGaR8yE2M73d4Fh7pK8dod+eWpid9LyLoo4vNbbL+ecvjoR6xwrNEZ4sMBfT2bHb0L2cv9NRiZgHLkIqPZb3+m4phwLppFqTzNN2mZn3y1GYH0svc6zXxThqYKIrlztvjO/S2wrj6KtgEw2/v/QEqw/eWPlJoDGMqIV6k42NhPjn55W9iyorPYtW1Wl/P6/Ea3IpDX9+qhXRkbA== 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=n9igVpBgk9JOAb2qnFZRgyxT2Xy2Czyi0qJcVvkU+qg=; b=Z2qqWnErN8sLyyUoaoAV7bh3mP1uciLqLwQY1V66nV5s/iEAcchMTYUuGz6QS/WkqvJrGt4Wd4inQGdA0EF0qKwAlbnpkKiqRMyJJTe2PUaldX692128EqIFJKfay9aCvE/60lugImyj72Ttp7Ik56kQ9y5yXQr5+zjacmptf+vhbt3LZVhtIqnYJYWqMhN9vpmEoN6juzA2vpWwKAwfzGKxcTdjtDFECJor3pHFnQEkWD1L7dahBorEe+uiXzLTFytwiyUjbOy9im3xG1VvU2GV3WwdALrYx1qx7NIFdPmjl9hSgooCj2tumeISGSQhpiuzrARoVN69VDDhfuZeTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n9igVpBgk9JOAb2qnFZRgyxT2Xy2Czyi0qJcVvkU+qg=; b=q+It34C2+ZxZYh+mIPLtKTO8/j1vnHqXa58Iybsk3VjfCCxbL5WXlApBVCtYJ6h6hr8kcjObVpfeQ31+awhJtLhAYUAwx/GpCOW+iQsvwb7Rd8kWaU8MsLy69Ts8svwl6Yh3NMKqWB69lQoxpLvweklpoFqu6/D7Him3MgD/byU= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:29 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 08/12] vhost-scsi: convert to vhost_vq_work_queue Date: Mon, 6 Dec 2021 20:51:13 -0600 Message-Id: <20211207025117.23551-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d20dbcb3-df89-42b9-c4e8-08d9b92c77dc X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:551; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ghT9Zmr2WUSxsyYi0tHgI4MY/0vC6FTWLT3Ujk056cmSIKfDYFNsCuFXkFIwiS+oW/8J8ExvvzxlF6zZcRNISWjXDT1qeVV/bJkiWEqp/x7RK9Sghomp3oYPVR2EtF879xi4Bc/Neyzlan4rWoECZTRvKFmRV+Fzm2BwncjnrpUcGDot+86rcbAbJr/vO5atpgKAfTTiI47IzkOpO7mBJNKzqV7oIFEmCYvGStqVTd650PGxDdW6JJnKeKGNP19XLNkT/U2QsRueoOPKJg5XCeCx3pnMYC62Bmp6IzOd4vyNaPeowEdYZyjstf2UXtGnas8rTf/b1Iw1vETDaFTDd4kO9REVcQ/aDaJhA9mlC3NpzomG8ihWebQbxzV5m+Rh2vBGMhX57klwhZOZ9n6zzyCCn+ThZHFQRcpU1cOnrxjXaPjKidvVXTlVICy13eTjDQhkri9ubo/ycxKWuMY/snAvWLiqYsUuDdbepaIeehyREWx+yRd7vZ7ybMFn65pl3pIKqh34pN96vF59minp4kelu9v0lR7u2fRRy0pxxRgCnylKUFcyuHapQWzLFKlNtrOJfLcNA0gLZD6IiQ3bG0LVyT20K/e/fppPfXGXF0IxVOU/KcyLrTRXy3ofENlrEtvUFesEshkHfK7xMczhQbPr8c0zTxrHxV1Zs8GS2WF/4K1frKMPUMCMY2VoK8DG8K1Mj0CuNPhrVFVNhkZ40A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AUi7kHlSgtfFdr6FFQkCJPki5ILgy4rioXyljdp5W+6/eNrMo184xdQmGRRiuX6TNHYqK7nBaEtVWicvBHBtRW9g66otJ18CrdzYtS9pisdCPKKVKHqg2EqfdPf2D1FQb3h7SGaVo5o5MBQIAYO+qW5yIEJKpemHw9KLTA3cP1y+/kc9r7bRVMXC4z0bPDjeyoEZCViGydFhykj8dsd6yjWnMrVfbvzjrZrZphboYyCTfGyLmY7D2idXMGd1dx3kX2xhVFP6k3dRRrGAEUjc9rP03KDNMvYQYp4YLl/zb9g3mxXOSjSsjBEKsxRGbrtKpze43uWyOk7AxYimd5qxly/UdZHBZBzhVL6W4/HfabkyVEm2JMEBci4tbwDwWtv8RKRU5JvIZLkXXydy5RUuq6l8gSdK9i6tz0To14GP+LHomqElvnCOUmmgalIvU5m2vTwkWf/7zLxKcgJ7c/Zt0rCCUKW9jGFCTItYcboHl9fWeKEjBTIYi8vbcCmzhQGFqLB0nQ7OWD9hXlG2BfWJMOEO754Gtpd/6zsCOsXLJLQaHhGdr60qKimccT+PJKwDiOrD7teheSjsDUhUuhkye3hG6CLBgU48NN+7DvtIabTmjGAT9mXbg7sK7XxDnpSNqUYLkKRyFCaZEjKUxLYuf1nVUB8bDuWl2MclLgeKK8lwajESI0jDSypkeNSmChzQT3MVT6oZkniz3Tv5FM0pngGZ3TrlVUjkkHrQnhoxDsOabdj7h/whcHMfEOPM41NHR1LoGO1k1oIWM0hAONoa0JU37aAveKEFn4fI0asnaMoUmegBYAbXde7fGclbyRmv1M6ec4RG9MxLzS0BQn6pRzi8FV0LykYCnRF9ven+Ew21kq1R1RfDC+gl/yBWUj2q1ixlS1iE7Ile9x0sv3R0keJJvzSVaB04X3e23yHTWBI8oP6balZ5mf9cmo3hijZMNdjY277hlynfZgJQ4oaToBr8p01j8LlA0n5kvZK4Il3gVQWs+zYcuNSJxcRvKZGwYAHyU14bjSTedYUHFjRjPuEeavgOuKcPVdXQHvbGK8rsvpLJevWKUpIaZSYzgGTtcpJMzTGDdeHKB3EMPDxJ6uLSrmoLxPYxBS7X51d9BI5nlbz5fxNJFM6w9rhttgH+YEZT/aCXC72OoBaQpUf34+7WwdrEpRksZb476m0VdV2ZfDK9GKO5GrZndqIOtf3rPmwoGb461i/Vc5Z+bd/mJzVZPY3rTvdOkTMUGyfE3fSQtSz83ZrX3ptcBXPZRrqvkc7j4PoxQh0bRAOyAS0JUl179mMpAwePpIF+ZXY5DwPcUcycXIhiLVKdwIl0RWcccw6zp3A/ciGZcgmDE1qFSe63sCGth8Q4Su6y9p/ZBUSLwaMhlN1SlGhvxHrvnz2vKAD7ZuRvf3ExxfA83Xm6cl6A1tlmCC8+LOJgsIeNx6mef8+TFKBPp5vPZi3uAlxTXB/11zzpIEhoZUBS/HqnS41tNjD4ngNZPwTu8iJWhDuld+0UU3UMFq3LcoPvturEhCS9/obexoQW8uNhPhtJrgHAapcM3p0gCXNoXpHHE2WehB4Q9SkCMXRcgbmiaZSgNvr3PMy5JqVo888lyng/YzMQH8rtQfMc+ICBGRqSKgQ6R1aDMxO6VXwNDaZSP9FsiZqzs5xu2p8A1eGNPxjhbA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d20dbcb3-df89-42b9-c4e8-08d9b92c77dc X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:29.1761 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TLoc79Uq5SpBM1SrKFCkWrlgtmMlWqLWPCEDXtaZXV97ZLkIP9IK5l4aBRp4gC8dhraVivCA141FulTaGc1VYdHUiMY+F+z7mBTjkSJ6Cfo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: BC8Yn1-zKo5nlKOmCbcUtkEJR6Mb-LcM X-Proofpoint-ORIG-GUID: BC8Yn1-zKo5nlKOmCbcUtkEJR6Mb-LcM Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert from vhost_work_queue to vhost_vq_work_queue. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index b2592e927316..93c6ad1246eb 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -361,8 +361,9 @@ static void vhost_scsi_release_cmd(struct se_cmd *se_cmd) if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) { struct vhost_scsi_tmf *tmf = container_of(se_cmd, struct vhost_scsi_tmf, se_cmd); + struct vhost_virtqueue *vq = &tmf->svq->vq; - vhost_work_queue(&tmf->vhost->dev, &tmf->vwork); + vhost_vq_work_queue(vq, &tmf->vwork); } else { struct vhost_scsi_cmd *cmd = container_of(se_cmd, struct vhost_scsi_cmd, tvc_se_cmd); @@ -1360,11 +1361,9 @@ static void vhost_scsi_ctl_handle_kick(struct vhost_work *work) } static void -vhost_scsi_send_evt(struct vhost_scsi *vs, - struct vhost_scsi_tpg *tpg, - struct se_lun *lun, - u32 event, - u32 reason) +vhost_scsi_send_evt(struct vhost_scsi *vs, struct vhost_virtqueue *vq, + struct vhost_scsi_tpg *tpg, struct se_lun *lun, + u32 event, u32 reason) { struct vhost_scsi_evt *evt; @@ -1386,7 +1385,7 @@ vhost_scsi_send_evt(struct vhost_scsi *vs, } llist_add(&evt->list, &vs->vs_event_list); - vhost_work_queue(&vs->dev, &vs->vs_event_work); + vhost_vq_work_queue(vq, &vs->vs_event_work); } static void vhost_scsi_evt_handle_kick(struct vhost_work *work) @@ -1400,7 +1399,8 @@ static void vhost_scsi_evt_handle_kick(struct vhost_work *work) goto out; if (vs->vs_events_missed) - vhost_scsi_send_evt(vs, NULL, NULL, VIRTIO_SCSI_T_NO_EVENT, 0); + vhost_scsi_send_evt(vs, vq, NULL, NULL, VIRTIO_SCSI_T_NO_EVENT, + 0); out: mutex_unlock(&vq->mutex); } @@ -1965,8 +1965,8 @@ vhost_scsi_do_plug(struct vhost_scsi_tpg *tpg, vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; mutex_lock(&vq->mutex); if (vhost_has_feature(vq, VIRTIO_SCSI_F_HOTPLUG)) - vhost_scsi_send_evt(vs, tpg, lun, - VIRTIO_SCSI_T_TRANSPORT_RESET, reason); + vhost_scsi_send_evt(vs, vq, tpg, lun, + VIRTIO_SCSI_T_TRANSPORT_RESET, reason); mutex_unlock(&vq->mutex); mutex_unlock(&vs->dev.mutex); } From patchwork Tue Dec 7 02:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94064C433FE for ; Tue, 7 Dec 2021 02:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbhLGCzQ (ORCPT ); Mon, 6 Dec 2021 21:55:16 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:50002 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbhLGCzG (ORCPT ); Mon, 6 Dec 2021 21:55:06 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5CPn004499; Tue, 7 Dec 2021 02:51:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=DkoqjtSG2ATYucz2O/6b9MD6Cz3yAAid8gBClUM0Bug=; b=TykCfqJkJsRmngVCXfkJVwF+RWXXXPdEE4R6atUFbJxr9x7rvhcVdt7XvhecQFr6rXcf utPooisrU5FgIEtVi2w1Zl3rf9Rm1TB7kcbDcTZaBA7oUJKHa/EswZPfHqz3O+CB4/P5 o5e77iC254CK7M3QwaCwLkvu2QF/HD5BkNd2wCFmKP3vWm5rmz36vQ/gopzSyAO7mdyW 7CIyYeQsqo/wn+FrmGHktTb0JRiFQb71e+kUZoNZElpjZBSTXvsZhHWrt+KqtXbEcbtn oyhORhCvQ2+fE8QxJelfm+OCAlpldjtJHkh/uy3vuQ5oY4+ZMvbjmVedZdANi9wP+oMY fw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csdfjbwyr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:33 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kgle153019; Tue, 7 Dec 2021 02:51:32 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by userp3020.oracle.com with ESMTP id 3cr1sn5w2j-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dKvb5ANqeJTkUvNLPXYozS69evUJEtO6qhyGs7rLP319NHBN9ZiZXVM+0Xo8Oqe6Hqnt5LVNWSwObobkjFCmPxXi1eEa8KXU2+Vc+3gWTvcUMscocsk74dzs5qEnwlLJw+FcZ0+EXwV1o80tDmL5ANl5tc/gKMb4zfbiO15AyMn3QHePz6gtpntKDzFDwDjMWzZ9h9PgGaepZf0wRT6XM1zvv2dlPfl6t77IHCY/JPHB4wBBTbsoS/o5oLJfAEAQLip5nDGaFSmgZ5zyQ4yOt+TiWHw7WLU6V9wlhhT2HswTOxxTIZ9w7vF3oMQh0Zrob0r8tVoNAR7xdnmHocIBFQ== 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=DkoqjtSG2ATYucz2O/6b9MD6Cz3yAAid8gBClUM0Bug=; b=gjjdCnRLHPQ/aQRlk7N81nZMPZoyByXHTnImUNcqww7lBb1a0aD/owvub2X0CR7RfsdU9fmeKK38IlbNWNhsUra8u5embqIuz831S42DUuWGDdIfVX8A5FhP0ULFPJTh7syDr31sBDrX7LAwwlyvACHOgkRG9lnvbQibirD96LUE4fXVI6FNhTXQEwsjG/sijzHF4pIYMRqasTyikyPsrPdQgjTk2sDf8ESi2HRdSg85h6PQejSAYpa3GtbcBiunPu18jAqXUJdWCD1xrB8sfK2CCAwVu7dYVm6yatPaaDDE6B8J6ZBvIHiO0ATHEKDh+YeGeE2dXUjKtDksGmrHrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DkoqjtSG2ATYucz2O/6b9MD6Cz3yAAid8gBClUM0Bug=; b=Xf7CIxLprJAHCCJea8vOC3TNia4Sc7qaKoNT/lTWI28UoEtuZekkPNatzyFWj6DsIMdTob/xYaqFZNq/9AZ2YBVqMblY89Bw5QrTMWylgFJxTupYZK7Lw7yUYyH+eMoewJrmMtDaEf6qOvTVEKxul81A/sOX0kstYnPE4+kALzo= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:29 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 09/12] vhost: remove vhost_work_queue Date: Mon, 6 Dec 2021 20:51:14 -0600 Message-Id: <20211207025117.23551-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2589c4c6-8f31-4f1c-2ec1-08d9b92c7820 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y6bFa4kHRAWek9x9G/9tJqiLU0f3CV2bcKReURGt7eetvHvftlfmAnD3dUL4dwzRGKPp4B2rM3S9CN2TJJzrs2DbrkhzQTagzyitZORL4OQWJmL7+iCGqa839SameY5Ml2oIgsuZJCi9+0F6xI4jIfBZDa5l0Eobsx3bGvqqJPapdic5Z+uHnsmfkoyPrzVwnWes4r86FXm9+CjImtUJJHee4oajHkM+UVct9GAivmx6oAq1/d8moFVoRJWeWBWgfTlgYCEfIhr9K29+dth4Z/gQFkjfpTC5kWUik371KKUwEK6JhD60yf5lTlvdI+5M/wEcIQ4AEtco0sUyORhi6R/jRtroKylCNQ3KCiXydgWbiH4+UFasopaFHC6hp/UbOiFJXsRL/5Yd0UYkSls/cZ/3E1eVJcOtWq4UG76AdCM3Fx94uX3/+KXfWjPX0tARrYipELmxbX4p9Xg+slVB91Ib4qFF7VsSaTjBRCioYUpORrnCXHqf8i/j6jg/GQ9P8RJXYlgdrF6ondpJCwKeEkWSUw34fzTBbRZMIHqFuHa3vIfJVuI5Qdqbk6J1zunWlRQe1Up+phx1uKyGLgItG+FlZ3AVvjwXjSqDxQgDF4r2JyRWGUOCPkRFcT1/RvpXyeidWj3BWMu94fkBJheesXAk00QcS2iJCZU7yM17HHbWMrKkeXCbo7jeE7mWzMKQUni0fT2CW+6Vz+3mYhzy5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9FjvqGzpiabesWKIyAZp6V8n+ypmBUSh7qnvUPrp62fbly7JnNhEScQ70UQu4SonCSTwrfScyT+8KPqXOpfnR6ZL0rDQkSITaia9JHIkt7wAkmlA0nCF8kPNmBVH2k3k9y346nuTpBJf+q968MEK0k5bH75MQgVUHToYTHf2RWQ2E4DXhI4GHW/zI1MwEnO2R+QUTgzO6RRdglaS0ODhhcFokOw78f8a9Vkd3mHOsvrfOnmTmmAxSdEZKf9VfLf8p1tvfrNnI6yGjVBfDiYQM2S20efPK1Kx2jxB2gZT83/cDnwKfDyz6UhOUXw3hbA2vbNuBFMG5xcyENhXqWBdjdkIxwG1TWK3Y41/b6DzAR4ZZhJX5R1g6VIY33jcHDgtKj3vbhhrucDuvYG+tq1IZZV5GJnHaNwD5TCQIBBOgt1znzsZw7RVhQaAY7l3xMta6GOleJts+EURBWZXQb6vB9Ty0IQAnNwIUNNUepnfDoMCtlPqOmHVgqtPDgRpKLLiU63gpClnDI2k6Q1hQRAQYr19sMNg9O1K2jAPdpVA5jREop4LbP7wHF2xZ/b0xSdU7Ng9DPmnMSwHt0Pe//IYrO0faqTsIgT6QCK/oYNQ1FLCRtcnO/n3zbEKL2AoGKe7f5xOWrPGtoGjbvFff39MZXaQXQ+yCvFbcvJjjnh01PrPjXgKsc3UhuFcC1AoW2Jh6BgltpMbumAXWNSURwtbWz6CouFSCFC0abvoLOmSHx2yssMJ4iaxdhYv3TH/eufNWEgBV9c+7ceNSATdMLX76SEWWhLWU2a50/6gnWwsv7wR7FIpUrx1grgl1jfuS1vJyF4BvFtT+KgNKV5m4d8eGzpyNt2eVPuHdjIBARedNmTX5RGjkv8NnzE97PGiy2132t8tRkUpLzPeB0iZc6naFPfRCNJk3zAuY7Ln96ERImQh4siC/GYwMk326jZFgKUXeah3tQf2kIvJCMFJcUtBeV/H/hA+bytUGHKW8tgxAuxTBlrl1zZhinNZUep4qjoOlDtYASUpIXR55qh/ABbB+15U8cJQo2pIlGTbfLq0k129DfttcKh+KhwJ9/oPsWozdF4G0+xQ63E0JKeTm7J8ZMOVXkNQBYk1f3C2COhzRnLDD6Kdwv1AgAIimuY5WnMRmEbBIrx5PAKgbQWYOeI4LltLUGepArj0wqFhP+Phy41J4Z4+fcXsRYsbcnYhjJpF9RqrJPK2qjn+5YlvUvB6LftCiJ82iokneg1Cch6WJ9VZx9CZDMiODQr0wLPUGKTdNUXpSe4EoID0e8EwLTzZiYIdr4hEP/Qv/jyaWgSkyFr4DsA/ZMvF+/2tnhTbx6e1N3n07R94Hc9Hwk1XcKPF7Y3+07/3zw6aFH4VYw+SFXEd1scaOekoT6q/uBleJUmi4A1MepuCPVlO697qd52ql/TP9A5Qnyh2MMQdJsIFkXXQOeyNX0EMoCDszQQ3CpQ3kDmZ8/uI85Ml16SmiSLAnEmKmyj5d01hjk1PjeZyILI3N4WbuALI6dEyfFGGAHzEVFV+AXmYmlWNh8gk52QZdpb3JqvsuUAJoXhBjZFF+d+jTSNJp5SYRkK1uKtXD94/ghzGXmEqX06FCu/gooSSQZayFYu0Mo0eeh0zMOrXbEPdAdsgenOZdQVP0SE3/au3dPOcbAI8tWeE7RrJSRHfbA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2589c4c6-8f31-4f1c-2ec1-08d9b92c7820 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:29.5859 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9AZnRSe9Ob59ERgXjDh3a2CsEYMLuJns/1HXGiZtocoVXNGmZ+HaAgRxmgHqS14fWvuVA2J9Qa84fTrarLjKKm9ja03S1f4nT8Bfvtgs8Bg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: -QOCfylhPAFnhSkrI9I3bcgtOfb4SKAH X-Proofpoint-ORIG-GUID: -QOCfylhPAFnhSkrI9I3bcgtOfb4SKAH Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org vhost_work_queue is no longer used. Each driver is using the poll or vq based queueing, so remove vhost_work_queue. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 6 ------ drivers/vhost/vhost.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e9f78f0d72cb..050b8007db8b 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -262,12 +262,6 @@ static void vhost_work_flush_on(struct vhost_worker *worker) wait_for_completion(&flush.wait_event); } -void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) -{ - vhost_work_queue_on(dev->worker, work); -} -EXPORT_SYMBOL_GPL(vhost_work_queue); - void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) { vhost_work_queue_on(vq->worker, work); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 58032429bd05..4423b2420c90 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -50,7 +50,6 @@ struct vhost_poll { }; void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); -void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work); void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, __poll_t mask, struct vhost_dev *dev, From patchwork Tue Dec 7 02:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3060C433EF for ; Tue, 7 Dec 2021 02:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbhLGCzR (ORCPT ); Mon, 6 Dec 2021 21:55:17 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:54186 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbhLGCzJ (ORCPT ); Mon, 6 Dec 2021 21:55:09 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5GdV012529; Tue, 7 Dec 2021 02:51:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=WpJwM0XnAzdcT1gIhNOmvdnESVRp0Jp8i83DqV1c8g8=; b=n/lpzALwbk2BfhvMEbXkl4Jf59pDlOTiXj4/B9s4fS6g6Wktf7e1FeyLgbMg60mbmsKr cZ9Njaegk01HO7j+XV2Cde8FhPZSXxcennT5lZIAXjP+auFsS7hj87IIHGS/XA6nbXYc YiI4575VSDhUC301/LxwSwvqB4XGTHkYo9KadLGy6exZFpIi08QANIPibMa5YfFyCAPG IgTAlXWC/Q4oqIC9DugKd2u5xi08WrTtbvLb8G44H2bDO+47G4QU5tkuNxbL8uDcSJra 73+OFDi5wfetni4hHp56lO4zlB5so5QW/FV0qeb4BXKfqV301yxCCXwecIDChhDPiFTv ww== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csc72c35d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:36 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kh33153049; Tue, 7 Dec 2021 02:51:35 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3020.oracle.com with ESMTP id 3cr1sn5w80-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFqnET4kqrrYFMUWvXqFdWgqdVjjf9pd1bIuW8q3oyLktnxwUJ7Y3092uxXlNol2Bv4ZvAgMrwvWJJGcOQCWDh9YyI48kCdUioxSZ+FfYeL92xpZy4acn4KPFa/IEi9Pp4c8omC1cHsi4TmbpZ15tkjKnjhrQGKEsuo6ipQkxyBwUfjJmOHKUgEmTdLH9I6X4sT/e5xd+UNq0GGIfp+S688047rXMscYnwOYYO7z+bjDfmwP9c2GcTlOZUaLe52GaAdq5zodeUaes8x0WnU4pSedDTjPIVWtyalkPF7qE9zk9lAsvLqErW+ihaQOeyPLpcXyg88iiWoagor7k41FqA== 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=WpJwM0XnAzdcT1gIhNOmvdnESVRp0Jp8i83DqV1c8g8=; b=OuQc4fyrSYkhkev+qAfuM5xvGueEts/8ehy5TO2iG+YSlrvOvVF7YVpC5ibFYeQ5n2nPkta/4IPYPuPm9wiYUvtUToeVLBAkxGqbNzuVQKsr/wTqht0SlvaTq9rCedM/XmUiVOaM6kw1AB+DznQtozKXJ4V3DeBkLP9jVwP32vMuynq9M1bRLL4fXTS6y2jQ/xnc1bq9TJT2bECxhhqK8r8cVWvg0NSMnuDp9ZyPcPEcBaLC/z8bWEvpnw/Wblz0MG2Cwf3Vkl0FY9T4S2lT6io28V45navSiXJuRcGS3xKzS2dVfiItyzHV8F/qeAY41dUYELrOgGwtfgvGDaoKpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WpJwM0XnAzdcT1gIhNOmvdnESVRp0Jp8i83DqV1c8g8=; b=PEdAKbbqYAuxd58jz7/NCkffSD/83oietLbk5apF9UOGKOEh5vy+BmIuU9HMoNsPTSqAvCUDJRNv8U7DKpApKs5eAtep6BzKxbsGI3k0M8hV/+KluMfhLieHitxQiQnLTTAymPetaaNWCNeM7lhzUn0DtZvv+g0gTIizp/buiYE= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:30 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 10/12] vhost-scsi: flush IO vqs then send TMF rsp Date: Mon, 6 Dec 2021 20:51:15 -0600 Message-Id: <20211207025117.23551-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6d6a283-3125-4a5c-a9e4-08d9b92c7864 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VD4n9OgKRlJbLNi2yd1YHwunteqNYKUHFlRg4bS45M1SiN/wG39BCgTbA+bbhNP+8ctYJTxxiL5lxROodo6TND6VGONF9jIzBbv0DMrx6yEymdMXYwHlG27XN+5PoBx6e7cGwIkysR0RnzYqgic6mcdIC/w2PY4n9ugmAKH0plBvP79+4k3Tb0NaNPIOnIaaGodDL8Yb9LA5LE6VEMgcKC6bpOZavkFvJIGh6GmXbGtu3CSJSlOfAJfuXnlqle5Pc1cbKrO5y3Pv9j+T1/ocoTU7fZDJjqMqpZpQxaDzcpfv52UCyXrtHSf82o9geGpObHrKvRL3LO5U8k75WUigIthvk9M7fgLrlVGfTgBi+ZjdaINwRQVFF0vwE97L2NI59UMWKjlJFnc6YaXt/O2tZjZ0JVdCo3FDAUrM+1yicP3KE0bKvlWEI2RUFLpW9432R9XmV9XkDY4i5lPsnhIDF0QDfIC2jQkWDTXZ6VgqAKWTVwstrH1lsgv2BQpcztLMl+XxHcOMWUVOwmQxmmkdHQff8Mt7xWvViv+2sQ8CmITue2kBO2TClKsDa6iv+MfzmQuzKKqr6l+cBy1Fm9GDuzMAn8zBdvudFNUzFSz6+Nz9LUst6Org+S5IKERqAuYU4hrfPeFqiJHCxSPyggk+1fL/wT7Bgl39NM/1WG0BBpjxhFM/OjkYlbRQ37GhRiGR0Wj+0K7D1ncPwNskabMIqg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AoIYetrkpaypo10jrDBJxiGN3qSF7Vf64xkKQZVImvLVqzdSRRiCjJ1uZLRSDpRRuTZwSXp1ZSyPSFoK4v5n1f/q1M9du9X5q7lHe+4xKHWP2Wkf6JGMnCwQgOABiPToLSkFdtAjJXNCg4Ievx67smEGGjGCPOo0cGOTlGJWTnfBmMmJ36GTy7sdcRLDQRruJqjpA518hnGS3NqphUGGkvvDUlZWvyk2fLIATDq3FEu2LQUovEk7+w++l4cTAKMzuy2W2hpprXYUdK4mmASxXvpJS512AvLPBPP9PPIcGE+69tm38zFsRSqpE9cCatgMI7LsHM4MxH3Ay7fe42JugQSlwRxD4fRG7zeyjuA891faJF9yWddALQylQ/yATqtNG0desBUzuWRRJKv4HhQwgl50XPrMKBRpEAfANWPkptmzym2+rzPmFVlJp67TH89ChZIhKg3RdWhPgAP03+kx53DEIzfDcO/DJzpxVsx/N59dHH1W157dO/kCz1oaY35lrAjAC9bTHW1CRpEGF43m/1kB5YBcmTDm9fhvvhZxADXqS5r9UJ73uDHHShvuJ2jL9iC3BuHoZ/1ClS/dFTSh5p1vDzWvP0xfgLwPLJxjiA2Ch0QgWhfJiTlscPBd52in8WCKkuiPiM01MnIf0KKXmIaAMmY76og9Mf/WNmDmJXBtEmEGW9DCaxPc+oACiPmq5nGoql+N6o0XJRt4vFAewi3f645EHRbc8Pdp4I7nzJWE3WBL/P6KmUpxJlwziOnbGnsShGTSvX+PdvFPc4XAxwEgECxf6Minx6kOiPJJfGQsoSfhOqqmATwxogdTzhgxlr6UF+T6bGxFCtqWMDEsAfD4Hg+DP1Wkk2H/TNc5OfRTkCL2gfpi1ZsmfTSx+/ye/dsoSQi4GJjD/DP32AVR6kr4podMIvxbdgvaW8djKqfzQZRooyy+fCgFnl/uBO/6ZJZXcSrM+MWkin6AbpnbvEAPlF+55wsGd0dMKfEoynlRdKxq0bglR/A6Rn7+4mYLNtDzeZDsv67XltN8j6zbPf77u/in0upZWjRbqQu6rmoROrUvDufYmJJFGZovKpiVitFNy5LR0iT4ORtyMhLdJrRFkcjTrALweOGBfaDmxx+KP3wZXZ4kVxXO5BT/E2Jt8q96PUf/ZwDAdlhEJhBixVnCnU+MvUdcCcBzaPLp7OJ05C0i9Ge0KyFiXltJBlg0WuSh+6bztoD92GDjDCHdOyPqN1b77JhwIS4gDV45IfXlhTPDGPpnK+kozBIiNNECrvIqtVYPLD2mqpeX8fkkT+MelnAieu6NQW0j/R8707cP9pZow2ZJ9JWp0Td/oPgskyo42n8wjCRehSriOLUuQ+6bZkMeE/nyEF0xs+Xf+NxGq/QXvNCeDT42alr84nDbn3Q4bNmjmaHySRW+LuCtbb/aW7TsBRAJhjCAH9pqJaWBvwsdM2LlArkcGmki0MfL/Y+TG5j9euzwjiQrRtl7klY2DM+Vyn39TvpFAKPynJGjPGphwSNGJspNJuKogx/vwhNWUraAjORqegc6qeUBGm50smZz9EE/wytm8/J4lev9FS5nWYBB9KNX9xKQprkyC585MC+tAD78TDjj6OPu/XZ77OZwFxaEreDlRdRuQ6ptCmn9lP+tVMcxQyre940WJuN7pWtCoMe2A4EwLwtE9A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6d6a283-3125-4a5c-a9e4-08d9b92c7864 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:30.0297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bG/9OpukN8LHSd+ZCriqg6wGtNHozQtipQtFxvG91UjaILkwlubS9HlQlwPKH7VggT06u0PaJNlm3NDt+Vl5HYl7F7kM2J9iz4tl+3vJL48= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-ORIG-GUID: DVHLnu3GaCbUn6TfB_TVSGkSSw2x-vvy X-Proofpoint-GUID: DVHLnu3GaCbUn6TfB_TVSGkSSw2x-vvy Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org With one worker we will always send the scsi cmd responses then send the TMF rsp, because LIO will always complete the scsi cmds first then call into us to send the TMF response. With multiple workers, the IO vq workers could be running while the TMF/ctl vq worker is so this has us do a flush before completing the TMF to make sure cmds are completed when it's work is later queued and run. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 93c6ad1246eb..33e3ff4c1f38 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -413,7 +413,13 @@ static void vhost_scsi_queue_tm_rsp(struct se_cmd *se_cmd) { struct vhost_scsi_tmf *tmf = container_of(se_cmd, struct vhost_scsi_tmf, se_cmd); - + /* + * LIO will complete the cmds this TMF has cleaned up, then call + * this function. If we have vqs that do not share a worker with the + * ctl vq, then those cmds/works could still be completing. Do a + * flush here to make sure when the tmf work runs the cmds are done. + */ + vhost_work_dev_flush(&tmf->vhost->dev); tmf->scsi_resp = se_cmd->se_tmr_req->response; transport_generic_free_cmd(&tmf->se_cmd, 0); } From patchwork Tue Dec 7 02:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6871C4332F for ; Tue, 7 Dec 2021 02:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232066AbhLGCzR (ORCPT ); Mon, 6 Dec 2021 21:55:17 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52686 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbhLGCzI (ORCPT ); Mon, 6 Dec 2021 21:55:08 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M56An019276; Tue, 7 Dec 2021 02:51:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=nTH3clUOEM+dbqJQFParaCo7XSrE4LwcicG5ZL2R4hI=; b=K/qLkYzK8FawnUMMbMFqz3Ci+eqYMK9iiRALQg0S6Sq2HsrY3LHk9FnfKFcX3HNsqjqo AYlWUHZINKCLUQStr1jDOWJEigjoWmB4aU5abbtFGDFRvxb0hzw7Hb29EBgo5Bm791bo u3fj4N56DeBCa2x4twfKuxRuIMQA2ej6hns0hPHnIk7FrOKegLRz6xfDgG1lN0jIX4ID J0Jx7zTJXxpFgOTU5yMEXiKQf7C6ntYnPlvdNCJ5IHv4GRSBq28pjmRgS1e4w2Nrf9nl TSlpCoc31tN4glgy2AHRN9P4CKiYIoQsa7dnXo3n9ane7AGrgs5JoV1oIbRAmIAQA4gL IA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csbbqmefe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:35 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kh31153049; Tue, 7 Dec 2021 02:51:34 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3020.oracle.com with ESMTP id 3cr1sn5w80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SusmI+MeY2vH9EIH4tLhFctegSh9FVHa36YPIblH2Hap6zIId+p3djbqgsKuMDVMfv9m8ko8CUhtWJqCuxAY66hCWKhCOiIEkx7DB9K23MxtAaZcFWybsn5scBbDLeA32JIORGCVcYCrsxwlRbk/kXMkc497d1OnTKCsia1zMnqy3yU+Zv+IEPAV09kJRVYsFKM94YvGBDxqv2Uhd4C5HrlZwhpb5jIUM/lNJkX/u1sABS/W6oMFEEV3VElpMwjRPnjRspRZ8gH5gn3HLAc++uq6Z6hUvYueUYTFsPNSdurMowLCta/7wBm1AOyMKSQUzQrasQqLqonM1P7yNm41Og== 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=nTH3clUOEM+dbqJQFParaCo7XSrE4LwcicG5ZL2R4hI=; b=B1OzYL6c9ln+BZ//lHmOO2fy6ns+Rad555T55ZrI7Vbg6ncoD5M+j1R867s/F0ZSiKsMwPNIPyVP03iAtFc78k/5UpcYTY34WYDvNgEULG4GIh0ZB3P4QtIOaQGG8VHF8B3XigGmtzWp+mMVKT+7QM/sg30zZIsE0CG0Cg2WmSanoRxDyI6K/VcB3yHhTc26aeCrAUOph/+dsZuHv49wrBOBC0yEl0EGub7YxT4ZR3RULHqgSS6MBi3JK+BeAnp6bVFUvxHZIw6MiSFqtKt/vd3DStAoGSm87GIoICh2F3nevCBxu59BBNv3e9HRg3w4f4QuMzlUcZOiYdR1FmNatA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nTH3clUOEM+dbqJQFParaCo7XSrE4LwcicG5ZL2R4hI=; b=fxKRPRRXu1MHsrW6Whnyd7yGWhMRVFkKCJKOlvD3DaMWxP9yYzV5ueVHHOpS8odf7epKrrxqkAvFt1DyMTitwlmHoHK0AZq1vrcy1ynyUlUOY8Wci3Teb1uymjbqJU7bxa8c517uohYgQHcotm2B/wj04waw90kWCD5aldXirx8= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:30 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 11/12] vhost: allow userspace to create workers Date: Mon, 6 Dec 2021 20:51:16 -0600 Message-Id: <20211207025117.23551-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b649f04d-8db7-4135-dfc9-08d9b92c78a4 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5v6iUBj0MHE+WNusvFU6tGEr0ncQJeNv+2rNkSB4d7UZNqUf/A3Ei+op9EnsnkDi0V31iV8f1o7SRYM+P7X50TZnOtMUJaRGSM0kuhqL78jscrDYXuo7mdeX4sZtl2mvKBl88RlnqqeC6cH3GDQAf3pmW2hk9q40BtNA008OLH+vHEW4t75DGoLfoGNPWGgwvyqzmbX3RL2Y4G2WInIoVUn70rpsmWFZa49Yl1iYoSjOhcVidmaTod/cGA84Aft3KGMt8o0a761uQWznR303sG1bd3XGNpYzpN08yuWk/YlOPKmZ9YyzJC65WDKV0mfd/gevEH2yJg63s6Mngg8df7NLkp3VtPROVOzCPEsy2qUvuudp2GGXGDPvFff+53ngJ9cNK/ogA+zTjVfGCGGZf49Yn84GVcSK80LuW7KHx5RjAj6bBS3WlquWJ1gjTH33Ko9fsKDHNPIczELNb02QXdjSfVc1Mx/dUGzJPxzI5YunpiUctVGrR8oDbjlUuODa8HYkBncY2yl9XNijg7cJO+cADTE9bX1sjgaBg+37M+rtyJIK4QW1AmZxmidIvgfbbojuZLN/gDNWXo9utUai7uxd5vlLs79V+9iyPHlqxAjWhzHr7BieK9lzUaSnbIM5luPhVluZwhZP4Yde2QX1jV3XFLwwrOfAsquEshQpVfEWU7kW8AZG1A9JTgMlGufq+XG9kf1RHHfQS7EwwwxZ4A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(30864003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EKURCg/NCwumANwiGGaTN0G35dyVzJ1cbYNlwPjOjYEqJRQal1+ZrZIng/7yD6mrhUYgUxnHNycyD1S5/vInu4AcBo5v0wh8FTx4yoggpTXfDYdjfuKPe2n82fU9TM3yGKrNyW6mizdQ+YwciYKlOtWtaNMrABQ+yPhFeSWff/WjyBsqKWJizyjFBQFFPRKu+EU5fjmssC0ZETaAX8gNnMflD4N/R7Qfg/p0QNMxo3/EqjjAedFtK1HcpCzeWgWwfQreAM4zSnMqhdRvFD3o5xtxHvwZygpF7uygtC86PqPayopJgm6eS1EfkT1FCpclobCxFuSg6AnJbqueCZtgL9a/FkKfeaL0mCrDXr9tziUBYxWLobI2hYGm2ET9GQHws3IPAaId7Dj/IiymjbrQJ3Do+P9RcbcpWc7pTKKus/YbuckSOvEJ70c7EbzLfbU+o91DoswtyhHVXhd0vWbF7BqjCb/BJppTPTl9BzonQol81EynT76Rb5qPu76egGQDXuJL/W7Vg7RhmSpvnbDjms/4nrVuIWB3UVSa9bq+7rX/PQBgmlZQLDz8dQscW/tgNCNb+VlFVHlihe4Kg2OHwkzQXIjVdC7CdVA6pptCNlX0eQuKjmvW9sppME/qEwPJAiVF19IxlXa2jgQFW73NmwS0LhEaSk4GHGRasjUNwf9oVw8uAm01p4VTirryKl0Q4loed086hSgJomm3YB8ujB2u7+frF6ZUNFUrU8INphigvdZOhfshYY6PQOgQkGmpGljKDmm4b0wRjsOFxUfN+HsZkrMe7Dv46EiZz0jb9ot9pA7R0jaP58f7qklQYqpdTAg4XH7zi6CY2orkqOIiozrTgiAf1dH6Ai1zpgiLvlYySY//wjMq6j1dLa7Vb7xmcBU/sYOJUIaghU3h8ywyHXgReB6hQ+S015zYzYcG5DJEktBQrvnlzHYDMv7ReecPPEVlNdOX/G17AK/HTYaS8QPIHHK7neR2VHNJoqnTKajak4ZgJ+OROim6+w5UA6SiesO+vyRNJ5YEfw95URMIXVehKtGbQejsofL2DkrU9nyp1hjl5J7eDVEPLSElan9LAuwbsITBKbJ1BG9SqGzyTabZMlL9FjHRsCfuhBUOReYFWAco8U/jxiBh0E4FiIowmXZ71WtFfhdiswHsO2Z6qPlo3KC2AP8Rmh6klUviZ3/2B7eecQss5vtNms2A4m7egKAzZXZXHdN3a0U/672hmAGzimkW7w5dgKD+rijOYRJDVcOS9aIfYcgZ1pTS+eiVon1y0gNotLvM3XkB4O2ipEpmg8EsAFgkxYygONu4a9B/chyRsnMgwQ6NLYqviYHrb8+pOcRMpfXrtiQg4kgwXnDeE8fKm8b2t9WY+T8pXRQGqTS862kN2LMejccqn14yHCH9YZj+bD/AJxQKAdc3PCFAGYLlx2p2IsIU3tY1TBDPHZXH1XDDoGhn20ETGNFg0FxSRo3i49GIOGrmE9KuxlkC7LlJUQUuavf94sHZETJtpuwoQZFewOrIttGpW4J31F8jPwT5x3qHo139LZinL/Mz5f+Mv5Ha8rAWpBZaOLbGzvAVPFAmwdVHZnJIJWUrr0aPQYcgOAK6jSB8k2tNFOnhQJatfWe7TPFEtVrk8Uhz7k7AAR7/VhbJMNvYEmxc/KDwlPPGO+CwZctjqBirTQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b649f04d-8db7-4135-dfc9-08d9b92c78a4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:30.4815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +Etd1UzuI++iYrILa8Jgu38SlOC4EoINd2UOxz+rVBx6BmQ6BMaZxBtEf8KGvptsA4n1FiH7DGajpZWICCSc2wodxnZ2Nu5jK7q2/bnP9Zg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-GUID: KcOt800NaP9wf2MseGdiquoLbkZUgETP X-Proofpoint-ORIG-GUID: KcOt800NaP9wf2MseGdiquoLbkZUgETP Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org For vhost-scsi with 3 vqs and a workload like that tries to use those vqs like: fio --filename=/dev/sdb --direct=1 --rw=randrw --bs=4k \ --ioengine=libaio --iodepth=128 --numjobs=3 the single vhost worker thread will become a bottlneck. To better utilize virtqueues and available CPUs, this patch allows userspace to create workers and bind them to vqs. You can have N workers per dev and also share N workers with M vqs. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 164 ++++++++++++++++++++++++++++--- drivers/vhost/vhost.h | 4 +- include/uapi/linux/vhost.h | 22 +++++ include/uapi/linux/vhost_types.h | 15 +++ 4 files changed, 188 insertions(+), 17 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 050b8007db8b..1af43b5d1dbd 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -248,18 +248,16 @@ static void vhost_work_queue_on(struct vhost_worker *worker, } } -static void vhost_work_flush_on(struct vhost_worker *worker) +static int vhost_workers_idr_flush_iter(int id, void *worker, void *dev) { struct vhost_flush_struct flush; - if (!worker) - return; - init_completion(&flush.wait_event); vhost_work_init(&flush.work, vhost_flush_work); vhost_work_queue_on(worker, &flush.work); wait_for_completion(&flush.wait_event); + return 0; } void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) @@ -268,9 +266,16 @@ void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) } EXPORT_SYMBOL_GPL(vhost_vq_work_queue); +/** + * vhost_work_dev_flush - flush vhost work in device + * @dev: vhost dev to flush + * + * This must be called with the device mutex or from the device's release + * function when workers cannot be swapped. + */ void vhost_work_dev_flush(struct vhost_dev *dev) { - vhost_work_flush_on(dev->worker); + idr_for_each(&dev->worker_idr, vhost_workers_idr_flush_iter, dev); } EXPORT_SYMBOL_GPL(vhost_work_dev_flush); @@ -485,7 +490,6 @@ void vhost_dev_init(struct vhost_dev *dev, dev->umem = NULL; dev->iotlb = NULL; dev->mm = NULL; - dev->worker = NULL; dev->iov_limit = iov_limit; dev->weight = weight; dev->byte_weight = byte_weight; @@ -495,6 +499,7 @@ void vhost_dev_init(struct vhost_dev *dev, INIT_LIST_HEAD(&dev->read_list); INIT_LIST_HEAD(&dev->pending_list); spin_lock_init(&dev->iotlb_lock); + idr_init(&dev->worker_idr); for (i = 0; i < dev->nvqs; ++i) { @@ -568,31 +573,59 @@ static void vhost_worker_stop(struct vhost_worker *worker) wait_for_completion(worker->exit_done); } -static void vhost_worker_free(struct vhost_dev *dev) +static void vhost_worker_put(struct vhost_dev *dev, struct vhost_worker *worker) { - struct vhost_worker *worker = dev->worker; - if (!worker) return; - dev->worker = NULL; + if (!refcount_dec_and_test(&worker->refcount)) + return; + WARN_ON(!llist_empty(&worker->work_list)); vhost_worker_stop(worker); + idr_remove(&dev->worker_idr, worker->id); kfree(worker); } +static void vhost_vq_detach_worker(struct vhost_virtqueue *vq) +{ + if (vq->worker) + vhost_worker_put(vq->dev, vq->worker); + vq->worker = NULL; +} + +static int vhost_workers_idr_iter(int id, void *worker, void *dev) +{ + vhost_worker_put(dev, worker); + return 0; +} + +static void vhost_workers_free(struct vhost_dev *dev) +{ + int i; + + if (!dev->use_worker) + return; + + for (i = 0; i < dev->nvqs; i++) + vhost_vq_detach_worker(dev->vqs[i]); + + idr_for_each(&dev->worker_idr, vhost_workers_idr_iter, dev); +} + static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) { struct vhost_worker *worker; struct task_struct *task; + int id; worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT); if (!worker) return NULL; - dev->worker = worker; worker->kcov_handle = kcov_common_handle(); init_llist_head(&worker->work_list); + refcount_set(&worker->refcount, 1); /* * vhost used to use the kthread API which ignores all signals by @@ -605,14 +638,88 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) worker->task = task; user_worker_start(task, "vhost-%d", current->pid); + + /* idr accesses are done under the vhost_dev mutex */ + id = idr_alloc(&dev->worker_idr, worker, 0, INT_MAX, GFP_KERNEL); + if (id < 0) + goto stop_worker; + worker->id = id; + return worker; +stop_worker: + vhost_worker_stop(worker); free_worker: kfree(worker); - dev->worker = NULL; return NULL; } +/* Caller must have device mutex */ +static int vhost_vq_attach_worker(struct vhost_virtqueue *vq, + struct vhost_vring_worker *info) +{ + struct vhost_dev *dev = vq->dev; + struct vhost_worker *worker; + + if (!dev->use_worker) + return -EINVAL; + + /* We don't support setting a worker on an active vq */ + if (vq->private_data) + return -EBUSY; + + worker = idr_find(&dev->worker_idr, info->worker_id); + if (!worker) + return -ENODEV; + + refcount_inc(&worker->refcount); + + vhost_vq_detach_worker(vq); + vq->worker = worker; + return 0; +} + +/* Caller must have device mutex */ +static int vhost_new_worker(struct vhost_dev *dev, + struct vhost_worker_state *info) +{ + struct vhost_worker *worker; + + if (!dev->use_worker) + return -EINVAL; + + worker = vhost_worker_create(dev); + if (!worker) + return -ENOMEM; + + info->worker_id = worker->id; + return 0; +} + +/* Caller must have device mutex */ +static int vhost_free_worker(struct vhost_dev *dev, + struct vhost_worker_state *info) +{ + struct vhost_worker *worker; + + if (!dev->use_worker) + return -EINVAL; + + worker = idr_find(&dev->worker_idr, info->worker_id); + if (!worker) + return -ENODEV; + + /* + * We can free the worker if there are no attached vqs and we only + * have the refcount from the initial creation. + */ + if (refcount_read(&worker->refcount) != 1) + return -EBUSY; + + vhost_worker_put(dev, worker); + return 0; +} + /* Caller should have device mutex */ long vhost_dev_set_owner(struct vhost_dev *dev) { @@ -632,8 +739,10 @@ long vhost_dev_set_owner(struct vhost_dev *dev) if (!worker) goto err_worker; - for (i = 0; i < dev->nvqs; i++) + for (i = 0; i < dev->nvqs; i++) { + refcount_inc(&worker->refcount); dev->vqs[i]->worker = worker; + } } err = vhost_dev_alloc_iovecs(dev); @@ -642,7 +751,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev) return 0; err_iovecs: - vhost_worker_free(dev); + vhost_workers_free(dev); err_worker: vhost_detach_mm(dev); err_mm: @@ -734,7 +843,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev) dev->iotlb = NULL; vhost_clear_msg(dev); wake_up_interruptible_poll(&dev->wait, EPOLLIN | EPOLLRDNORM); - vhost_worker_free(dev); + vhost_workers_free(dev); vhost_detach_mm(dev); } EXPORT_SYMBOL_GPL(vhost_dev_cleanup); @@ -1604,6 +1713,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg struct eventfd_ctx *ctx = NULL; u32 __user *idxp = argp; struct vhost_virtqueue *vq; + struct vhost_vring_worker w; struct vhost_vring_state s; struct vhost_vring_file f; u32 idx; @@ -1711,7 +1821,16 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg if (copy_to_user(argp, &s, sizeof(s))) r = -EFAULT; break; - default: + case VHOST_ATTACH_VRING_WORKER: + if (copy_from_user(&w, argp, sizeof(w))) { + r = -EFAULT; + break; + } + r = vhost_vq_attach_worker(vq, &w); + if (!r && copy_to_user(argp, &w, sizeof(w))) + r = -EFAULT; + break; +default: r = -ENOIOCTLCMD; } @@ -1764,6 +1883,7 @@ EXPORT_SYMBOL_GPL(vhost_init_device_iotlb); /* Caller must have device mutex */ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) { + struct vhost_worker_state w; struct eventfd_ctx *ctx; u64 p; long r; @@ -1824,6 +1944,18 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) if (ctx) eventfd_ctx_put(ctx); break; + case VHOST_NEW_WORKER: + r = vhost_new_worker(d, &w); + if (!r && copy_to_user(argp, &w, sizeof(w))) + r = -EFAULT; + break; + case VHOST_FREE_WORKER: + if (copy_from_user(&w, argp, sizeof(w))) { + r = -EFAULT; + break; + } + r = vhost_free_worker(d, &w); + break; default: r = -ENOIOCTLCMD; break; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 4423b2420c90..1738388fa02d 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -35,6 +35,8 @@ struct vhost_worker { struct llist_head work_list; u64 kcov_handle; unsigned long flags; + refcount_t refcount; + int id; }; /* Poll a file (eventfd or socket) */ @@ -160,7 +162,6 @@ struct vhost_dev { struct vhost_virtqueue **vqs; int nvqs; struct eventfd_ctx *log_ctx; - struct vhost_worker *worker; struct vhost_iotlb *umem; struct vhost_iotlb *iotlb; spinlock_t iotlb_lock; @@ -170,6 +171,7 @@ struct vhost_dev { int iov_limit; int weight; int byte_weight; + struct idr worker_idr; bool use_worker; int (*msg_handler)(struct vhost_dev *dev, struct vhost_iotlb_msg *msg); diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index c998860d7bbc..117ea92b3925 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -45,6 +45,23 @@ #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64) /* Specify an eventfd file descriptor to signal on log write. */ #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) +/* By default, a device gets one vhost_worker that its virtqueues share. This + * command allows the owner of the device to create an additional vhost_worker + * for the device. It can later be bound to 1 or more of its virtqueues using + * the VHOST_ATTACH_VRING_WORKER command. + * + * This must be called after VHOST_SET_OWNER and the caller must be the owner + * of the device. The new thread will inherit caller's cgroups and namespaces, + * and will share the caller's memory space. The new thread will also be + * counted against the caller's RLIMIT_NPROC value. + */ +#define VHOST_NEW_WORKER _IOW(VHOST_VIRTIO, 0x8, struct vhost_worker_state) +/* Free a worker created with VHOST_NEW_WORKER if it's not attached to any + * virtqueue. If userspace is not able to call this for workers its created, + * the kernel will free all the device's workers when the device is closed and + * the last reference to the device has been released. + */ +#define VHOST_FREE_WORKER _IOR(VHOST_VIRTIO, 0x9, struct vhost_worker_state) /* Ring setup. */ /* Set number of descriptors in ring. This parameter can not @@ -70,6 +87,11 @@ #define VHOST_VRING_BIG_ENDIAN 1 #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) +/* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's + * virtqueues. This must be done before the virtqueue is active. + */ +#define VHOST_ATTACH_VRING_WORKER _IOR(VHOST_VIRTIO, 0x15, \ + struct vhost_vring_worker) /* The following ioctls use eventfd file descriptors to signal and poll * for events. */ diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index f7f6a3a28977..d38a023e494f 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -47,6 +47,21 @@ struct vhost_vring_addr { __u64 log_guest_addr; }; +struct vhost_worker_state { + /* + * For VHOST_NEW_WORKER the kernel will return the new vhost_worker id. + * For VHOST_FREE_WORKER this must be set to the id of the vhost_worker + * to free. + */ + int worker_id; +}; + +struct vhost_vring_worker { + unsigned int index; + /* The id of the vhost_worker returned from VHOST_NEW_WORKER */ + int worker_id; +}; + /* no alignment requirement */ struct vhost_iotlb_msg { __u64 iova; From patchwork Tue Dec 7 02:51:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12660943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1911CC433EF for ; Tue, 7 Dec 2021 02:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbhLGCzP (ORCPT ); Mon, 6 Dec 2021 21:55:15 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:53742 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbhLGCzI (ORCPT ); Mon, 6 Dec 2021 21:55:08 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6M5EdH012504; Tue, 7 Dec 2021 02:51:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=u00qoDBdAGW0JGm/dcunSrWRtUIddYZAsEHgU5/auDs=; b=TgnAvA1yU9haIXc+aP1anjuFsO/Dp+auNNYfDkPNU3/Wa2AC+FJXOZDe/SSf8zzXERxB USKJBNiy/FfBYRsKo/MMkES3PO+cnq9sCQRZ6lgsuA5yBXiUJc+S2oNipggfiKTtySsz n7xdOth1sOOwjD2N7oDYr57KyIH1/pktwnDQL+RLwl3lCT87KBfkL3T3erSs0V4LQ3dC z6LzuIfpcLRlE1+U0FRfMSJu2FuUK9nIis6bbNGln1Nw7ey5LXtfJYpE3tKs/602BAuG LsoRe4MUzUwkog3Wy3hA6cYte6kTVl8e6+iaULUe6g4xF/xCa6Vdb4kQcly2Xe7rsB0p Ow== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3csc72c35c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:36 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B72kh32153049; Tue, 7 Dec 2021 02:51:35 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3020.oracle.com with ESMTP id 3cr1sn5w80-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Dec 2021 02:51:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOEg651gJDDjKKxJa4D23B3N7qzsGUsVPmLIfqYuHgffJhWUcrhgZBppg7WvIClFFVwjIKqqcDetSjHxoDUfYLnCOv+/n/9/5ZdOQMUaiSoM3MrR6mXS62JmlaE90kkAAWD9CTqmU3G+IZXUbaE8FO7CFk3LSfBjWENjnvO+ZJk+a8VmNgtimYATRZA97SvGX2sFgnPondP96TWWUs8q/4Kg6ejPSLw6m2bj1FsgeGserAaBAlVwAhwdsIKOMBBCzp9vV6+FUVymgyOAOJzuSHI+m+mGdBJ9LfTZMsmWuWO87x/ii4XiD5amFI+Y9PWLWkDEAc5GR4ya+KT9u5Z8wA== 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=u00qoDBdAGW0JGm/dcunSrWRtUIddYZAsEHgU5/auDs=; b=CzsfACGAzrBMGpGZ8jFACAwNTUMKYX3pKtjOa09Mb1q8aV7MGh/KlE+O0P2C3guhhjxV6kUjJE1jDRfwTDcSKTKVtT19yMd/vSgYGNmjr4DTrFmsAoSIRYsRcpxdIhWLqFvKZkUqR5QImhg+q2SAUld6yB5rH1gbRhHRNvFBwsZAuR76ZNwzlDEq8DEUJV3KszCihDni5qAYaTx/+SZARxBVTcAupmBDUCU2n3H5yBb79tRZlMY8dgnjPpHmlbuJXT5QBc0tNl+zIR6Kt/bG3gXBpHc1j8Vze9EEdGOQ3R94P39hBcsjifZqXDpcMzk5fos4b9nD7vcV7B7EsyWlWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u00qoDBdAGW0JGm/dcunSrWRtUIddYZAsEHgU5/auDs=; b=GBLyrkVEPzJF02uBpEAbGodxdiO3oX7LMQRvtN472PHEfroGIPUB5IcRb/SF1BbFsrHAFo2l0pGcgmpQ6+FkJlReS3XFJYmf0y3vzsMC3+lgcoSxjkEkOmGhPJb8GaLZgx16VislO4TeISA+gSF+Wst/oRusl0CqlIep5CzQF4k= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4347.namprd10.prod.outlook.com (2603:10b6:5:211::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21; Tue, 7 Dec 2021 02:51:31 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4755.022; Tue, 7 Dec 2021 02:51:31 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V5 12/12] vhost: allow worker attachment after initial setup Date: Mon, 6 Dec 2021 20:51:17 -0600 Message-Id: <20211207025117.23551-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211207025117.23551-1-michael.christie@oracle.com> References: <20211207025117.23551-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DS7P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14 via Frontend Transport; Tue, 7 Dec 2021 02:51:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0f4aa0b-bac7-48b7-33dc-08d9b92c78e9 X-MS-TrafficTypeDiagnostic: DM6PR10MB4347:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8n9n5LdCtmGJJjWZkumTIEMIN/uxglk1h6wzupgLjq5o4aRU9xJ9h0F0D2WXcn8G8ag1Uf06u+iIAeQEkkFSRkBiMzvkcJS+fdsQlEo/Ks6jEAFNk5oSxQGH1P5zR4ySoXbYbZ9iQNOkKfG8Y1MLqQr03C+wvU2a0cvX3iZEI3myTlxyVVGeaP5WE7AMCzwPXaFk+nud1YrEeTYyUCNxu8Es8Vd6y8jIkkOJFmOtPPiRbC9SUPvNABIZwlhHdS7fxatD+Kpv2FRPZP7C3QPcWzA7Pj21dLX1HR9bTB/Y2bDMtVtqay+yi2mSnf9RMNZwuUydra+h2s7x0S5Ov+Bugw2RqkmtrIt0O3iqP2M0RWSNM39JNSK1BA7NiBMNnfKYSM8SD7zYeaLJ8u5VH+kQxEbcjcEZCtwWanfrjh5g2T2IwE4VawVEhElNJ8ZEnrInGARriR8PQQsNV3ob030mubXmH+aLl5wsNLSJdYdDzSp/vVUzX2fv/G58tzJqILnWwSeMjNqksIvp2CPPzz0Q3JodTAPjbBMb2L4GAE5kK1u6k0/Qxuf68MO5Q++rRxw7cDqdNWPEoUK7B5UIdhJMu1YA7OnbVw/tXmqVi2xhhQk8vZLGqFCBpiIQpz4caDq2wy4rsKN5Pm2lCi25RWDOVwz0dtV+jt/+DDKdJvu5+D3YXFZUB8tSNTbQeI74aeFnTUhopBrSGnlUn7mfZJ6GTg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(6486002)(956004)(107886003)(83380400001)(4326008)(5660300002)(1076003)(2616005)(508600001)(2906002)(6512007)(86362001)(66946007)(8936002)(6506007)(316002)(36756003)(8676002)(26005)(186003)(66476007)(66556008)(6666004)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TPngyCTHx55RjRh/QX222ZjWgdmwyWat5E1cUhJAioEy0R4g4VEXXtbVMP10UNimzJsv6fAJwb+ipAwE0Cc867PEMp9SyF9lmpI8XAyNnzx8AEtK3asJqZxhL4oek421Y72QQc760wsBavy2ro7/UfbDQIsJ+hPTSyEG6RwE0zOttLtYkuefoM3g7Kym38V4a6RNDzipmwysKWOit40ijorskmAIL4sZM2rnswKVPpeMamnBMlsS5qStkrBMEqMF2pyyCT9r1CEcRGVw9abOVk3ad5BWNdEMEiO146HtzNVH5sRHzSEPNEHIyBUcvXMiTUvYVvVkwDxovk8VBMLCn/SQhGIxQ/3VKCM3oEdiULCcXvCbt7HgB7uige4argoFErflWhd1oSt9xpOWPECX+byK94TbA0lqRSofTvNTjh7ypZGYf1uHhnsXlsyrc0bp2+2Q1gjQrHYiKzGTOJRgc5EJeRhl+09YXhXkwgdMUw9/hYkzDRMO7YWFtaFMNt9Il6vy3QpfDUqm4SDuS9/W+sU51N7DKcSnSKoR6voCglaQZ0cSS+a3os5Vncc8BqJ+fW8c5rs+YE59XLAGgdqHhoObywb9dfEf7Pfpc8S6JCe710cW90iqkj0ycX0SBuQtTqR/Ri5VDIjzh5hk8LFYfpp6E3o03DjT/94XzgY8DyAKj2XW88y6N7kIyZBUMHBSwuTuQx1GzoqO3KJ+ksbaSFCdckxE9809qmloSUvput6efRNy+JG7NOLqTZwU+e0NRtfY4yzYWvIZ5i5jg2lEke+j8q7PMMpC+viDkWCTsOx9azwCEi02CI2UhvScXu0J+wkviUPJmCsdum/NYzHpi37+oEcyeGeZhA/5NW4ya6vNkF/YFHnu+tFKjliwcpNx9TZ2wUWHaE2ScBhs9IOygRoOhYACt/v0syZ9I1cukIptcnX4/O0Ur4+Zq+Bz0wINVm/Jv8onIKIYhsDJV+AnbxIw7996b8YlVjLt6Va4x82SaT7WA3z853EZEv2jlKhZclgAk0xEJQWfJIQKf1LzwBGyxoBpyJymChoWCaUbp99pTlvq0cxJNd2JfSFg0JQsf7Mflu0ZR4HYPCcVl35HS9rBgyij7dao9Mwt+txDzHO/24S2yAD8ZvvSvk5SeRdzRgGs93As7/yqO19UVI8AURwrJQgxbSDPI1hCXe3nxDySne8VuzCzaW3jjhpbOnQW7vrcB/Sab8GQFnRNZs/ZfQMA8me5T9X5RRJwaWF3x9PxJTrAaVXmnxMOSTGxAMIN/iXHsZ3iOkfBlEsZ71/GwXTprKEpiKCNHF0vgh2lun26r8cy4CWCQQ095OPP/L6fvGGIbqXzo5QNMxWtJZ1V0mzygpl4MmtNwF8L66m7dGVxlo1KqBjwoLKU5H3iTcTE4vJbTFXg4RRp9TzPTSO8o3BBPcFCQZurLvWzJUOWKVrj7/87oUXmVJyIhDlHFlimHojbAIrQshbzdwU2gHrHNMpD7uMMjufG5RV0P9wTIEdqjo+p1nfjSzJmFzJR6VCMfdiaSXiXqFmWZ/ZmcZpUgMtFJDmUfbfWtp8itJs0sNTgOaY/FjUEG4ERUEMc+voyYXjbvAkANCq+hKtBHAldSAyI4MfSkoXXX/XMT171nw2clhRJXL+yBdDvA+MjeeaDJyYLCqAFZq+0TEckfFmcnQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0f4aa0b-bac7-48b7-33dc-08d9b92c78e9 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2021 02:51:30.9173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8YPlwB7DYY79dyPVnlzmgsY3x1SHlsXgq3/iz/9UjBbsi2d7JF17vflNzDPcLaO3jCUHnR8N+DT2ttmd4+RrS8EnuqOl7tPlf3wZLP6df7k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4347 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10190 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112070016 X-Proofpoint-ORIG-GUID: KrZ0q4GwPO2-SNBqtDAKGNzhAOPgLlHc X-Proofpoint-GUID: KrZ0q4GwPO2-SNBqtDAKGNzhAOPgLlHc Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch allows userspace to change the vq to worker mapping while it's in use so tools can do this setup post device creation if needed. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 76 +++++++++++++++++++++++++++----------- drivers/vhost/vhost.h | 2 +- include/uapi/linux/vhost.h | 2 +- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 1af43b5d1dbd..f702df0ce33f 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -232,12 +232,9 @@ void vhost_poll_stop(struct vhost_poll *poll) } EXPORT_SYMBOL_GPL(vhost_poll_stop); -static void vhost_work_queue_on(struct vhost_worker *worker, - struct vhost_work *work) +static void vhost_worker_work_queue(struct vhost_worker *worker, + struct vhost_work *work) { - if (!worker) - return; - if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) { /* We can only add the work to the list after we're * sure it was not in the list. @@ -248,21 +245,32 @@ static void vhost_work_queue_on(struct vhost_worker *worker, } } -static int vhost_workers_idr_flush_iter(int id, void *worker, void *dev) +static void vhost_worker_flush(struct vhost_worker *worker) { struct vhost_flush_struct flush; init_completion(&flush.wait_event); vhost_work_init(&flush.work, vhost_flush_work); - vhost_work_queue_on(worker, &flush.work); + vhost_worker_work_queue(worker, &flush.work); wait_for_completion(&flush.wait_event); +} + +static int vhost_workers_idr_flush_iter(int id, void *worker, void *dev) +{ + vhost_worker_flush(worker); return 0; } void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) { - vhost_work_queue_on(vq->worker, work); + struct vhost_worker *worker; + + rcu_read_lock(); + worker = rcu_dereference(vq->worker); + if (worker) + vhost_worker_work_queue(worker, work); + rcu_read_unlock(); } EXPORT_SYMBOL_GPL(vhost_vq_work_queue); @@ -282,7 +290,16 @@ EXPORT_SYMBOL_GPL(vhost_work_dev_flush); /* A lockless hint for busy polling code to exit the loop */ bool vhost_vq_has_work(struct vhost_virtqueue *vq) { - return vq->worker && !llist_empty(&vq->worker->work_list); + struct vhost_worker *worker; + bool has_work = false; + + rcu_read_lock(); + worker = rcu_dereference(vq->worker); + if (worker && !llist_empty(&worker->work_list)) + has_work = true; + rcu_read_unlock(); + + return has_work; } EXPORT_SYMBOL_GPL(vhost_vq_has_work); @@ -507,7 +524,7 @@ void vhost_dev_init(struct vhost_dev *dev, vq->log = NULL; vq->indirect = NULL; vq->heads = NULL; - vq->worker = NULL; + rcu_assign_pointer(vq->worker, NULL); vq->dev = dev; mutex_init(&vq->mutex); vhost_vq_reset(dev, vq); @@ -587,11 +604,30 @@ static void vhost_worker_put(struct vhost_dev *dev, struct vhost_worker *worker) kfree(worker); } -static void vhost_vq_detach_worker(struct vhost_virtqueue *vq) +static void vhost_vq_swap_worker(struct vhost_virtqueue *vq, + struct vhost_worker *new_worker, bool flush) { - if (vq->worker) - vhost_worker_put(vq->dev, vq->worker); - vq->worker = NULL; + struct vhost_worker *old_worker; + + old_worker = rcu_dereference_check(vq->worker, + lockdep_is_held(&vq->dev->mutex)); + rcu_assign_pointer(vq->worker, new_worker); + + if (!old_worker) + return; + + if (flush) { + /* + * For dev cleanup we won't have work running, but for the + * dynamic attach case we might so make sure we see the new + * worker and there is no work in the old worker when we + * return. + */ + synchronize_rcu(); + vhost_worker_flush(old_worker); + } + + vhost_worker_put(vq->dev, old_worker); } static int vhost_workers_idr_iter(int id, void *worker, void *dev) @@ -608,7 +644,7 @@ static void vhost_workers_free(struct vhost_dev *dev) return; for (i = 0; i < dev->nvqs; i++) - vhost_vq_detach_worker(dev->vqs[i]); + vhost_vq_swap_worker(dev->vqs[i], NULL, false); idr_for_each(&dev->worker_idr, vhost_workers_idr_iter, dev); } @@ -664,18 +700,13 @@ static int vhost_vq_attach_worker(struct vhost_virtqueue *vq, if (!dev->use_worker) return -EINVAL; - /* We don't support setting a worker on an active vq */ - if (vq->private_data) - return -EBUSY; - worker = idr_find(&dev->worker_idr, info->worker_id); if (!worker) return -ENODEV; refcount_inc(&worker->refcount); - vhost_vq_detach_worker(vq); - vq->worker = worker; + vhost_vq_swap_worker(vq, worker, true); return 0; } @@ -1826,7 +1857,10 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg r = -EFAULT; break; } + /* We might flush worker, so we can't hold the vq mutex. */ + mutex_unlock(&vq->mutex); r = vhost_vq_attach_worker(vq, &w); + mutex_lock(&vq->mutex); if (!r && copy_to_user(argp, &w, sizeof(w))) r = -EFAULT; break; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 1738388fa02d..7903ac6bc92d 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -81,7 +81,7 @@ struct vhost_vring_call { /* The virtqueue structure describes a queue attached to a device. */ struct vhost_virtqueue { struct vhost_dev *dev; - struct vhost_worker *worker; + struct vhost_worker __rcu *worker; /* The actual ring of buffers. */ struct mutex mutex; diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 117ea92b3925..e0221c8ce877 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -88,7 +88,7 @@ #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) /* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's - * virtqueues. This must be done before the virtqueue is active. + * virtqueues. */ #define VHOST_ATTACH_VRING_WORKER _IOR(VHOST_VIRTIO, 0x15, \ struct vhost_vring_worker)