From patchwork Thu Nov 4 19:04:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603679 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A03C4332F for ; Thu, 4 Nov 2021 19:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5619461157 for ; Thu, 4 Nov 2021 19:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234108AbhKDTH5 (ORCPT ); Thu, 4 Nov 2021 15:07:57 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:55514 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231823AbhKDTH4 (ORCPT ); Thu, 4 Nov 2021 15:07:56 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1A4IEb3P032488; Thu, 4 Nov 2021 19:05:14 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=3aJDenUEDyOoOTfoekDrWXg24pA1mwwyDffqn29hT0U=; b=vLMvk4d6XbrNR8prJjqNrXj6RfUrOWQDLtCOnuyNYn/K3dhhNO0tRg+EQwZz4iuSLm+F WP09w7YFECFwG318VtktNyUaB3lpkg9g8tJo6iyW8uP6vyeVSIXzGm4owY+cGixhNk6K hfilX4+VKjxICoeIgEtx4VEzZNFiw38YtmYmnb9boNiBnQgp1xIDy2AKwhIgod6Ol9ly YFc5pSWHzzqm+E64KSQCcYzADjsASk5HhtcOcF6qtnOetdTOUtqjxdJs6HXu058/U4MT XixnGUhdsF1iIUDPbAn0s2caegMphEryC9e0yBL57VEBp3+VSyzea7EsZk/rYitZeCAJ nA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3ju73acm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:14 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1A4J17XZ042421; Thu, 4 Nov 2021 19:05:13 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by userp3030.oracle.com with ESMTP id 3c27k94tdc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YIcwZcIMgaDIEXVoX3SN3D2L7pmWoz5eBowW4nO6pRxYSJlRPYC3l45AYsILT4Q/MjZk0dWTMIz4CBgGNoK6RjDOPJUwNmGuZC5pRfJ2HgdbD6SyMfuG0iDfG2L2zHKUJfSDVr0GOy9+tLLqizK8jtFHgGuJ12tmIg3zEusF4iZysk65Zkr7nWBiGAP1rgarBcH91shSNMz74/ZCVmfvWo1VUFLZrDd4o/tlJ2P6clh559BKJEN0YC+hGDxZgQ/BQ27PK+de9ik3JZCx/pMr9TQJzOwh4WoE32OdlTzzDMYY4+93pmVmUBS/FOv5gzHxbqm12Yz/oWY1imXdqwzNAw== 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=3aJDenUEDyOoOTfoekDrWXg24pA1mwwyDffqn29hT0U=; b=hVeSZAgABGibShtXObbX7/pRWm+eChAvcGihBm5Cfsra5H2QrjYMQLJIphmd4m3+aDAw+YpjJ5r4L1Z/jY7PFJiCWh95ZDaahROax3eXljl+HFW1Ytg/ZGVQy6CtSg5iE4IDbcV8g4lkVar4qWS4jknODsqVRI2v69Le3aXJd8/ryMrz+PRgv7YHou1ym1YnwC7fkgNJsx9inkwZSL7X0iCf/pM+tZfQnCi8xejAR5aDuTWolv2IZpyKpstFsjKcWRCLWN2I2MJu0dpZ++thH4iplwEolMO/h1hhSfetS68STH7O72PwuB6bQgxAWwXG83bcLy2ViI21LM9CDdT0bQ== 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=3aJDenUEDyOoOTfoekDrWXg24pA1mwwyDffqn29hT0U=; b=y9C/a7dsfbhInCRgp/XcxJJiCSMK//PdHL0XpcVVsNlJYYVpKoH7NZitai1QNxXw/7zazZyt/YPYda5T4drguthsgw+9MvjMV9mpCxs2rMh5Prm2sHx2zQwoGExrLQeoGTzFpcpu9z0x78y4c/Wv8TXMFg13lomTse2MCoQmY5c= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM5PR10MB1595.namprd10.prod.outlook.com (2603:10b6:3:13::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Thu, 4 Nov 2021 19:05:10 +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.4669.011; Thu, 4 Nov 2021 19:05:10 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 01/12] vhost: add vhost_worker pointer to vhost_virtqueue Date: Thu, 4 Nov 2021 14:04:51 -0500 Message-Id: <20211104190502.7053-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 014cdbe8-367e-495d-818e-08d99fc605f1 X-MS-TrafficTypeDiagnostic: DM5PR10MB1595: 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: Oxt+utEUkH5ogAKhrMzQTejltitVgOWCcKSyyx2hJVrULTD8lArpRUi/Vk1jbgtHDMOzVohDgaU1T8kCP05A9LRh2RIxNtp4EoiOjAEH6pdYs4XErZGbwQQ+WAmlk0FkExWXryFOY2nyGLC0aLFuxEjMMP9DdoeNDNs2+BclFhHhygnWpXwphcqrXLOEQgwXB+OSTM9L9J/SpPjDzd42fL53DNikkSws85PI81N29ivhWm0TTNy9gfnsD7ROzA31WIJGw4x9Wq/6yfQwiWiK2gJCnEBcZNF/GQ0ojR6PWOter377aebBwzLrmihRu6G0Dn+dIQ7pdYpn9WvCOvNfP2UZ/C4kX3NMcCMqT1uz9HoS62+7KKUgSENEnVKmkXyv96ZLm3LpTzxTvyeHoKg3tY8fIxtyH5nfVmf0fFJ7U5cp2xiVbw0dwQfXnALu78MA0XxEVClmelp6sKeIrV66QK2Zz1fjqzHWv/WJLnOxTkj1TgOkBZ6ykXBBevbG60HbsIEUpGoj2H/kg8DkxpDHmo+rJWKdultUHrAnLf0aDq2XsDcxau+9BhS/5mInyucZnnFRuoWJm1r1+HBngnV3yj63L0mi4YEfejdVB46xfoJdlnMGBv4dNPUkjSlANrcn3AALVaI1DKR4ulKdjfoGzfqVO2mZSCEDWW/QLiyr8yQrr5k0hehHgpQ6/T1wVkCBEQ4BIbwmp+76KXYd266PYw== 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)(107886003)(66946007)(52116002)(5660300002)(36756003)(508600001)(6506007)(66556008)(2906002)(4326008)(1076003)(66476007)(6666004)(83380400001)(956004)(8936002)(2616005)(186003)(6512007)(38100700002)(26005)(8676002)(86362001)(316002)(6486002)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AZ46gQ/qlOyKc9YYyHtSM+GLmzIXX3//48dXokYoApsf9cHK/ioscSIbgKLgVIko1qFRsEYYvuw6ECjOvPXCH6YkVshUTF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VHU039vVF+jmr5lU797qpIaqc1dxsTawVwLtgipkHu6iWhKeg2lEZE0e5LoAjsCFGyMWMXoXPDCuShtl74ZVJzeKj7u9id0H7WPkkvWwu6nEgr6eGSDH4vReoxLqywQnRPN5OOs1V/JPAc6cGDJbUV5NijTKO/oU4sj2XmcHd9QHSaowamcRIUqHmSeVmn4OsB97+0XH/K+FESm0qT/wFaAlJZFf5skizDYnVOveipzV8Yy4bSjZE8wHaNLW2bSnGltkpIJ/eVvbZdh5DU26Q1VrJp4I5BKxtW5zboe0J9DG3GnE04bKm/Mh8MjEBDf2Ap+XQp5dCsvOtySlDF0sW38i3NDD6+c2ZaL0wQshuwN2/luKSUtrpGZuxXcA0Knzog3Em1vfzUjAmQjL39kfM1FN7mBG7InlMZnkgwcMy3OLM+nUCKERa1u1j6BTzhkEhl8BoCHSTCt0w+X3O9Z/h11RSALdWRSEGtQFct6/dWvQxePAv1ClRcFRp91w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 014cdbe8-367e-495d-818e-08d99fc605f1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:10.3519 (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: TtmAFkTQMSFC6vNnDQxCPTC0OZVNm5efGnI6spNBffw6TusMRmZFT9LFykb7afc06jzEeRP4YCVcYfszr2/68wZlWjwPRzX9jrcjmxbmdFk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1595 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-GUID: EAoLvzligz_kDjxpkxnMn7HSRuZvVX5U X-Proofpoint-ORIG-GUID: EAoLvzligz_kDjxpkxnMn7HSRuZvVX5U 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 9aa04fcdf210..9b4e7d74dab4 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -496,6 +496,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); @@ -574,15 +575,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(); @@ -594,25 +594,24 @@ static int vhost_worker_create(struct vhost_dev *dev) */ task = kernel_worker(vhost_worker, worker, NUMA_NO_NODE, CLONE_FS, KERN_WORKER_NO_FILES | KERN_WORKER_SIG_IGN); - if (IS_ERR(task)) { - ret = PTR_ERR(task); + if (IS_ERR(task)) goto free_worker; - } worker->task = task; kernel_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)) { @@ -623,9 +622,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 09748694cb66..7ee38b4a2807 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -80,6 +80,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 Thu Nov 4 19:04:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603677 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3924BC433F5 for ; Thu, 4 Nov 2021 19:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F4E061051 for ; Thu, 4 Nov 2021 19:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234225AbhKDTH5 (ORCPT ); Thu, 4 Nov 2021 15:07:57 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:20074 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234108AbhKDTHz (ORCPT ); Thu, 4 Nov 2021 15:07:55 -0400 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 1A4IWMnf027065; Thu, 4 Nov 2021 19:05:14 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=qSY05G+VH6XojMvrb20ZXD1g2hwA5+AKsJUy8o8qBuY=; b=CkAHeV/0Trqh1OKufI0Cn7WfLfuEjVYXAv7IlcYEJwDZCZD1/OKdmsKiuzm175ckeDHn ErsP3DixkSfZQj9qtVsZ9SGmJ365wIAmhnrgJVFSM7z9zZXRjXQ/Em5yY5gehMPGjuXm k+DCkyk3bvMtvMWaCwMOH+jot6v5xsY4mCtHikFKDoAVlzY5CA1o+OynF8sv/aQvbm6t vFVwbj0zTOVUbLDQ80ya1+K/sYlnyNlbDO5cdsVxQK+PP+EeOsLIhW9g8NPB8rjxZlim EQ2alooh6woJpO9ZK1YILAr4u9OSgEbtfAZO8bu20fK31FOa28lP622n1rSm//9ooVKu dg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3mxham4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:14 +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 1A4J0PId122897; Thu, 4 Nov 2021 19:05:13 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bjNMxZ6NacVNQkA+JIQgiZ/g3YaPaykaRiDGGC9r6C5zIJmDRmPxePe49G89AsOXOGYoMhgiKnLHrPxYZ6f2GtRKNQn7GSPUIqMuc1AsESjOM6Qjq6q+rTCa/GDAtsbcp09UgPKBS917Uqqiy6wVNNb/zn0b93mdh5KN6yNykLltLx/111krLr5og2/i8fwZINEVv1UIgF2zCPM6oWhaSUNSytAm+t3q0hEXW+tVTROQST1b5aKddwL3fzuHt3nYAOGYDdjuFO8l3vIiB1vb8Fpjc3aWKR5diSA3LhOYBe0z7WjGoXGyFFxpa/E56fBCZ7YafYeMBymDxJCJPolfjA== 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=qSY05G+VH6XojMvrb20ZXD1g2hwA5+AKsJUy8o8qBuY=; b=VgE66nfYjsFqHFAO9FXINrrzM+dFyoQN3XpF6EIoDRSGOwdDh3YjCFqV8ZKwWFZIOzHOeg70BTLYbwxvgfPivjv3Akc+tN5PksRJHEN+jnMkzAC/a2uAZEl48REISZKS6hm1CVcgGSjVAWUiydEwKwwdz0IgCDvRXd+kScV2HSOVtkourvNJYstBhEhg/xTAZnTnXR3btYwSuMYNN9Iqkza27UpjVsOoLcJt7c19CXvBpZQkvuisQcIyYRW50eRr6QLiuzojoL+acIDMMMZwnCG0DfiaxGy3bmagDgjD/7AwklRJVbGHpJp+zQ0rx3HKMBb6TJUMIrAX2691WTQYOA== 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=qSY05G+VH6XojMvrb20ZXD1g2hwA5+AKsJUy8o8qBuY=; b=jLkiUi+3FXKwO1nI0a3qn5Ij0lgtpBonsad+M+n4C7iG+OJR+A8FYYUik9sSugnlyUiHs97Khp6RGaCyaStW3XN6uJBMFyDPhPXwsHsr1MYlaM7d3Fvq90CTKEqmtsLhmlnRa1B2moDOSkipCUJIsC+ihkHc7lZmgsy+1ojNbYo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:11 +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.4669.011; Thu, 4 Nov 2021 19:05:10 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 02/12] vhost, vhost-net: add helper to check if vq has work Date: Thu, 4 Nov 2021 14:04:52 -0500 Message-Id: <20211104190502.7053-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0185c8d7-8c02-4bd7-fc5e-08d99fc6063e X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: 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: Dn94I9GdhfM4nX2k+4Axg1EZQeuOYLnP9A7jPhW127PqBjnO9eRo+bsWhN0cXnV8uUNXNs4RdBHsNrK3EEC8E7aWFXiK+L4LYRyb9VOmoJZ0q89NhJjl81s9sAaG/zqGiUCbOVf93nikw8W5QiSdWQsVtJH8RtIBb8q3iPl0S1PMboHC2rH7bRAEKayhvW+mrf8y/WjM4IamzvI9/1LmxwwTF2j8D3aRueHhHDTMXyzOHzljWTDCyKcInH3nXIbqm9EfiL7KvX3RkIqQkwT3WntceOFNsl/WQG14Py1z5I6Pwzyo0RsgANl5D5fwzqK6zhqaq+KB50NixRq3XsqX1SbqM3t2NmKp8mOMOHnhk03zbgtJAHv2GzEUfFZcJ+yY8QBWq2kplqwqfIUXODyjfBjPbUdaJIbKVEqRJL4EF8hKKWvGckfUU2T6brJ7ZxpQMkyLQlO1SUrWZ8G7/omy7JSJTWRDVEwbaIEyth6BXIfL22HZ5F5uD9tjgTEsZL5dYcC/VcoD/aoopUv5MnLQEKBwXQyot5drGGh6MDbOGGyu2hH0ZrcPqS0YchPFTETTolqYErNqKdsX1UV5t6gGq7JyufphO21VCfhKiYbeLEg4Js1NjmprYszAFzeZ8e/dUMQwBs7t2tjGcHykpjPYLlzpSN8LkQH2vEvgNIi7Z3EXdVl1ribsPJYaicl3ujfQm7Kej/hRPKnraHieVgycGA== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bQLtkYlGuWAwEN/uK5iPE30l3S0DE22FoFVoYj3ssUYXLFl/OHRniqK9veWic8+H3VoiNk+NUGjYPCg1NnKLXY6ElHA5xhLqLU6Xi0Hq2HO6+a56YUwzcVEtFKLUA479DqDWtJSuAHDjJFnPRqwVrJHSjXqHAlLZymVdNZBPNpdCA8jcyepjLcENauorttGYD1Nrtyt4yMrCWG8eql7EUaNIoL5tbvWBAOyArA8GhuRUqtHz94pbokmsck5q7FCE03lu8eOcD+x6tuUnlW7aL6udn9/xILXc62ekHtRrJpaKQtnzk/LP2UWOYYalnT5xUOx8d+JUbMlWfEafAy2PZtxXIhw6cFc5JPy+InMdZ1pRugM++aEShr+//dKp2tIAgLbd54m6XTFqKoRlgnX4I7RCysl1ZATY0CvCDkenPkaue1XV7q4lJvK6KOhaQdse3y6uryn5cNhLtnJwfwsvvqU6zSoHzRg0eULHOMti/Sa9C21Vib3lmU9wH4WTegPbLtt/kyU4j23RWUNn7/7uXI5CYL2SvYiAoRYgopyMSk1XvKXP+gWOKj3YpsNInQSCKPeahm/Jqp3bxrxtxqO1Ai4oyZRq7Vny6t2gSRMsBG4y9FTMQhEt0qX73jDtjdKXPC3h9phHmpwCZX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-Id: 0185c8d7-8c02-4bd7-fc5e-08d99fc6063e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:10.8277 (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: Ou4GCdvsouGRy6QTGLdJAcG+W2QG57hRYefE6Sw9rWrHl+rnIawQWvzYnLrU5Ce3rHJEFkxvCHD+Qdv641BH2uZTzilgUNHxqjCkWEmtJso= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: NvnmqcWjjcgYPrd43UOVGraDULB25D-j X-Proofpoint-GUID: NvnmqcWjjcgYPrd43UOVGraDULB25D-j 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 28ef323882fb..6c4b2b2158bb 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 9b4e7d74dab4..f6bfa1c481df 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -269,11 +269,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 7ee38b4a2807..37989518a07c 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); @@ -200,6 +199,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 Thu Nov 4 19:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603681 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5412C433FE for ; Thu, 4 Nov 2021 19:05:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 902C261215 for ; Thu, 4 Nov 2021 19:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234231AbhKDTH6 (ORCPT ); Thu, 4 Nov 2021 15:07:58 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:23532 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbhKDTH5 (ORCPT ); Thu, 4 Nov 2021 15:07:57 -0400 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 1A4IapaA001625; Thu, 4 Nov 2021 19:05:16 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=YRvGMJIr+pPdp6mOPkFreVfqZcjqlBTVExiJGCzv26c=; b=Cu+wYIKHS+TCJyN6ikRBw+xu+dzR8yABx3UGQEvEKGHbm2AXvSO7AMB2CS9WTcJ93eqp 1IqpzaKESXdzseOvderB8wHddJbZa0/+NF0AtO/FqxW+LE4iuxIuy3mFOE17qLbxrg8d yd2IJuzllXv0HdJUoWdAYl1v5zLe6J+jZE8omIuSU6I4Xb1OEhr9B5i81apziRNp9mqM x4zrTTEss2NHTl9+3/9RitiUcbzskMDrJp38ORGSxh/BpnFgfGDtYgz4f+Q5TgzIjGDZ KcVIDU7gq4ga9+McPmjF5P0cwJXTyk6O3kzbxzDSBc2CAhILZ6sJIfPerbfYgp0CyhdS AA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:15 +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 1A4J0PIe122897; Thu, 4 Nov 2021 19:05:14 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhqnXAgm3x5wNH8Qu6fCkoHe3TRutwSdhMkzdnJ6QiQdKZUEY7FOZ7rdVtmJ/px95mo0ZQFQUbHTkimR0daqDswDyJSIqrVw4lyvEoTUncJt0g7EPCuSEcpWsRxuQbtx+HQuKFlyC65lIFFCfxYqi/mV7mPOabZQ2VdWbA6++FreyqRUrcTrGGAptvl61dCmIPB/go/rqzJm/i77fCgWpsDh1YDSwhU3vhwrA71WooFmhkuHubjMhwMtk98ixOadJnjbeI2251/8+9plFufCrrqa/lnsOWdfXwPiMbx2Uz602G6tN45NAdzW3WJ4x5VGUjHzbtvsC+ZC4XgRYA2RBA== 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=YRvGMJIr+pPdp6mOPkFreVfqZcjqlBTVExiJGCzv26c=; b=lzT4VcSTQ/yMh36JmuhQVRLPEhLMp+9C3QJtBWNQGSFPDso79cwA9UsdWkcilV6/TUhtMJYNvX0K+6ul2/46l5V8l+1LUQ3YaPWjKzKWdX8TjEwiXTgwHB+V1ruIn6HOJo8hmxZT13+Lq37Sf94aRgo7H0EoEWlQiWYs5dTvIx1UOqOPF35Zgf14vBnDhjRfj6bfLHqTsPpumsFUFQo1QtPKrMo5LsKNff6j5+r7q2ULK53l0Kz1tKfUdUTh2nSNvzw8NDT1ppMmipYqO1IlPl0cJIC9eNAwrT6Zxo91iPnq6/i6z27qM0w+bRiJBS2ToP1/dtB6n8/oASJWQwpZ0w== 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=YRvGMJIr+pPdp6mOPkFreVfqZcjqlBTVExiJGCzv26c=; b=bwH2b4/B37gY6ZdnEEL1dTqzxuRFyZNA4zBro72PUlwe8CRroX/4I6gpOV6YRUN8UndTEcCxPPyOaodsXxoB6gJbuV0Kvfm1owkrgEiQnkqL8Zl+TGbwHVpeOKcSo9nQ1INZr4N+1nYU+bbNCyT/ILzPtOGDQUdx9kcCJcinOvo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:11 +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.4669.011; Thu, 4 Nov 2021 19:05:11 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 03/12] vhost: take worker or vq instead of dev for queueing Date: Thu, 4 Nov 2021 14:04:53 -0500 Message-Id: <20211104190502.7053-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab3acc03-5bcf-4102-ab71-08d99fc60686 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: 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: CcCcCp4TFu0X9dw/p147h91LgUxjDnKxNWpOeyI76Y8ITv8V3pq9CyKu2SaYpzOLlqaqO9y7eMTYom5QUHBx++drVjfeZFSRBYwexpmm+E8fsLCw5txCq/XRDp035bI5+VEAAA8G/6FWyzjYRCJvPHdB02B3O27rsmCwVE6Ew1vTHBgtms8muX9hCQ9ZMfrvMJl9WRtiYaxSbzXzLsDtBeMS8CdLdlhCfQw6VhmWpUaGA6pdjPhitWW99hUk4qRL6dmTyRYvoAT81tsBy6agv2SzxMOOFg2yfdqRFO+6MSdJt5n+J8AmYSNrQea3MGNqCRyXBLRJahmVfiPn4qXL19XW+ORgxioyW4WDNpmK0bcQzRUZWwtsbxNgvUSmrgPECgPQ4Ox+tueMDUTq89N5Pe13JrII2SM38sdlehtQsKo0Z7bivTe842B6ANXga7dT2uKjVpvDw/GHVbD/wmC6f+8XIEGdIyC3R/I+oAE+9YHcTMrp5AEETIqhZyi02z450NXICcC8SNA+CNmsz5WfccTAdmgNp3+Ds/s7KvwCqXOfo3He7ohzxpxo1awEqTDfeYWAzqhAfXBGqfc3EBwkc8BlMPclnR/2R2sEAenioEyKZB1LaYXPo6lRfMRRXqlH6syQEWeO0ei3QoccHHn53jhCnEWxvjrvwBrhkLCkCL80hXu+bcdtSsniPRpJ52QEQW6Rxdl0gCMLd8Y+nox+Jw== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 48BzlbFkAO0MGMc+7uc98NHG07IGRK1Yez9BCPSw+I4ePMuI/MozZpx9QxwElWM/xUfzLIUM4Vt1JGaxa52xzcmPHvnNTLpWv5QsF5ESu4TKjZ3wE0YLfeG84P/DPcdH504uc/izpa2nu/X6FrkjF+D6ftjUshOebrjlmgncPmYRDHQT+5g8BXqbfCqTVAN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TbWleOiJ22/98syUXEhqlh7qd7CqKQW5AMoLo3lRASiqkuY8BzNZECJHeTEdrGJOlYLwkdeu6K+6lDf0cwEv9NUMNoyIa3UN1cGrX/3IelUPF2ok79mLVxhfKsx7Cu96bsW044bxi7Ruc3eva8Aw8j+HdBcKSCwtiZea29Z2ascvU3vGs6AaL9bmmOxrjvp3BnHwetoe6bhP+bLbqABXsoqUMSisR0U+Lv610evg0xdBjmyB3q1b2SznPRi4pB4mOZ2QpRIy+hinEvBCbTbRXjnKnMBe05SjNs+gUyu0XAMdi82EZzuBClM/lMbwPaYVkV1luf+Ul+/WGwdkkKuYJ2MdmBtlVHv0yH5f4zd+g4kQv6vo1iwCoyOT1HAm5M37TzD8l5o3YXipfeIqtliPFNV0m5H1w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab3acc03-5bcf-4102-ab71-08d99fc60686 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:11.2615 (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: pWPbPpBTSK2nvI0QSaiOHTxgLJtKa4HGmA8Di/UqtidrLOfQaaCyF0AKpKNrsVyuLgGkoox0nmep3/R9cPzJUdNMIBbPzV4E7/W6QSnk0vo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: CkzZwRmNOSl53nPRJGLTkCM83rQ-21_o X-Proofpoint-GUID: CkzZwRmNOSl53nPRJGLTkCM83rQ-21_o 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 f6bfa1c481df..f2c6981297d0 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; @@ -252,22 +280,6 @@ void vhost_poll_flush(struct vhost_poll *poll) } EXPORT_SYMBOL_GPL(vhost_poll_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 37989518a07c..8f209d1c8890 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -199,6 +199,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 Thu Nov 4 19:04:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603685 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69642C433EF for ; Thu, 4 Nov 2021 19:05:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 579DE61051 for ; Thu, 4 Nov 2021 19:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234257AbhKDTIE (ORCPT ); Thu, 4 Nov 2021 15:08:04 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:25358 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbhKDTH6 (ORCPT ); Thu, 4 Nov 2021 15:07:58 -0400 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 1A4IUwVi027083; Thu, 4 Nov 2021 19:05:16 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=D40tPvmKWcALQ529N71eSOpOGZt4d+MRa6Xymi5OU3A=; b=OrkPI4MhsQM67hfASN6C5o4EmTy2q/sxoKStttwFsgIQCnZYWd3i3MhvSbWOwU5cWpTQ 3Ri2J1v/C41JBRZCGTioheXzLB32uP2rCt8SZMIGR7qXCv0v+ePWWuHjw4LHKhpaaTr8 4Ig17G5iAaoKkiBQp3M6KKSa2dApF7R+DDVzFe3adMSWAwl4a9lGoz/YkgueSG07dgIu Fbivyo16YRMoy6bZ52DRf0Rq/RViA1kueXP598B0laV8lyELP11EEolYESJisaqK6kX6 Biz0Scdn8tNOs931egG6d+oxLjjt4uP0hcdgvVjjYLnfQxUkTVEWBTHj3iLMLVukOhI6 6w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3mxham50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:16 +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 1A4J0PIg122897; Thu, 4 Nov 2021 19:05:15 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JeJXVSvmv1h4A1+g5eOyTkVTLw2ZVTwJfGAtzSwk4+A2yy7lVQ6D5ISZVi3IFjbhiW6TXontDoIoyCJgiGq++zZDVgiOmnoLI5ScdkeJEJ0uATaWk5+a/6HElLFpgPlIOwi8zEvP6k29DMU749Y+esHpykTq7ukpVthpxRjHTGeGvrHzQqt7jJPDSCsrFMk/Oozqc+Vdhr6cvT6n9MplAnsdA4SRQ5xnxhjTsRonQLrTIj1FNR1Jw7bWlXGtyF7yUP8MA9xAbP0TpJP7pOFqzkSG6UjRLo3NX+x+z+P5qst5t/Ung25XYM7ImeDIcHV1vUj6J6tfRnttwzvvK9dMTA== 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=D40tPvmKWcALQ529N71eSOpOGZt4d+MRa6Xymi5OU3A=; b=XW5UgIgLacSnXgGvjH06wdxnR2C9MvFjbcNRrFM3KaJufpqz0NkzMkCTSeF2N8jy+IcJvQwMA6CnGMxpRMAFghBcE2G4Agp4krvsCdppW22yvn1AElDktKjLYiMroHWi5PAm3h3p9/JV+vQ6Wv7MS/9jLWzUDsjMYBsMNoQ9oJ8ri0fHa78phqnjUyGpaH+SGNjAtf+e/mnXUrgPVw66mEI0T0d/YioHObDK4MswTIOVlFfgwhgYQxhq5PmMB9a5roB0uK9w7RkBQ9QUzKSmbvXs+s6S0gRS7yXmwe93yZwZC2IHWCIH06jeR6ggoS2MW95Iz0Qg/6dHY5SHM5S7YQ== 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=D40tPvmKWcALQ529N71eSOpOGZt4d+MRa6Xymi5OU3A=; b=R+2QrNjS9M2BgxWIoIfA9Yyxn2G0cG3gR28Y35ZnTz6/b8SKAVuXwgW4FHromWXN5EKmSp3T8lO7SBmGSgWA7wBRAboULjZvxAeFcdbmC2G0P9RZ9aSNFtcs1KW6L9Tys1pW/9HJ9k98uhiF3nVs5KzISEh9irgHv+ahVfUIGdM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:11 +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.4669.011; Thu, 4 Nov 2021 19:05:11 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 04/12] vhost: take worker or vq instead of dev for flushing Date: Thu, 4 Nov 2021 14:04:54 -0500 Message-Id: <20211104190502.7053-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25fb686c-6472-4711-c2c8-08d99fc606cb X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6/Xx+XSPMzHevw8vFVEBf21ybY0w7Vff+pp8BVAuOydKm6aCWHqhXggUwx5sXoLSsNMcZ6tIIxp5K6H12M1GaolxRZog1CO20W//GQbY8vj6DmS7n2rSvVbp3wqaTGZCfJcimlVe/yipmf2er6ClglPmwUJBv73jMVBurtL3JgZcC88epWj+aOEghZBDDbq5ZIT0I+tuboLHvOQGYzOq0aPs+zg83Sk1s2T9lX/TijRYdLvVa2TZfuuOe1XuH1n023C8t05Ugf9IDtkt+lLqfXlpX2OY8iQNu2eFO4cER9hIoV0qA/fN1jv+1tywwXSC7oL1uDrdF4tsPrvng9yKZpeQuZ+C2sAwiPtggDuxqGLCb8RizbHMURYE6CdLFS3pB3JYACxGFJRtT2n1wx2Owl+OaRshc4/S3CT5jeod8s7tfCIFTnXVa8FJbbbcEr2V3UAv16NPDG1AGZCWpYJWO28+js1oyUaLbg+oIdEp6o685VGbugPnBzKbXbUQY1Zd0q6M5Tk1NSHi98Ng1SkVJ/izwK9DLAASxAOKdYvD5oWPqjfrhEPBXNW0tWHPhtD0NXvtKblsB02HgTLwpToinSNTZKyeipET7eGiVBhQbYT4wzdaXxdUSugIorvsjrRbK1n26sfoXC2x/yltt1IJkEkT5hQ70onJU9EaH4I18bsxc8/U4Xu+og2Oy5UEdoK+96VCxov9A08IBNl6vIABLw== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oKsib+yg57l3w04qIlcBY+2q5/PIqEGwm9eT2YBeWk3bds98fvErNIySD023wgTwyWSVJ4w9elql7jPWVj67v1jB1YydnbCJD1InexxO/FjWFVCjtEx9YGMXonH2vFHdUfg16YO/29s1D2xEUcw3GoHvqjZAa+7f7TQNOTXdig53OXqTNlriwmUcxO6RZtH9vYXm0uYJsjfj04YoxxsWyRuHp8l8SFYnyeShFA1xcDaBTkXk61qSAkUi8+IWnvZi0Mfu/V8ea8/COKluxnWALSuTBIK61dpLM1ucA4MFnHYwJBI7K7qs+AWN/d4hBic/fq3dkxusPY5mAdWjZkEtL3W+xMVUz36wugfPaRm1YZciHLd/IXEbngguF4iZONSBqj9YArhhsCWVWYkTP3KCsMudUPPh5zPC5iOnUiddtSHq+OgP8bUMYg5UH6f+1CjdCbc4q7ixMP0Bzv2T9lCCSijlHou8YP0CoXNpIzYXrehK+lcVfpdGCfCVsdTW18pb38WKC/vdjBVHSGhSvxMck6XrlTu+CSZmVMqI/I6MnfpJf62tewA0GtDlHNegE2Jfo+oC9FDXDw5hFEN5f553mYhMF8jRzUsT5ZybuLmiX+d2oEhflHFNadwmOLo3o+Dd8/X5oqYOY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-Id: 25fb686c-6472-4711-c2c8-08d99fc606cb X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:11.7663 (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: pmW3Mi50GVq3prURqQoPEjydjuZyXxvHoYtrGIJls+E/5oTSf/5feSZJoqiKXsTaqoXc3Ba6VFHG+ki4UmUys0/Dxfsbk7TGntGHFRn9CQ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: MI4MhI_4MSpxUf09a1DeD3jQefZWr1Jx X-Proofpoint-GUID: MI4MhI_4MSpxUf09a1DeD3jQefZWr1Jx 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. It also adds a helper that takes a vq during flushing so modules can control which vq/worker to flush. This temp leaves vhost_work_dev_flush. It will be removed when the drivers are converted in the next patches. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 30 +++++++++++++++++++++--------- drivers/vhost/vhost.h | 1 + 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f2c6981297d0..e4d765f6c821 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -246,6 +246,26 @@ 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_vq_work_flush(struct vhost_virtqueue *vq) +{ + vhost_work_flush_on(vq->worker); +} +EXPORT_SYMBOL_GPL(vhost_vq_work_flush); + void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) { vhost_work_queue_on(dev->worker, work); @@ -260,15 +280,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); diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 8f209d1c8890..a985caa35633 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -199,6 +199,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_flush(struct vhost_virtqueue *vq); 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); From patchwork Thu Nov 4 19:04:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603687 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE02EC433FE for ; Thu, 4 Nov 2021 19:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAA4561051 for ; Thu, 4 Nov 2021 19:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234261AbhKDTIF (ORCPT ); Thu, 4 Nov 2021 15:08:05 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:28204 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbhKDTH7 (ORCPT ); Thu, 4 Nov 2021 15:07:59 -0400 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 1A4IapaD001625; Thu, 4 Nov 2021 19:05:18 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=X5HrRn/ql1GFGMZSy1m7FRy5eOe5R4RwTzYfSa4G6ew=; b=izSnITBz/SnV+L7VPF9ZgA/mAhISCT7QKx8i9MOBGSXeeFRiASbXx5wZoXqMbzP2NQjU BZe+x8rr2me1B2HgsYJSnqrbPiTiQJcDCkbkk+cCfe4uk4bDGrNWmOC5Ar2u15IN6oZ/ JPrbpSwvg/fw1BHCDdbjr0rg/hNPUdB2gxDiTL2QRb2yqCnJimYqL3TlRQLHzSSMDf8Z ppW9j404usLgWvZI3wwU8oynqBy5wCe10G+Ms8EOKvM5arhcIpoiUBEM9boshlf+DNJh BuUg1VdLauDYfWHM0L8oInILAQuCyxJTGcqMO44oRKeFcsSByKe+5Ty/q9iMQtC6yuux 0A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u7w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:17 +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 1A4J0PIh122897; Thu, 4 Nov 2021 19:05:16 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/jFX/yvLDHa1jhfzOwr9uSBWkOkoiuGQSKd0La3Y8gPjTpWtNP8Rdx/U9mjLUcZJGOF9KQT3yBebakqYGoccO+qY6CktcipzEI9c9YQZmfuQbY1kzeV1rGTg9cmtWQmuUVS6tTXiunKCm9fji5rm8nv/qzcLoSvnwIEQYz64Fhxc8gabInYU8FXfqOyNhUZfJ0PuaZVBJ+tPUjC00ncR/AvfTE24LdAAgmivfdjDFII/WyHHgeI2NYzPWIbi8oC9Xcwuesvmyq+mGuwqw8aQCkT+sXia5S+2A6DU2O6GZ1fPHs7s8QId8t+NwBH67a1qC8R+MuZAfd4zfpR+/rjdg== 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=X5HrRn/ql1GFGMZSy1m7FRy5eOe5R4RwTzYfSa4G6ew=; b=QP3o9ZG09fcnqBChQOiqSeMrz0EHyK8sgPwRouMpkM1kJIVaCe6TjqSykCKK7ZM78ph/0bC7kp0AHoNBkwo6O7B9gTlTz6xeis4K3oFeHmsOR+xR4LrCsXXKlSSIQ/0utdySxqg4ejYEEI/3T73WMNBeAId5aS7239Ue5nP50u+wCjB0FDIAOhwJhiKdZzn10wpQrLB8ndAUUfRGS8uNIsVsgceYlH7ygluj1YoZ2lTESZK1CmxJ1yuBNAO35EzVaItdGynGowKsyQb+ct3UjC2u/dzANAqMolo3SEw3GUjXqlVQK++D0EPZibbWtt7wQXZK4h/2RYCUgmEf7Hekhg== 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=X5HrRn/ql1GFGMZSy1m7FRy5eOe5R4RwTzYfSa4G6ew=; b=GclgwAitZFdH+B2xuezUUkxQY6NpA63gpePzFi5P31mcyh2XpvS4dkTh6tRdm9GGn6B1Tp9xFfIieihKdrLRa06aq/SS7oAFkyJNOrzhR3WaMIqs4/sIRoriC0TuRDzMT81T5pEM/mp2vPtvSXLDAqiE/OC2sHc/SeXha3Jz10E= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:12 +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.4669.011; Thu, 4 Nov 2021 19:05:12 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 05/12] vhost: convert poll work to be vq based Date: Thu, 4 Nov 2021 14:04:55 -0500 Message-Id: <20211104190502.7053-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e958ab9-85d6-4591-f394-08d99fc6071f X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Blq5QWpoh39qT9iRi62I4GZIJtgb0IlAfjO9MQy+pIQA01awPs2vnTe7H7OSLvMJ1xdryRl2915mVaxrTrQdIFU1KC7Jb0QkyoV5SOCQqhNaDLxo3kv5+G8g/UsA+LTWAdfMa5XiljNMEL/ulXvcPImqeQJ7wd7vtoxhBGWQEdOqX1fQbjHDONswjDCYSHuc7YwOD9bHc4epDsMzO24Hpss4qVyEpMEvvoGuaLky1tuJRDgMBDtfqK/r7QomspMkp8cZhnY2+v5rhqgrwHVRg093wBdEmWSaaG9TmLHs+pD8IMdBonUv9psMyc7JIFNafuZU/EnaIWWGYFsRuexhQ738VITxYg+XZ6azPqEZmySUTzAlsyT1LvdtvyUryRlEZJ6diJm3kpjWk9armDKlHBBywiZZzlpL4g9xArymWXkR3yGZHLvyKuBgnlyds+3unoDnJ7YcHswpzCgruQur5MyPdvrvDiY6iOEeIsAQvrpieb1+ytK90TAQ9graI1wMQQk7tL76k2vaTq6L93m5CbH8KYOHwG4X5IEzYYZUIEdNIf142N6nYaQJA9WsDc/nCNh6exTwObkoDBU0PQrnDp801F1qitxW/COgQBTTWeNjw0RKl9hjZTULTE9ITgDg1LYzq7cNBrP3oDic34rjlafI49tpOSUsXBOR33LcqQqUmRfoxVbTXhE4ZKuBKuUysxbKDhZ4WfKpWH7m1TctMQ== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SgOUCzhIjU0uThXaC0KKWQSVpSGZhtaGhvd7iqLLnYb4Rjb+ntNhJOGGsmNdT8WV5MRqHMyx3x8BL4n8e7wFb4wYfX1oeJAZFVSdPwVSv6Gmo3of9zp+VQJj6Xtgn8JHZ8QG/mGkwTBdFHpyLRXyUx0DRu6CEAfzinV+HyPVOiGY6gSrqwv7RvhFFshg7yRil8hhG4x3mRCLgQ6ROZsnuASqHhlEWeaU2VQyhq6WzmVi/SXLyvC/D/UmH74DYKz/PzPryx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9Y2XSypveEHpToUmsmIGMhCKE2jhHGhy/S0YImYdxbCMEOWTnaB5qAi5ebbdRLoBSX1ISwMwyGgj9PZqjrP9LQdzAnb2nhErdlIRcqzsp4O5feJPzbEoxd22zRxbXNznHcyn7dUZWc/aMhbfXmLXTl7XCWrskqSRlUqd2vkyRDt/kEOwgNZlhASgtjcNl2GYupaFdBj7z0fto0VZy/cGbOxjbZijIg4FvSZ2qa5ZQ0dNl6p+ZetDlbusK87opM/Mr2F90m2zS+xuKRIaYgylk7NsVRT6qJYuOzsxCXphHhGLxp4r3u17pfsyLfIsk7Nn+hIBBm6aHkUzD+EKgw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e958ab9-85d6-4591-f394-08d99fc6071f X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:12.3030 (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: Xx3oZ1fIsnGH2V0pkioaqcEHajzM0CNRqFNEV3FYmeASxM+GAd8frK75+IZdexbDcupsESflJzcXwkm8ZiVqWqesG6ocFxV0brjcHYjZlyk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: FNNyY2oljsMKXaSiVo_KE2xHh2roSY1C X-Proofpoint-GUID: FNNyY2oljsMKXaSiVo_KE2xHh2roSY1C 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 | 10 ++++++---- drivers/vhost/vhost.h | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 6c4b2b2158bb..2e1abab45f3c 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 e4d765f6c821..c84024afefff 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); } @@ -288,7 +290,7 @@ EXPORT_SYMBOL_GPL(vhost_work_dev_flush); * locks that are also used by the callback. */ void vhost_poll_flush(struct vhost_poll *poll) { - vhost_work_dev_flush(poll->dev); + vhost_vq_work_flush(poll->vq); } EXPORT_SYMBOL_GPL(vhost_poll_flush); @@ -301,7 +303,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); @@ -526,7 +528,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 a985caa35633..d9650da2be2c 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_flush(struct vhost_poll *poll); From patchwork Thu Nov 4 19:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603689 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6667AC433EF for ; Thu, 4 Nov 2021 19:05:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D57361157 for ; Thu, 4 Nov 2021 19:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234267AbhKDTII (ORCPT ); Thu, 4 Nov 2021 15:08:08 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:29866 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234238AbhKDTIA (ORCPT ); Thu, 4 Nov 2021 15:08:00 -0400 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 1A4IWckf001571; Thu, 4 Nov 2021 19:05:18 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=tecX3TKZejVzr2ZrluTgNOxcyIPArSV9kd7wAux0mCU=; b=SEYby1ot+4QAQoULBn1CtRucGc/cUToQW4RdoAPhNtSXZ+El48qF7V5i6Gkyir7lX4le qOqjNVz5BM54hR58ruHSXMc3iUo6fsEFQfJZX9fWZS+qYC7voMB8rOwOJRD3dBl/eLTh v1BQHNzcuel+hL+Sqnaaebuhw/zjmBVkgTsvG5Xv3jvYhtnFBvrq6UsYmEIzk9D3JtDj OJ5GGy6iYVKr7u5WCObVL2F+NmctPkVbjOkhqxB36awZBi48Cw6j374a7eqvV4YwP06v tPfNW/vdRlhsoZ2bUyCU2/WBMXY9EyYVA+JL/jGzJRE9uLdm2hR8IEPSZilRKlaZKT6+ MQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:18 +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 1A4J0PIi122897; Thu, 4 Nov 2021 19:05:16 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwuG9MaZxz2k7y8i76qfDRADGUyVH1/nlAqiOuUTNcV69NUEXYuHkHA3xCCI2xuadte4MS5IuvlAPY7BuEN4vt7bxlbY142Wh8K1Av4PgZfl6MOk4DamGPgSxenE7+pntJE/tcdmfzb1+x5oMB0GyLtxO7aZ4pDP1twc7ZG8dQhBMb1LIz78C7dpjpbFBs3hkVMq75KVYdHuHNrjiOvaAlkC4yZluaL43UbfViT/MJ6Hl5/mJmeVHX4d4YCCntQTLughpLC4KfcNHdtbcnwFPScQRAT3NizNgnrjbrHe2PW/5gTfztLGnRYjOvG56IGooj0/sZDRU4u1qtg1Mb2dMQ== 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=tecX3TKZejVzr2ZrluTgNOxcyIPArSV9kd7wAux0mCU=; b=DOzsVharuUZBUDqgFEsNLD3R3Ga9o81eRzU30I2BuF1Oe7mySZNRUS74RUwFZbOEQ2oV1JcqduD3LZPqJ9kV9Pj1O8JGs1xm2CXquw808iNCdA40lLM721zzdWfQENl3QQzJ6Yso0rL+bs2B8QdBRHF5L7/+VICuSVmgTBzIobHphZCv3G+zf1AYbJaz9dJp9xkgM4/214eWy1SatlhHOBGirb6l+9JdVAXMgKtv93AWOz1/qGY0CocRZIasjayUq1D0m8mTuqS2hCs1Vkz33cJS6SBTbSgGU71Dz0LXw+AghpKhfxbdK/yWZYKwcL0F5bJNrv8cRfZhsGqeShQ8Fg== 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=tecX3TKZejVzr2ZrluTgNOxcyIPArSV9kd7wAux0mCU=; b=hXTvr7cbpTMGWrG5iXohY0cIK7Wogp8lLaucaa7lZSssKXyUt22mcgZkR5fhP3W6ICy958F/wkJwRj6VOoQj8EEG61SKYh/Q087uu+ldSbgZkys1FC+6AbddkxvLb3A8H+iQn+bl4kVhzuDBMbsjNP0BWpQY3OwiuQw5BPGz9So= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:13 +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.4669.011; Thu, 4 Nov 2021 19:05:12 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 06/12] vhost-sock: convert to vq helpers Date: Thu, 4 Nov 2021 14:04:56 -0500 Message-Id: <20211104190502.7053-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64797a84-1f0c-4e56-ec57-08d99fc60769 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4cqOsbzO1ALbDzYK5f3IjR4N4jnqDmusVMza/eYO2zUVWKXep//HuzQB+ohx+Nxl8CCeOkmQjYaYe9InNGrDnfuIlSGZR++I4PPBQnry01FWmNpgWQHoF9B6Tk2uF5OvurY7W1ALm/zFAe8L9TDw+JAyjGD4TFKnWMKyMxohGqroqCE1UIuy41FOZDAWFoYnM69KX2+aE1sjTLuWhLkMpWYqI/dtYvhL450iaLA91TvkQ2iy5/EFqJFH9RKH57JpcJUxq7buDIHJX8k4a3ngwL3SHlz8kF9DhhM/V+lPJoXS30sfvgkkLp5cV+ROILdJLN2H2N3BDwWk10UG5jtAq4Z4kzoDZGwgS0FltYiOpy35IbA6OSj5BQS3FuZ7Ca1VaKyHijntezHTxOCYPSk9Y7wGjBJDB6QzPxCnv8b91zI6zruwlVnk6GzehJLrAZkkDwBrF9N2RoFwECvPcgXIol78UArvKh5i/WuiLKn7HsUE/eNbhp7DhNL8YzX/swG/30HXuM0NPyQkZvFnYolromdBdXIzaFiJAl+tolmCYjt7+29yvaGV7GtkIps+ajOdJdPvvT6cZ9Qro016MWB9bXpaE6FhnwCi+0tvPo5Zle5TXrv2jfrywDw/KvXUDM+B9mQoDkSa6j+bjTArHeT+pgvX8xeZ80jld2m1JzHb8zyHomdKgmVR/XbBLdzBiDlv9J3TazJTDnV7CDUVunRykA== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j8u5b7nWV+hlmA2fl6s9dQiybNbXWRQrDdD2OSD2Qnkj7ofaMdzinr0M7JeDElzpX0MHPv/V9iK3mzu4jZRjOYB6Dtz1/yMeLN0F3h3ztZOld5wmE7M5wrVmS7PIk73heIhNvupDVflxR7oFQ2WWqE/tZJQCgxDc7TH5yU14KcvtcY3zgPM5Ned46/6hTzYFrCpK53Gsw9Q081A3kyMhuuhfmeh6e9BDEK80p9H2q9OmpcOJc9lmCVkBfbtBuImwrwsoAtr66x9Pzh3r2m1mcD1hodvgJkWEC7YKTCfsZczpRaZjs6+1W3N1Ijnio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7FsDfH8/ifWHKts50JRQFffaZ9GDPIXKakMN1Zx4tlRvG4lcsicbHdGQgk0S+2LiDQQrkKjtajGl8orMbMrqGrvHnppRUAUgBfI3oZlGv+ZITbG3U9ObpDAXuRDixOVPVO8owlY6tG8o5sRv4taCRnF7QOaroLRLHYM01HXjiUN3vIDAFgLUq1pG7c/e0dcEpkwtriEEd0VqDr7qYwrDS1717zD8fXDHpqkzgm0DX/XfNDw+ZPrWk3PepRnYn8sJILNQWEAIaobZNfCRFIj7fw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64797a84-1f0c-4e56-ec57-08d99fc60769 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:12.8818 (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: X5mYxXIkjnExPNUajTSQo4vggiDQRquyzO57cLT9JMR4n5/OAblhAPVR2a+OF+puB7XEu6JfxhTK3xTv7I/+SAM6vx16e0KEvTLqV0lUm2o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: e8UrUeOu-oKJ1tkjJRY99aSR_t2tNzOX X-Proofpoint-GUID: e8UrUeOu-oKJ1tkjJRY99aSR_t2tNzOX Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert from vhost dev based helpers to vq ones. Signed-off-by: Mike Christie --- drivers/vhost/vsock.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 938aefbc75ec..0c9681e120de 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; @@ -612,7 +612,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; @@ -712,7 +712,9 @@ static void vhost_vsock_flush(struct vhost_vsock *vsock) for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) if (vsock->vqs[i].handle_kick) vhost_poll_flush(&vsock->vqs[i].poll); - vhost_work_dev_flush(&vsock->dev); + + vhost_vq_work_flush(&vsock->vqs[VSOCK_VQ_TX]); + vhost_vq_work_flush(&vsock->vqs[VSOCK_VQ_RX]); } static void vhost_vsock_reset_orphans(struct sock *sk) From patchwork Thu Nov 4 19:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603693 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02821C433FE for ; Thu, 4 Nov 2021 19:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E337C61215 for ; Thu, 4 Nov 2021 19:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234242AbhKDTIR (ORCPT ); Thu, 4 Nov 2021 15:08:17 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:31746 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbhKDTIB (ORCPT ); Thu, 4 Nov 2021 15:08:01 -0400 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 1A4IWnvj001563; Thu, 4 Nov 2021 19:05:19 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=V2BiWlWONQB9Fkj62gZN5o6V72Nn3xht8vO97+bmBR0=; b=G3ojJFHHl/L/lXUuIAFUfdn39ABfIdzQ7mvh0/sQ8MjApXLVyFnTGE2ISgm66QX1saeF 5KyWC4sil7cqzHe+gd8jeNyBH1BKgmp/yV6X1NRwbqaUmqoHhedCF2NhsXrCH9nuB9It +3J4S+WwgjmSSSKCAnZKaTKKP2o2bIP4HJwq0Yh0t/Ei0s9Wals3aPdRo8idQKh9iIAy 295EYl6tDo7OkY+4nBcob5qXPS8CvA2AQGccdcseK067O8nbBlb/wVpnj+1LR5yxfj25 X/PxXFvk8GTuJJjSjoLTx5Y3foBs82ize+yIp//yLEXu3C4Z+bRwi9pywXL27KJG2cqZ Eg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:18 +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 1A4J0PIj122897; Thu, 4 Nov 2021 19:05:17 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3/UzKqW0kHrLfPdfItnlXk8Wsz4QG8cdNxX1DwDWL1sTKhyzh5nCXecCL/QjjwRbFMXDCbGuKieVitvAy02kn2vKA6+JgZNUEXUuFH04s48Ycg3u8880yMi1IBmPWR4nzBdY4l1IJ8tYIvAt/uinaNgtb9MRESGLTwjWDcvhAB2qACYlaVBm1zXVDZQpqhgen4C8RpE7FL673bAZqaaK6h8BJQB3KXC7S3A1XwKgW1wdqlpzmONlrsRei0exZ0XFSVUNDxumhABJya25UgWPZGsE+kWvs60iPedFvWYC+XRuV5jw/Yx3BKWw5mcFQ/LzY+4Znu6oJU1b2aNsVUDhA== 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=V2BiWlWONQB9Fkj62gZN5o6V72Nn3xht8vO97+bmBR0=; b=GMTfZRpuwOUx7c7XxuMLVQr1ZZwOLf63nNJNG2UkIhhE0EXWFnxMA/AvfXFBcAspwFxzpoVC0prlj1x1DV9H9y7I6Gu0YKgo/FQEvZE4hFIcnl2bL7SSk8R+iZ10F4fP/itEFQp9N6wftRfbaYw3aygfDzybyQs+zoOuBHVQF+IZcRJTFGi7s3uWzPsG+0BDI1zIxatT/V22sK9AtSF4JQaT5PlN9SY58hDeEfcTeJ+YfyVuKi4p5GNefgaiETlPorCT8I/WKfRHLtv9/i8jo24eTfXJ6hOvV2EgWnGnWmACV1xvLIuefyQHBD/5AkkXq5SzqZuPNxK0L/bm1Q+Fbg== 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=V2BiWlWONQB9Fkj62gZN5o6V72Nn3xht8vO97+bmBR0=; b=ayLacFo2GpxkFwiuq7WO9xYe8ErzwVw6v0DSOoxAn4yWGsVLzgyqMzqpgHapa2o0hTpg/QTDAZgdaO/4sSYrzz+WicEdqCu+obVmT155LLm2UOLHkpfM85f76xRHLcZxQ7kJVa0aT2CC5Xv2YGKkqgttIDJJm+Q18AP0zgWsyU8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:13 +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.4669.011; Thu, 4 Nov 2021 19:05:13 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 07/12] vhost-scsi: make SCSI cmd completion per vq Date: Thu, 4 Nov 2021 14:04:57 -0500 Message-Id: <20211104190502.7053-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: daea8f37-21e4-4651-e462-08d99fc607c5 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: 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: z66mMg3HtzMWd9suOY4GWYlV+weLZTzUSmNLWvg85YYeCDPBmqt8xGHRFmK/6HU8yVKmTLIhdg1phO6qFU5eIrtobTmgARwckXC08t6o15iillrOumqTMmGZhIFbhxWxjqSRzcQUiohA/Kk9Uy6Tm0shYRV0+PxhFPSRgbPnhXSD04amdytg83s9pvmVQqr05PBixVoFPmmDhEiCTH6QhzJgktlPIoJ0/4wB9O6cOhdoQg8yFfWexWHusY5cOx217HJvzQof7rTUPNJlJu9ni4cdyPawyngzioogwRJ5JHM6Qt1R9d/HQ6z9MKKNbH/PkWzo4gonCU1FynAnHcNTJmXDAy9uKB9CIRLwWuZ0EKOCYqwt2fLjpo1/g8ILc3xA0WsNjFp9PXBJXg1TiVumGApdCoR0k6Q0Hd8eVOScbppxq7SYfvYXbJdzs1LoYvttFCLZ1a1h3GG98xRTavlWYkr/ITGOQdHTsrqqgQWnVtSLnW3uxLBJ/K8QjyWQQZXLnkVp8gD31zxsfYrNrD/6Bo3b8rhuHAjjCfXL/PtpkXEDLV5jv+cUAmzvlh8NIuZAoT1BDhMR3WHdHo4hiIxDfHe4vhIHWUC8+NL5bFh2IWHZJEejcfsRFYw8RTgZabOQ3l6BFDIak6U9NWfsvHHakaXDf9IRAb/T0KZoQKkftm4v62ZQrWTP/yZOd5bwduZU0lBKdMkGHAtcBGDgSHvacw== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a0s4kz+flKFKa3RP+voj0UEMjtvCJLy5aITOtH5OMslzwHXDjeO51BCp3A5eKl7aLdaFEHTuSiCG08DymQc1eTPx4mD8RoJnGWY0Dpwh8R3g6txSOy3Yg7/LF65rniNYwO5tIWRw44gB7ICUtpuUqw46Jnm1WKdqrXzPp/wWcVXquz+uVISzcijNTLaglc/Lm3U+Y3lcUtVPu1F8O+zobgi+fekzfBUYwBxWLtcQRI7WNtRYzAAu2La2b9Rp64EEOygxlCfGIJIfIZ2FAkcMeyQV3+dfrL7R8sU0M59Ta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JdN5q6Qh7oyFcU9RN3P8pt9PY9Vh3Rq0q/OeIwl34kZAY1l93mxHIXL/LPnDZYHHy8fJqlI+VY0v1Y3dfs7qYKxnXhWhMql+rqcHsYaRNd5evtBnq3194XIDh5ZfZcYD31C8skC3P7TYtdLgiC3shIGFCILCNAzUGWflBFn3+9n/Z3Bs7IDWmBqXYCxwCq2tYzs9VEvNPuXwx1S1+j7BMbyXtjlzTMXzu/zkyg0qHn6yc6s6WMZU0IsiLROCim47p7xzEusX2iReo657s25rb80UYxAda1SaXeescAxDWpeUiD2QPg/r/hF1f8EgKxja6A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: daea8f37-21e4-4651-e462-08d99fc607c5 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:13.3855 (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: 7l9NTT/QxMCQJTn4VEVOtPAbekh5Ts4e3gUu7GGQgxAVzsqBeftJ5N4yBuF8H6JMQ8ocMbg0gZezcPrlpup0+eVGeYmPAEEDMg/7yxUR5BE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: ThkAG-cKJgLX4szjQnO1DUNJk0jqY8DN X-Proofpoint-GUID: ThkAG-cKJgLX4szjQnO1DUNJk0jqY8DN 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 532e204f2b1b..0d85ddb68420 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 Thu Nov 4 19:04:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603691 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8301C43217 for ; Thu, 4 Nov 2021 19:05:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95BEE61051 for ; Thu, 4 Nov 2021 19:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234240AbhKDTIR (ORCPT ); Thu, 4 Nov 2021 15:08:17 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:33068 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbhKDTIB (ORCPT ); Thu, 4 Nov 2021 15:08:01 -0400 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 1A4IapaE001625; Thu, 4 Nov 2021 19:05:20 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=BGDDUIOqDwyhFnOlbOmNwt4zkp0IVmaJ2y7UYayCi0g=; b=Wfm4GH0nis6ysVyQ/sTi4RJsIbllGKwCRj7u33DAIbwniZyzSr7PgxUaDYlJVBQmsF9N NMRxmfb1zIE2vxUqcfsHVopOppl/YE/KvLiImxGetGzYwuPmnI9tcQgPGuHH9FV2NEMI vuDUUmp8/SR7EUvQsun/UdC4hG+lmVH8lTltyBXfPLMPoAXnKibHTw+0DgFDOty14pyI PMBhKhMDXw2JvJfCbpIZ5wMOmQXFkS95FbYC0YSXUVlno3hEqO8ZQ/PiD8J97eSutEKE I8oPHiKr0o7WwFOCR9vye28KQ0TreZJWunOq70t+EGbELTZgH5nhpJQDtVy5gAHfHCRw ZA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:19 +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 1A4J0PIl122897; Thu, 4 Nov 2021 19:05:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMbj35niI5sOFDl2TrF4YfrmZnSApvx2CeLFMSENPsU6D7eVdUd1KNdssThhfpbHbhwbwi5BYyfXk9iVWSCEvCgPUkrxiif0iX9UOJtgnEZwvhcSMTggMuVR0vLTqR/2FHaAtcD8YYj0klCgrS2eaHhrQf5HFREmdwgktAQJC70cN1JZZ8Kmy8KA7TY0T1wBW1kJoGfSM4FoBDl2LG7y8vjWgvRRc/lbXijkZwaBYeBb31e8FiFQeKqCjYCO70c2oftvIEc5UTUZ+mnQcoo6N0pM5XrJnOzSadrGuOLlNU1Rv8FWy5EBd8qB4Q6iopBgQTA7hfTCT0nXRjZ4xQGEhw== 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=BGDDUIOqDwyhFnOlbOmNwt4zkp0IVmaJ2y7UYayCi0g=; b=I45FxeN40b1vHQ6LMmJ1nvsFaFEw9Nu4cqdV7WJU6Dovgf/QB5ySOU3HXgq4ZRscY+6v38hzm93jC6kou+l0SfsjQeyrXulTym+sa3WQINKJzelDr8ouAf8D2IXS3efu3yl7JTyxz76qby2m6OE3zUnnHPY+3v8URBohAPJaTVJDMSo9VaJxVKZKXUFqzYbjG3a4QWR9NRl+rx3r5+ziihZZNl0qn30Lz7TdlS5rf3Y6ERI6kOJJ5rGS6JCi2cRlGM2+hNRq1YwrLlQDEwVNkNTk2WQ97bEKyomLaYUJK1zIKug2Im8ydn0tC8fV5a5PK4++67TUDjkh6R5u/CEpRA== 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=BGDDUIOqDwyhFnOlbOmNwt4zkp0IVmaJ2y7UYayCi0g=; b=zYcYtnvcW6UAyBS+r6U3OKigRcQm0n4QxCjGLAVva8kcZuDkDvkswbYgwFNldX8paaaoifkEgBEr4FNV+IfLgTCs2inmNtTSd9ZqB9/gMAUZimxkdXPUV7F7Gp9jzvXgcJlrtxThvcdBHBBRoA0xunkQ4dIsZyPKDJ7NpeDqcqg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:14 +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.4669.011; Thu, 4 Nov 2021 19:05:14 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 08/12] vhost-scsi: convert to vq helpers Date: Thu, 4 Nov 2021 14:04:58 -0500 Message-Id: <20211104190502.7053-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c5f18b4-72a7-448d-0cb1-08d99fc60815 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DIUANvzNDRcP3T2JRgAKgnE3btkvWcu4jXIETBNQRd0el/3fu8tHVu+ZdkImha918JrE6JUDnIUBtvGocuEuLw3h7ADd/g/he6OuRZaftjUdB6TsqnEfsM0pvpoZWjMjZJb0DMKgb+wLflyaYR/5HW3UlJvdjuXRGpWScQMzbpVKlO33XKsohN5JtIOpEW+ftIt2x4l5oGZLgE+2ok2hhRTCHnRtCAj/cahoHqjSOcdOAzU7EPIuLxNK0lL4iOcBxJ1VLc6xH6jhlcjUhGyK0pQyl8UYb1a8YytZHhBO8UKPd5ZehIRn4YvaX5dWbuF9RnrY5F6MYlymZIzcvAmWGVUbWxPUIqOzqcxuEW4nUuYNGjmNvlsEkd8zKt/RRBHrB1FOmmeYwQ/vh8yUUbT82pwmxdHjdEdVsoRXULkb1y0XysC6FalgsgitAKP3VOqjyOTWcujjAqFRoZV8aJ6+IaguVtc4ko1aEQk/ng54+wLdfr58JWZbpbV2VYYZim1P18NlEo4gioYtG1OzGqB7BjvpODV9hFdsGpdqNqS9xH1DXDRtEi7yKfBVGTLRWpfndqjtruPlgdNGkjZJxm/p/CXcSMCqmzDOG/tgqTqW/562gXeMxuoKCFUOkz6W599Qm8KWHQJxlhwieVScyoCoEP7IKtOPyR+XH9KOua1W9asXGzzPkvaWvYlHOXeVaFiVyWjGBLMWc1X42eDceBAY5A== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0eVLF2kopHOlZn5bFJ0LHDbJmJfkfyk2e8e73NxBuqj6lUIPMXBiNd3FzufeRtK5w48wDAMo0Uw+RMJ7p5TZx/Ua3cUMo/1w2HHPcPMHZ5NAPG6KC3lZe8L3RltHPDYwO6U4LZEEhIs3U2WU1LF3yWEK7gDBtgMsAgzl8zx1JSHhj3Od69HN8LSbrcjESGFvIzG26v2L1y3R14XUNRpzzGu1GFFd/soG+JnPdwKOpFWLlSr+bbrqJMNyHdb+QBxuhPkjyLM5JZ8e3D6JPHo9ULlS0Ncvj+5n1lBvG2YttjmpNVzKrVRQdVbR42XBexSGJIhdcqrtlAocxIcQnSfbn26ssiXyXKn77MKp3G9Uvd0ayBJbgLokzwYbVR4fjsJ/xT60KtoovkZvjNWmu1o6xatxUqR2n1PCPkPZXuTcIWEIy8q56yYskjs0OdnyUdDJGqn9WU9ZkpxxKVcqj/RszjwD235gSsUKzrDKU7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Gr4RjDQ1RycaV3MoRFb+oZnz861UD6zE8Fycvj80B1Qw+P9DXCW88oB1BKOFk7b0Awt8IxGgODutbeQktpaBnTem3QDx+GT/ZmzB8LTc+1rAk1hRTyKMGkmQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c5f18b4-72a7-448d-0cb1-08d99fc60815 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:13.8763 (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: GBr6GhvSfyiBNFGIUz/WmAtdP5I1NuDZrSm65TDAt7pHdLhKEUDYBAWO08bm4GeSMrBg3mw6HCqJM4UYGyfv6kemMuk1jnAIVAWohQQqwms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: sgsOQUCwxd53Ss-KMkvmUHsGz_2Yps0f X-Proofpoint-GUID: sgsOQUCwxd53Ss-KMkvmUHsGz_2Yps0f Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert from vhost dev based helpers to vq ones. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 0d85ddb68420..08beba73ada4 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); } @@ -1428,11 +1428,10 @@ static void vhost_scsi_flush(struct vhost_scsi *vs) * indicate the start of the flush operation so that it will reach 0 * when all the reqs are finished. */ - for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) + for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { kref_put(&old_inflight[i]->kref, vhost_scsi_done_inflight); - - /* Flush both the vhost poll and vhost work */ - vhost_work_dev_flush(&vs->dev); + vhost_vq_work_flush(&vs->vqs[i].vq); + } /* Wait for all reqs issued before the flush to be finished */ for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) @@ -1967,8 +1966,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 Thu Nov 4 19:04:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603695 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C52DFC433F5 for ; Thu, 4 Nov 2021 19:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFD8461157 for ; Thu, 4 Nov 2021 19:05:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234244AbhKDTIS (ORCPT ); Thu, 4 Nov 2021 15:08:18 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:35644 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbhKDTIC (ORCPT ); Thu, 4 Nov 2021 15:08:02 -0400 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 1A4IXJJx027064; Thu, 4 Nov 2021 19:05:21 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=2ALhmznvgKCqZqdwocieI5s5BoZZTfqEGdJWV86lc6I=; b=v0vOpGLANSTK37k3Vvwr0vSHVDCo97p/07iolvATXO9fIlc+G7GLtBDPSHVxwKhy6Kxl 9tqgQl5xZ6IsopMR9I1rdDOA9lvhg1592NprBZEBOfjv+Wc9rYaURrPCXHDGjoMlS6fm aU07NkrGvNku0mqgF4HDdxu+c3OeF7o6b+uD/9cN1HWu7uDROm3AQDXosFiKbnfb4BPz DZN4psrE6UrGtd7qrA6FiCMVEoBf/yX1gFziL/L1YM+BiyWSyQsptoDe/gSe3J7Bcp4F ttID8ozcOPqXUWeexS98rXJ8lKjq5LeaO6QUhKkHfmfdmVoKVQdOXHml/fjrmODyyHFp 7w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3mxham5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:20 +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 1A4J0PIm122897; Thu, 4 Nov 2021 19:05:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCyId2Xa5+i8y/J71g6kp52RZzTxSQwKST//y+v+3D0VmeZuFCeAWSk9TFq7cRZWMyMeivSwpb4Rrmhajblt9Arnlb0SVq7w4BoEEBzbXeUpwyYKlgphKJtAfME5cKuZHWYAn/fJi+Stwp7pIM1Wo9jzLC1NtT1/IjtvQvo4ljmFt7EC1owh9+YRN45cRS684jSZZC2RkPvFkAFrnTl8PQWDmCbfahMikeRIZwbnJyW4CDjQmlxjjElGYhRK4r2RbF0ovrg4023mDT8wx7eZ1sCMthhueBVAZFoE1JNpu3syUGl8n2qoOSkV5aT+MsqiBpLDe4jZr/XuZMOsHOlJjw== 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=2ALhmznvgKCqZqdwocieI5s5BoZZTfqEGdJWV86lc6I=; b=QetJvnlOr6N3s+CGqKSk3oCW+HZDnMBo4DmaWauosnCUdoEvBLQR+GnmmpJv4Th10BsNzcBKqA3V0T9HnmqxrdGtfQXySuRhKPwZaFlKZEGIUl/PdwAL+KRU1hMSZlQ16UIUH0ghPrUX6mGOhKO633W59LvyCnmlcdSdQmICDt+qTKIk/TGXGiYK7OaORgOJozMi8LHltvfzuXfJLiK5aTu4dl+4RAP6hJPGZ2tlgxNe7sUSXg8qJAkhhYuT0khAGBt4B73LcmgR3xKXsuaDbniVjCf5AadeF2jlZ7BU7MM+lQpT88SVj6iKTRsACmPZJjDKjMrl5pLyv7ipMMlXRw== 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=2ALhmznvgKCqZqdwocieI5s5BoZZTfqEGdJWV86lc6I=; b=zON/9s5vC7bG4GCjNO3ILPH+uF25RTJC2uQk9eTLcKiAlVYzYkVsOpS4eNBt5oPdKetLH3mXyu4nJ/EjGXrgNvHToJ5eQNZJFEelQYOpN5kUGqrFuMEsp4XKbeg6s0areuxDP94zv5KH0NtY063Je9l70+5lhHEuB5ZBHC0TcNM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:14 +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.4669.011; Thu, 4 Nov 2021 19:05:14 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 09/12] vhost-scsi: flush IO vqs then send TMF rsp Date: Thu, 4 Nov 2021 14:04:59 -0500 Message-Id: <20211104190502.7053-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5421532d-ab13-4084-fcfb-08d99fc60859 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GbBkrHddWHTTEH+IiIt90r1WQqxC08p+ofkohQVeRLxbWdvIuA0kCwjUjxxd1ricM2ob7RwVKCYw+jDdvitiOIKn/wWHhy++QvLLQ4jtcx02k1fJToblEfY0DxDNfkl7l/j9CbEe8nrGMtTAknSKL1eUHwXuPSRmH0f/ds8fkBKIuPVQF+jY9R66YDGioNr5l42Lll/sXzm2r/v7MmCG0Af6XnQ7vtQNVBekTeCA0p34PosdIbpEpKR6HBYat4j+KE3FIQYPwvyilNMnFkubAsS6fBlirIvSZxjUVuvRH5rINI35PqplNcL+R8HdoKckbX6tO0DF9YaIdu0PTGwxozka4FKFcwYoJkeTaG5i0PpfH9bkfGxljWD1vvzQUtg7Fus+j7Fgfv3gFj1hgBZe0qymua5gPFXIDfVdziPpNah21TxDGMejVMT1N0ah68CyuNh9ItVhlaBI5ySJwKrYy4UdNNfluCkFtpOdwdw6OW5VgwH9siwi5/1ncHKhs2tLR+lXgYVbAjANKOS1Zv2gvACpIMQ4xFUJxC5oCEdBXnxqNzS3+ar2PYCGLT83ZxhfoLfGEOsKS7VCudW1bmXpHwsybu5xHs3sFrHt5sAw/+34Qdipi2OWg2mTnCmglocNh4t+RHkgbtp17KmVsZEMbE14U/33W7bn6N24nWNFGCxersQ1e1roZt70R7Mm8v27p4LfTjIlXm7OyNeahxkdSw== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 07Q6WyegPsg3VklUtWSLCRCYtkNQ7waVnuh4NlkkxlfthkAdWOzLJrv6hMagZQEGt1hy5hW4lKbH7BYKmJx1egEVNfzpJ/lEOsHDlHZJfbl444ALMM7VekADGY2REu64NuCR7uOVkfJZ2i5G7Vr3LMCwLHgayEGZOQwyo7aHdDwLvEUpRDwPIyFQSprsESySJVyJOKQpoWiSlz46UcJUBKbIQRxyg7s5d+TIRh3+peJFra1Lon31Es0E/kJ5I+kBzeEO7vI3eqDC3j5xYAd151i0yqj1TTZri/uudhWWXqAlv7+Xf7dYHr2/eqso7+gzEEYPzgMLwE2gjUHqv9HwhSXN+nALhJeOBY5LwkfLfQs5vauAOZGn4R6A47vSq/2dngeai2YjlPz8gZFjxn1/W/ZHY2dsR3HqfSmlR/cRj2i3wrClgvB3IwUDQBHappr8dwT9QNMjJVOM+gmE7cZiB4MTB3I6m9KoFO6IWXDw/dhfnlcM05ql1Wk+IZYXOyE4RR92YmDbIVtyrHlQuY7ZNvYrKI0U9tGE+siPY0KrpLNqG1rBt6tzdHqkAocjtXyM7FJEbnKTaDQT9+QfKc4K579oDQqU8KEBGhsUNuT9ZU2SLYrWajaIGYUeSJ5GQ00yhbOh8R/KSeg1iQSbtaFBPbjV6xjPvGTPFQYxD8Yckt05SP55o+K353R0bPcS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859 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:14.3381 (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: DtfczlmBUpTEEiRu8lekULNyCeHKeJo5FXlEsIEHYiG479+jqq50l4IMGoUdoWalga62n0eSz1prXs95P4GtnZhoKOi4i4zIrqA+E1nOaIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: CC3Hy-Oq5Zh9FKqzKEVQePELTBOBio2k X-Proofpoint-GUID: CC3Hy-Oq5Zh9FKqzKEVQePELTBOBio2k 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, one of the IO vq threads could be run after the TMF is queued, so this has us flush the IO vqs that don't share a woker with the CTL vq (the vq that handles TMFs) before sending the TMF response. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 08beba73ada4..29d9adcdb4fc 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1153,12 +1153,28 @@ static void vhost_scsi_tmf_resp_work(struct vhost_work *work) { struct vhost_scsi_tmf *tmf = container_of(work, struct vhost_scsi_tmf, vwork); - int resp_code; + struct vhost_virtqueue *ctl_vq, *vq; + int resp_code, i; + + if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE) { + /* + * Flush IO vqs that don't share a worker with the ctl to make + * sure they have sent their responses before us. + */ + ctl_vq = &tmf->vhost->vqs[VHOST_SCSI_VQ_CTL].vq; + for (i = VHOST_SCSI_VQ_IO; i < tmf->vhost->dev.nvqs; i++) { + vq = &tmf->vhost->vqs[i].vq; + + if (vhost_vq_is_setup(vq) && + vq->worker != ctl_vq->worker) { + vhost_vq_work_flush(vq); + } + } - if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE) resp_code = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; - else + } else { resp_code = VIRTIO_SCSI_S_FUNCTION_REJECTED; + } vhost_scsi_send_tmf_resp(tmf->vhost, &tmf->svq->vq, tmf->in_iovs, tmf->vq_desc, &tmf->resp_iov, resp_code); From patchwork Thu Nov 4 19:05:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603697 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC784C4167B for ; Thu, 4 Nov 2021 19:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93BFA61051 for ; Thu, 4 Nov 2021 19:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234254AbhKDTIS (ORCPT ); Thu, 4 Nov 2021 15:08:18 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:36180 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbhKDTIC (ORCPT ); Thu, 4 Nov 2021 15:08:02 -0400 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 1A4IRGe4027061; Thu, 4 Nov 2021 19:05:21 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=fspmCOXmEpt+I2Zli2AQcYiLadL+u7tR5vrwNrLtu8w=; b=uwnZVkIi3RNwZdvitKIv3W6jvwZ5tXaLAOhG0em686hNtFbqptZ0bn4gkF46cRSX31H0 Wh6GVP/Q7o6mSHKYIsHmUPG+DCqTo2yHFmsVPDtCTWr09QRdNKaASe2RMldX2Trk7Zf9 KThUNZaNwCQQybyUWH5+HXFy1B5dhiPBy5D24qUFzzRIeweWKXcUDl/9U5aESg1ysPr2 MLmjMR31wKi6ongIpWx1ntOGeEq1wmcYQI6k31+SOeOHWKZWL9LD2erw+GyDwyJHVG6/ oN4orMYn1HUKOzECITrKU9qRt/fIsZxHnxZDZ8OMWpzindWJF5BIWH95Jh6fmqV9/rYO +g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3mxham67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:21 +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 1A4J0PIn122897; Thu, 4 Nov 2021 19:05:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jlYKSUC5L6kWtywa9vHYaPWHFIgvmtHxGg6+XChIAnrIuY5A6elC9RBJx+O6pcat2Y/Qml4TWNAFOXcDL3Cphl5n3O4bHdZYsEqiIT8up8rPJLkJP9X7nDCHzuwm8RhRIsE9mJ+r6BtPzjruNBHWBxTri/aN3r+i2xOF4Di5tsZyryIf+U14rGt59Sw2lizEcnmy+WYG6W9d3T+8U3xpp7I4/IfXK4yoGNDl7kDac6keGSS45nox6r1hYxdFB4j3Oi5mTG73A1iqig6FxTHCHJUNxj7eXx1S/cA01BNdaZ93wsHDrOJE31IcrB1fZgztTmMTgLCmUnVxwUS/LJ5prQ== 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=fspmCOXmEpt+I2Zli2AQcYiLadL+u7tR5vrwNrLtu8w=; b=BLy4K3yLrUR48Qs8TRr+dG3j1GVoPARg68DgKBd34frm8dJYzxhxU7aKQHWcJLB0As/YZszWOfezIIcWAMKp9PmfnGv+Ys4YQ8ZNQiDRyxoz42zQPPbNN8hTqMw030E1uHn3u1Oj9V8IgoyVyZru5kK9vo72/Ksv4SXl3J9rNTEW/vUnd119kr+b6Q2Q6pV5knZgO709us/dWuOsrvt3a+x9e2+sk7c5693x4pjNVNTkayu8sRBGzi0/bzh/aibOmzYfpNqep/WGyfMWNTYpm83+zSr51ZUhvVY6BxsEEm+/tn75J1pMpGz8jOnk8AEQd/cGVRjtnEhDWamlRD3YYA== 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=fspmCOXmEpt+I2Zli2AQcYiLadL+u7tR5vrwNrLtu8w=; b=xb2p7TkMQZEPayJrvUsqXaFT3QcBkJn3nsU7j6bJj3H7DONYVmrWRGBs1yg4hfttLH03v5vu48OEw10td5jT1VNhyTHmL6W4y7Kd+HaNmvHZhXGjp/PSic72hWN9oOT7Jg3fHEYd8ggiHxKhFGdmUZxL/wQ+vXmO67WtGpMbqmE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:15 +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.4669.011; Thu, 4 Nov 2021 19:05:15 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 10/12] vhost: remove device wide queu/flushing helpers Date: Thu, 4 Nov 2021 14:05:00 -0500 Message-Id: <20211104190502.7053-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0318f15-a271-48aa-0f8d-08d99fc608aa X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wHSxI3i/kjPL4UNkYJ9+xVavnv/UPFmQW495mJZiTL+9TWTnOaU5cwGv8Y8xuzZMbqVNcUvaRinz0lebb8Nu05zt98ILa/afAhYfgV74KQF8ZfOovjyZiSRTwCzwoAn5cXA5pEJfqW8SiEEBEj54W2DKxfLGg+9JxYpt7JZT0zfWjUkjyFBrCXziB1nWhE7TLe6B5cX0T8rQmAy0CzMfZG3XxQh8e6c857W4DklqHk+5Pm54AWmxauukXnzInG3vx0t1Y9YDvLGFSdDpZjYD2NUaNl9P81gVYCAdYiM5sNLAo4M+i2Ic1brIB31dr/hnHr8sgpyFWGzaqE51latzcP6dNJNA5z6NOXC1vY+R0nYI7jiaPoG8efx6p7WGz6XKNtUchTc8EJ7bvm3OVwpI70ETTfT0mI+36W6hF/A9V4uDUHhET67XLF7TGkYBT7bvqWjq/CM7TpW56Ju2P4DFvMFtMJDwMlcIfvk9SQ8IhaMEQ1qPgrwflQEDSUn+04MJhI+Fs8x+/i0gQd5rMxfYD1LOlHlxQhpBWN2mEqstUH6bpVgzteiKcp2QTG51L1657jsG5tzDWc/8a8VgYcHoklbWe4q4SLm9Khf8zwu6X4bDFhcUJoq5RQdwUDQNMYueQTNKygyQnyYbzXd+Ed0XLGK17AHD+m0ya8p8ehfrQ1rAp+U0UrIIyw0woeIkCEUh4iV0Idxgd+3ArE+1VSVl2w== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pi2sMSwqtPcndXiOSN1rB7F9BTILQS1lmy17xR6tHkxBt56nOFH3COtlOBUzQAFJxrUOAK67l80MR3tjy7PKXGLJ3pxtK0ecHkKeOt3Onmch5rI4Ox88RIoz0V8icRDS5eAfwnRN9tu5qAFS0fL3GmlPLoa9KvvT+S39fyYidHqVjToV/eBmCxX5FwLzI6cp6WSCNVtHn6GfouH4VBGgsD7CPAu4T893NQJHp3MaCNCo+LTvDj0cPZlR3OEGDhzRDc+ax8a3gJ4kvDUgnIOuste+GASmM9wXAJooAj0bTulEqPQbcZmvgIJjXEjHu5AJGk0OQxCU8VxfuCVBtXaxcajGITb+UGCcToVq1wVsXPEMvl93Uzo41RTbzP0hHqmKcUtn19zNTvOVkbrj0Da2DpyoFIxyqyoS/l11rRqZcHc6TuMNJphk5ucN76zvUtw+Rekvpr/JX9ErscP+KPi2E73RO7td+ivLiFTtNp/LNqfrV6Lx3BniyWdGNdKUtTWxWNS0TCLXrBENY1Xna716OOgFqgIXfhNzCtq6au9o8pYzMmOzcLv1cagAAarFu7km2WxnzQK64YY18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BJjksn1rbcOfL4AE8OXGNi0A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0318f15-a271-48aa-0f8d-08d99fc608aa X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:14.9078 (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: ln9QHhXAEsDB0l8OMaAyXjgzTsX57llg5kAPcSZB6Eo4299x0fN9dVvNMpN85nN4c4A0vO2FRGtrPMqwmyPCdBadmCzMnhbyxSzSXz9YICI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: AZREJikqd3iDhO7EHRtH3pwcC8yECSHc X-Proofpoint-GUID: AZREJikqd3iDhO7EHRtH3pwcC8yECSHc Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org vhost_work_queue and vhost_work_dev_flush are no longer used, so drop them. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 12 ------------ drivers/vhost/vhost.h | 2 -- 2 files changed, 14 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index c84024afefff..04f43a6445e1 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -268,24 +268,12 @@ void vhost_vq_work_flush(struct vhost_virtqueue *vq) } EXPORT_SYMBOL_GPL(vhost_vq_work_flush); -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) -{ - vhost_work_flush_on(dev->worker); -} -EXPORT_SYMBOL_GPL(vhost_work_dev_flush); - /* Flush any work that has been scheduled. When calling this, don't hold any * locks that are also used by the callback. */ void vhost_poll_flush(struct vhost_poll *poll) diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index d9650da2be2c..33c63b24187a 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, @@ -59,7 +58,6 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file); void vhost_poll_stop(struct vhost_poll *poll); void vhost_poll_flush(struct vhost_poll *poll); void vhost_poll_queue(struct vhost_poll *poll); -void vhost_work_dev_flush(struct vhost_dev *dev); struct vhost_log { u64 addr; From patchwork Thu Nov 4 19:05:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603699 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0001C4332F for ; Thu, 4 Nov 2021 19:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D91A761051 for ; Thu, 4 Nov 2021 19:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234258AbhKDTIT (ORCPT ); Thu, 4 Nov 2021 15:08:19 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:38160 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbhKDTID (ORCPT ); Thu, 4 Nov 2021 15:08:03 -0400 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 1A4IWIBA001562; Thu, 4 Nov 2021 19:05:22 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=n1E7o68yNwWUlvCj0ZVoARYR497MCigAHBDlATsxRNc=; b=Q6f3/NdL0pk7T2ZXvuNUIoToSmQ2n187SzAhtoaSoqJzT7zBk6mQvSDXYjy6xA7x+EfQ pNucgBoE0uO/wGxdJqJD/yWjWfNJK7lZWfMGRwLq9AHNi5PFOE+WDvnkIOdzMVpI255h DQu10KFc+1fKQuQkawWsK+widmqaPiwFrCwyMkAi3ofeJRzjBs4PgS2d7Dk0Onwn+IPd mwKjDP1QPG/pwdlEG1Nt+m+JD9Iox/HqeRvnsFG2UKlaENoh44qsbyO6hDXG32TMOcwH pwvXsNQQvv9o5kQVT5fDFZpOirimO+MlcEG0SFtGMZmv6kWvU1tWEv7siecvJFDBqS+s tA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p9u8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:22 +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 1A4J0PIp122897; Thu, 4 Nov 2021 19:05:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 3c1khxpeas-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FaS+30Yyi7e1I+ffiXkGpmqyqRtE9dH27Usf9Qhlvv8uT2pzR5CVaiJ+4A+FHMGA7awQzFkhb16ni4jmdkNP8zYx3amITQpjvqM7RFvQpnA5L0hrGEEQbxlNlphxOLotX0O+sH9Bixt5wHgSJSwRn+fnQYVgZ8XK5AWhJsyMPJcUIAQx0YOXiaDVG4984kb3rkejvVmYX5L7bFof7QJmBUjR0lIzn2HfLk5QxhNWc/hJc9VCJbvv81JVok3EI3Z9hmkfkZCMt0n5Oq2Zn3mXRyjUKBCPwZZ/zgkfkT+Jzd6y9FTklmERBn3Dv8O6q6ARiWA2lGNReC8sztac4im1BA== 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=n1E7o68yNwWUlvCj0ZVoARYR497MCigAHBDlATsxRNc=; b=FhttiOmxJLD4Xnm8Ee0cZnCNAETU5AjpwuUjvDxKEcu+y5qkdXKxiZS34Bt0Tu42JZtKuI1nGVdBYSeXMfHdNoZT5V9X2JL7Q56I3uu26yLP6t22bx1bSoLZtTqWWEelBwGoV9KWWvEq3Oaefm0ps3kGysqR77n8z3I5inIhJt42z31w2ZwZRSjSVHGQfzB4lKQ9QrsYYR4+HlS/BpKL/GawLQSvzgR2wzPfuZdTM6VtOLBXft9PR2D1HzlZ2J7022qkzaDBlyFSxv+vaa4CFvgHSXNDdcAHj/8eaaR0v6KPwz8ieE3hDPrHPcpMTCOqeKF2MCkXn79YrvZum/Jodg== 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=n1E7o68yNwWUlvCj0ZVoARYR497MCigAHBDlATsxRNc=; b=aorLc7iGFir5BKIlTvKeSW/2YhVQsqPOB/m4hEA1qB30I91/xdmgFejA5CgWTdch5Gx0VZl9OZcMlBW6WtYnbTO6QfsxHSbQ/0OjbVP4wYJYd8qyyPjmCDzqZX6fjeDhBRcO3Kuwltl0qr0xOoqf1/PXfNNAdXdwBYRdH83eOMY= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:15 +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.4669.011; Thu, 4 Nov 2021 19:05:15 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 11/12] vhost: allow userspace to create workers Date: Thu, 4 Nov 2021 14:05:01 -0500 Message-Id: <20211104190502.7053-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bc47b5f-039d-45d9-6bc9-08d99fc608fc X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:972; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JoufT448qiPw4sM4/hm09H21Tqzs1RBnbiMq282NZ9iUmwye78RQJqkC6GoJmXYh3/q9npmSardNIHVJ0p5SVwlvw1Nv3ghLZ1k3YLyAou6weVjjiiCsQ2qdKMVZakMB1mftIenBoD69MvzWdDNkJ4roRsqFYF4ffCmpNlY6ojR5CY2ql5C/NZZDyqXyjkyl+fOA8kZMhJd2lQ5WKWCaOsoLSCV7TR3kGjFkgDo3rlozhkSJSBV/DR139HXWATEiRoKZmb+SfHJvysd1lnHE5MmkGXl1nUA1cCPQfBc8fOst7lwtoF7IueHRG6yHTltA54eqFsiXzzSSzOZfQbA37jOrCsKmqmgqcvFXobBK0w7tsHxM1St0VqpT38kzStPWqdm3c6VhyvNSL+i0d1uDsIXKmj7NHiWszXi0SnHkW1ekCjj80JmXuY78YD4Pg34jm2M/iNkEovvg9wIsMZQ3TbSLvgMZBINR2K28vlbraZWWu3aT5QUN4/k5ugB9DX4mVwcGYF1i9i+UyR66IGYvkJgsFyFePBNQjRHJesjcGwrkFRDheVfVhu8F5eed8Z5mWkn6nF3T3FbA4a0IRlNx/+wZPrZuX7KYVXy5AaBrXHrr4IyZJxTIS0jxZLHrVOZ2MQeMTsujkYr1nilpw52SHKj9H3Mjnm9xUPZaLiQAhusyWSNq16o9TlIEBYH3WOD/A8ROiaP3wVKliTg+hwlLjg== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(30864003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xKxTxA9LElXK/QD2RtYvLZlSlmVLyu2MDrKdRtcZ548+Vj5hQe3QzghO9XC6e8hSEy8DPOQLZOqAjiWF/8EhNey4QSAkcPPRr4STwo46dshXCR3reLjOGAboo9y2crCglO/ClP5wVh5WbowzOTOMAAY22gKKaqP94Q/nRwP4haKrkeOFmYGQh1MLCjCuvlbNqot6D5AMFXDZ6OE34wsB3oNttvi8IX1AVSLZc/9DXX1iRH2Uy2dBFUIHvTjOHOSP7g/C/fv07CPvJa1VhyWMJZuw4d/4I5zDBN3j559JzLhHH8GnAgxkD3hVBY5FMKjQL/U/AG5QmxpkQcMWg1qaar9oKWI38Qehf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yEFppOXSrcHxXAlFt6mZh5ZPg45CUNUmN+bJDHnf1e5AoA6xviih8EnI+yCRwsE2GoPZDeJSzui4JTbww536gO2HJaCIbLLSBie6x6U8O694Bk9HjZAgYiEpEVKJ1RiNsNiFufZDBaTWGSN/I/Zl/wZL1qQ4t3Px3PKSwUEWJYr/2lwzeDojZKd8AR6/KOzcjPI/fO+7zr6vbuLbf5RZuL8r0nRj01wa6VgS+o95SahSZCTHqtUoobqxsLRZjhg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bc47b5f-039d-45d9-6bc9-08d99fc608fc X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:15.4236 (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: sVBhu+fJ3ntCKVVC5gdYJP4Carxo67Ld37rQOWm0JEtKjBAi8SvEeNd4l6GnLfltwwi4NakVmuklTsN3Jpy+vAXyTnWD1In9/W+vqw/1wN8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: PoLMfNpGpOw93DNi12C74yfHta9P3-p1 X-Proofpoint-GUID: PoLMfNpGpOw93DNi12C74yfHta9P3-p1 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org 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 | 149 ++++++++++++++++++++++++++++--- drivers/vhost/vhost.h | 4 +- include/uapi/linux/vhost.h | 22 +++++ include/uapi/linux/vhost_types.h | 15 ++++ 4 files changed, 178 insertions(+), 12 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 04f43a6445e1..20bf67a846f1 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -493,7 +493,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; @@ -503,6 +502,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) { @@ -576,31 +576,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 @@ -613,14 +641,88 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) worker->task = task; kernel_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) { @@ -640,8 +742,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); @@ -650,7 +754,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: @@ -742,7 +846,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); @@ -1612,6 +1716,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; @@ -1719,7 +1824,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; } @@ -1772,6 +1886,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; @@ -1832,6 +1947,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 33c63b24187a..b3786e3537f1 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 Thu Nov 4 19:05:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12603701 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1868C43219 for ; Thu, 4 Nov 2021 19:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9261161157 for ; Thu, 4 Nov 2021 19:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234027AbhKDTIT (ORCPT ); Thu, 4 Nov 2021 15:08:19 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13916 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbhKDTIF (ORCPT ); Thu, 4 Nov 2021 15:08:05 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1A4IKgC8007651; Thu, 4 Nov 2021 19:05:24 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=uhy0eaVXtQ5BTjjbq3SmuQky/hU3/yMsNKzsIBCGH+U=; b=Z5Fy3yfctuW+pkvmubwPwygxIJFtgl/E8qjxkerz7kKLZzmpFpV7AS7OZTClhkwJY+zI Nmccha0bd8MHUd+qsaYzZ85DYfyS2xMTVEEEQD0gHtQMRNUiq7WqbdWdB3HUl3kE+wzt hQhzOLmerlYDvcmTqJG8hhETEcXVaCQT3jhN1TZR1+DSD5mASCOJRAtis2T4bMpFhERd upSvHxrCsmCJl9RiOl0McqjJZahECN5ZxjdBxl5PAw5PMD2+GUBP+p2LnV62K3L4IIxX mMVejdYECrj1/fT4VPHWYZSLG0Q0vRMWRgv6le8oVj7kXt/Xk+9v0SHaeq+qiugFtKTp GA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3mt5jjnf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1A4J18Pk042493; Thu, 4 Nov 2021 19:05:22 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by userp3030.oracle.com with ESMTP id 3c27k94tnm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Nov 2021 19:05:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GHF1qUpk14hJ69p7GUvqX2f0uWiTB9O+eew7ZCYthft2pXv4PKiCciBjMq6cA7gUxgLStqLMIP7kGQbD/3kz/0MB3sBfEMYhx0YxZDGzP+AVX111F3VqHIER9LouH0pRUNc8K6oEyTbaiKvczkkoyDF/99eo+PLx/LHNQq8a+oK32DsJWuHta5Jqe46PC8rl6JnS1DCkU9w5FtcZ+o/yMF6qUK7VLg86+ftfhsn1Uh61xCTyk2QUQ/ntqT3g/8XQXHDSTx/ZXFfTQG3Z3R1xoD1SQD6KgVz6PIuPHH+7FV1lmXHMFHk1wVDhhNFptmuP5PKHbV5+Z2q5TfLJOucEXQ== 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=uhy0eaVXtQ5BTjjbq3SmuQky/hU3/yMsNKzsIBCGH+U=; b=hyFLn138I+UyYN7iUJVm3oSEaEt/AGGiBWnyKAhbhDLeGUu94jQKmbM++OTeJS5437WYDPynPWQoR8JxAuSJI691LMjeXorGVVD1fKA5H71jFQPQwCNbJOP7r9z5k86riFJ6qpISVanWlFcrMVzJZ4VX7QRJPTCn7h7JwBL4hU/JKvAFKlvBEQEPjtZByIpRpOKsXCDRih4q5lDB60IvI7IuFMR4o/f1gOV8tpFMwGpDLa5qKU+06e/udQovO9kPFe4HNIk8m/H2rjRybKfPCDKmk0fvJBqdTwh9Y4otQ6s7c7OijhLsFD5ntI072mWmzvogezKvcP9Ue+qG2A/fmA== 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=uhy0eaVXtQ5BTjjbq3SmuQky/hU3/yMsNKzsIBCGH+U=; b=SullmOThPhPJkA4QEf2dxpjkdfZfRWsrDhssN8mmesoIqV3+Ixal+JZ3YRo4ybgR9eqfPXI/66RR3UaWOeFn1g52dkjMpjelQ7C0pgAHOqFEzR8Iux7GuCV2dyKbEIs76ZF2zM+HlvEvtuITZL9KJYPWTcL3oiDht5hvuP2owm8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB2873.namprd10.prod.outlook.com (2603:10b6:5:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Thu, 4 Nov 2021 19:05:16 +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.4669.011; Thu, 4 Nov 2021 19:05:16 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH V4 12/12] vhost: allow worker attachment after initial setup Date: Thu, 4 Nov 2021 14:05:02 -0500 Message-Id: <20211104190502.7053-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104190502.7053-1-michael.christie@oracle.com> References: <20211104190502.7053-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR07CA0080.namprd07.prod.outlook.com (2603:10b6:4:ad::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 19:05:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ea4edfb-1fc9-40b7-ef6d-08d99fc60945 X-MS-TrafficTypeDiagnostic: DM6PR10MB2873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 55xXuw+T/WD+pjxsiIItlMC0k7i9uwnDXZ3N8wL6xwdFHriK7Ezusd7MjaCcU0qWVB81wteWZlse5zhlvVavP7ATPt3ry1TqwGmhGg2Hpt8WuQRgAL7tUMRYfMe708wq56jOHS6KFTjA7XsWt9aSRR/NIQ2Yr614R6KWictCA76IyZfVq+e36AieKDMZOluaG2eulT1lmhNJTK0mJqq6eoSYDQRVnZKu8Pm9lPXgl4/TAJLGTvbG8J7HVUx7k2ppZY3mNGAKtqyrGdx/dG9jYmjLaYX5HgXuEQ14yIrU9oqpgyxrJL8eyNwlhJT7wGpYJmvuVd0Svd0BHBH0x+jmFiIhKltS2Zcl7D+RSUHd7NWFMfO2MUtjLxgkvdKIZy41A0AOI1/5PpEsODWDR01a4aWWs4JolfS46pRncSOM2+aS5AlmvKvy0nXP8m2E31Ld0Ceg/TlXW9G6z1KC0UdZ16oT/3duL/WTz6OtwYnKJhxFi0hdWigKloXkptprTI7OyG0USKUQXSby7x44JdAeCzn8Mg11Y7gBaj3ZCupunzco0v2DJEkoqxNLQasmkfxrfHshXpvHwN4x72/EM+n0bKnCvFK/woKVMsQ+bKcl73R+CIjm82hf6ZlwWkk6ZVUNytgzc2zhke9Fv8gtA2ZW79PQ+QNsefCbv7kcGGyB32XfrKNNCOy0/Y4ChoF96e50mGagxzX+s6Sa9yv+Wo5SaQ== 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)(5660300002)(8676002)(52116002)(6512007)(66556008)(66476007)(6506007)(26005)(66946007)(38100700002)(38350700002)(4326008)(186003)(36756003)(1076003)(86362001)(8936002)(83380400001)(6666004)(316002)(508600001)(956004)(6486002)(2616005)(2906002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UxFerOYzWQugyyDVTEHDnZC0fXHj1oTrTEHyeaq5sDriCE5u9wiAL2+ykdPT/zqvFXTWVkra3k2LFpjjXkNwLTt7EndFhahIHdIUW8w/u7KTmIy98212P0TTmS9hGXZNUx6JJ0MjucJeTieUF1KZcl5WHcqeg5ElbsgV8zD4o57e0wmf7e8Se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ZSLDGDpE4sSaCqZGAQC4mFZ8bICaOg6718tHiriPKThmo6Azg+i5R+ao3gzQ5J1Pg1pYWEq/hlRiTmndFpxWAblftGAKPO82tATo1ZUnNX6BzITfiItb62I/pba2VjqIPsQ4nTkATKR8/TKLVanF5AXGnTQf1kXaElv9z2ZydcllAHnN7eDItsPFSav4ogs4CajUzz61iojRJk2jlNc/QHZzhYQENkKDhAYkDwOW6oXMiHCAaOJ7ByVlFZVcQO6i59+JUxxMn7p63n1jhGwAPNZob4HE7rMed3buRtq2FUrrhD4tQfYmyZjdUzERNKskeuO/ANtrrGf1ztMUQhY9ej3iEzQXNuWTl2mC3fTJJ/lbQPVYw3S2UwbUtl3NvvUCJn3wHNbhbCuN8J1pIYT9r+ril1Epn5jGhAF9LPvFgXq+eaQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ea4edfb-1fc9-40b7-ef6d-08d99fc60945 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 19:05:15.9893 (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: dg9dHjVdl72hqmM7mi84QYXKUNqTtZX8PZ8LUiuxpTqPDvEU8wf/yfnSqUHMEOdMX1rTBREews3h4Zhx731R96fka4zpZbRCnrgJyFMacWU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2873 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111040076 X-Proofpoint-ORIG-GUID: cKBByJNOqo_YbGIxgTBe_aOh8xTGpECz X-Proofpoint-GUID: cKBByJNOqo_YbGIxgTBe_aOh8xTGpECz 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 | 102 +++++++++++++++++++++++++------------ drivers/vhost/vhost.h | 2 +- include/uapi/linux/vhost.h | 2 +- 3 files changed, 71 insertions(+), 35 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 20bf67a846f1..f47710a77853 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,31 +245,45 @@ static void vhost_work_queue_on(struct vhost_worker *worker, } } -static void vhost_work_flush_on(struct vhost_worker *worker) +void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) { - struct vhost_flush_struct flush; + struct vhost_worker *worker; - if (!worker) - return; + 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); - init_completion(&flush.wait_event); - vhost_work_init(&flush.work, vhost_flush_work); +static void vhost_worker_flush_queue(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); - wait_for_completion(&flush.wait_event); + vhost_worker_work_queue(worker, &flush->work); } void vhost_vq_work_flush(struct vhost_virtqueue *vq) { - vhost_work_flush_on(vq->worker); -} -EXPORT_SYMBOL_GPL(vhost_vq_work_flush); + struct vhost_flush_struct flush; + struct vhost_worker *worker; -void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) -{ - vhost_work_queue_on(vq->worker, work); + rcu_read_lock(); + worker = rcu_dereference(vq->worker); + if (!worker) { + rcu_read_unlock(); + return; + } + + vhost_worker_flush_queue(worker, &flush); + rcu_read_unlock(); + + wait_for_completion(&flush.wait_event); } -EXPORT_SYMBOL_GPL(vhost_vq_work_queue); +EXPORT_SYMBOL_GPL(vhost_vq_work_flush); /* Flush any work that has been scheduled. When calling this, don't hold any * locks that are also used by the callback. */ @@ -285,7 +296,16 @@ EXPORT_SYMBOL_GPL(vhost_poll_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); @@ -510,7 +530,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); @@ -590,11 +610,32 @@ 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_flush_struct flush_work; + 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. + */ + synchronize_rcu(); + + vhost_worker_flush_queue(old_worker, &flush_work); + wait_for_completion(&flush_work.wait_event); + } + + vhost_worker_put(vq->dev, old_worker); } static int vhost_workers_idr_iter(int id, void *worker, void *dev) @@ -611,7 +652,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); } @@ -667,18 +708,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; } diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index b3786e3537f1..607e95887942 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)