From patchwork Fri Oct 22 05:19: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: 12576995 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 0E265C4332F for ; Fri, 22 Oct 2021 05:19:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8E6D60EE2 for ; Fri, 22 Oct 2021 05:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbhJVFVt (ORCPT ); Fri, 22 Oct 2021 01:21:49 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:35414 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbhJVFVs (ORCPT ); Fri, 22 Oct 2021 01:21:48 -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 19M3R0C3010002; Fri, 22 Oct 2021 05:19:27 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=i1K9Q+8wKKbVXZVifF2EhDXzLFqt2vHRHXa5/AqZccg=; b=NEFKk8RdkvtlwtuIOsAx6dXVkP6ll5DK4Gw7p9w5Qk83B3Jr25B2C9BLfMg1scVliRCm OFvc7S67lIuBQTGbE6KmQtMbHuVqpzHMMsHdkwtHfaAMG+3yVmTg0FFkPtZvjFawa5Dh Pwvf+H7aI4TxSuZBXBtGyK1KHlBvpr2R1e7oAJPeA9TmYAgExPRLiO5gzkQX08ZPnizZ I1Zi3Q7d6VF0cZr8tfbH5Vl+DPG4serifbQguSzsTKKex5vlVpp5X8wXZjU8T2IMDe+F Kr41RMDn1LBqiGLiFkxY5wMTxd+Hu2hsaC3mZB3koc6t+C2acqJm6TK44sPYFLxwqqXC TQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bundfg9e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:26 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIZ139141; Fri, 22 Oct 2021 05:19:25 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WwdsViYEWmjSq/cTyfxZ01l84azbV/9HElzS5Bvg8m33/loGSkDx1o3H4IqIW4u4uwM0MncVvYvkT+2IfGEhiVvU8Mkp5y6SSZO494EM1xks7B75sJe8fi/yO00UMr64mI3YcvHZAUPBdeWmmpbuXmbGg8v/2raU4Q9eWivmtyeRRH2bhPrq5/AZkTTc4pn8Yk1F8gH2VTy56G3TkqAssy32J9sqPwt3bq5SyJoEHzkldyBvs392cgZUnDJhojjzg9GiqtwlO8tpZOkpTEd1lo2UogplWJVMNtxW5UBatNgn/LZTsr5MnKJrRV5rj25+KEf9juilR/k7lJNNqnHgdA== 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=i1K9Q+8wKKbVXZVifF2EhDXzLFqt2vHRHXa5/AqZccg=; b=NNyqWFFOPKnkGF914Di3bXdY1141JScO+L0bgFppncE7VXNCeMGP+hRxTqtgTCoMKjuD0ojI8Ut7fwzeWDmDpzgxydG87K0QRkewZaNkONxAlNXs2CkK+iih7yoHO5G1CBg25vTHEUlFumFJTFiSR3+zf++ZOwSDWFzQqC+OMHRJPdSIi8hT8v+Mi7NAi+xMo5xStTi+0WbCCLNaA7jjwnZJXpVpvB3fAm2Pcsv7qYwuhwwV8wwRzwS888DgfXOMCeCIEmGg2fXSxbf6NaTUEFXdRLefaXL4w8YpeCVM40J9G5/ecqRoBXGOzw5eny7TnFDF8KSxwOSuAzxGcRudhg== 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=i1K9Q+8wKKbVXZVifF2EhDXzLFqt2vHRHXa5/AqZccg=; b=IPOfpeZ5vrvXKhERB9j3VKwNTSyswAEU9kc4YsjKbZtGhinaBsXQv+9kiinvBx8h35zWxOmLfWZXEOzL3/TKHTP+l46CEEzvfD8bZN4QfQ3RmAmG8oc79KeHjFlKcDF1w8qEuZzUzOlvFgd83ZJe1fOqUmOq6jRBIJx09n8oFvM= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:23 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:23 +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] QEMU vhost-scsi: add support for VHOST_SET_VRING_WORKER Date: Fri, 22 Oct 2021 00:19:00 -0500 Message-Id: <20211022051911.108383-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f999dce5-700c-476b-17d5-08d9951b828c X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:272; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e4+JtirSTEzlVcppqHHNGT61le4K0OJkBsstbjyoEkvPoXHXg1SDNLvT026NMi97h6wTy23qZgCVEhJxsBYfxCqDFbWl//5LEJmDdiI/W8s1hh+42B5bLLCilt93NxeSlPtERYV0VBgLW5Ij71sHNt2kHebvbrWxM6LxZdmRIfAE0zZa4PF0YHA2pc2YNhnh7UsFpwpwwvf1ovkCaHHBZaLgSh03nE83is9AMTN9ZgdWSYisu42UHZXD8vuAn9XYZqIQmkbrJfe+wEw5icZ6JOjG1Melde6MMOl1Cc0jt09wAfVo+LfprwC4prgMH/FC38Z1O1LrZteNm9ZP/f03HoqW72Iy4gkjh92/qZukEY04A2grFsxguXDuylkBeg4ElPDvyMIWP9o52QqlcSogUgihkhVbA0RXE6AJs8iRBhDfY4Y2mvnYL0QWDIY/o27Gb8f+hyKWGjM4L3QoL0+pRIY7jwGKeNz6rEe4aN/4d8QdyTfLU+wRRJGoafPcDn2W8dzZ98xIEgmbCyapeGvmPIRyIoP2ax3llLbOx2yGMMNx+t0bCdiJeYXpfKygaof+Ynf6v+zFpN3TECjzvLuTxByOxlQ5Qi9XBTdhVnfpd44IGAhqxJTiMTZ4JcP1VdpE+9yo5nVQzlSC1PAMMXMDPdJ8jBYcayPk3Wb2DndjzwKvNB2jffUnfj11bnid2Sl04HVJrTP5nP4wshEBXAWLPg== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gi25lf6PCgs9d3n649q8QM7/a/Grn3NtbLmSKG3cir4n5dg1sjWbFAp8qKo8WRWlUbnh9pv+XrRPmOzVZmqQQ+n7wetEchUden7ffGvBS+BBR1wHwD8w+L85A6DTxqzi0/qwshnA8yh/ZO/bukwLMqxbsZV5ZZ9PEuRhocsDGrvVU5upRVHxHjHqLaHvnO+C2K64ASMZSPRUm/iFNK5o5veAPCo6rSSAf7e9aFPbX+wMb8slWUyT1cXj0NM0Z0AEOQe2ls/iJLLwUYGgGEmWFzZcjSKRVOSCBFt/5CJXuAHZPtqCcWxiKhKZ2cmBVyyWZ5Roxnus7HQ57VhRZg3aNdH9m2bGWB9afqeS2h89YPLOgcPG6+2nI1iNQdM00JpYoWZHkRQe4Lehan7YrAPFdqaSEZDqLnhe8rxYUk5iAYPgg846q1cmYw4MqX3dJ2Rchkk5GNXInSkRaPDaRhG2Et1EmKsi5fyjKdHKAeX4BVy79WHs1VaCIAU+n23N968AgFYa/kpmgatesOc6B/yNKZBJ16ZPX7GeqrvwbMljIrnde9i+Ens3mLUPP+hgiCFIyc3FC5PuGR+Hw+knd1WC3WywmjfUuTSUkObxMNGu7DxrPrbaE/HeRQq1joBn1qBi172wgnrE1KP/0hdXZfR4ekJ4hhQ4qTrqYfweRRwZ47R8mcoKswPS7eAyZasA8/5YRXuXKad3ze5AYaz3sfKqGBtYu1dnCcLTp1OEm9UVYDoCqVx28M5/WcRMT7JQGGDiLGherBFHe8pDAx0EeU+BICH2pJaKYz0H97KXm/X4eWXdA/+MztvTvkvf2NU8b3tOLM1ehddJP8QFH4veazRu8jLfbZ7UpuJsxF2HA48iouqHfDQb2jAqNqcPzXbpY0BhUEm9VDk1rgBpHbvBXAkNQ/v9VdrWKqD7jFKB02Mo1XltI+C5KKicZ3oSnXBbKncae0E5cjEpHedHR4roniKoYub8yHF3TTx8uQb/xDXXSMUW+QQX+LSzUKrRq7pg4s8YBkG34uRtXnlnyWyvUKulrIUeUpRPtmlviy8Fmy2fjX42+Fm29sjDlTeCGLyQfBQvWj6UUC0lTb5pFyXRR9yhwH4rhk5sgiBrpBBAjXWNo1nn/0xKIi42v3iUkG0fyjC79F3JPZgCmkNuk2bsRIe7uxoj7V96PEHbJ617V3IcEgVzpRhhymDTqybN1ldr3dPHCMtV4fXyb2ZVsPvlG5Dsj1T9xbYX8RqzzLsQgHomwV7e9oPrpQN1OgT9+1ry0sqzjS6oMByfrcio1IPqxFS/9Lipr8o7NXjaJJGPQB2vWFFASeB9oHe9Lq1B2DCHMfNPQggfLrrXI5D4td05rbbRaRZGduWF545dnJ1tH6E+sR8OFUyCR5pUzAh0Y+WRN+iwB5EKjDDs8EnviMNXKY1D7srg1UXQsOoVBI5tACvffufzO7Eqf309jwPOl3fOIsyj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f999dce5-700c-476b-17d5-08d9951b828c X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:23.8189 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: HQT-aRGQerP9O0ct6PDlxYNb7ijAfH92 X-Proofpoint-GUID: HQT-aRGQerP9O0ct6PDlxYNb7ijAfH92 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch adds support for the proposed ioctl that allows userspace to create virtqueue workers. For vhost-scsi you can set virtqueue_workers to: 0: default behavior where we have 1 worker for all vqs. -1: create a worker per vq. >0: create N workers and allow the vqs to share them. TODO: - Better support for sharing workers where we bind based on ISR to vq mapping. Signed-off-by: Mike Christie --- hw/scsi/vhost-scsi.c | 65 ++++++++++++++++++++ hw/virtio/vhost-backend.c | 8 +++ include/hw/virtio/vhost-backend.h | 4 ++ include/hw/virtio/virtio-scsi.h | 1 + include/standard-headers/linux/vhost_types.h | 12 ++++ linux-headers/linux/vhost.h | 11 ++++ 6 files changed, 101 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 039caf2614eb..74363f9a519e 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -163,6 +163,62 @@ static const VMStateDescription vmstate_virtio_vhost_scsi = { .pre_save = vhost_scsi_pre_save, }; +static int vhost_scsi_set_workers(VHostSCSICommon *vsc, int vq_workers) +{ + struct vhost_dev *dev = &vsc->dev; + int workers_per_queue = 1, io_queues; + struct vhost_vring_worker w; + int i, ret, cnt = 0; + + if (vq_workers < VHOST_VRING_NEW_WORKER) + return -EINVAL; + + if (vq_workers == 0 || + dev->nvqs == VHOST_SCSI_VQ_NUM_FIXED + 1) + /* Use the single default worker */ + return 0; + + io_queues = dev->nvqs - VHOST_SCSI_VQ_NUM_FIXED; + if (vq_workers > 0 && io_queues > vq_workers) + workers_per_queue = io_queues / vq_workers; + + w.pid = VHOST_VRING_NEW_WORKER; + /* + * ctl/evt share the first worker since it will be rare for them + * to send cmds while IO is running. The rest of the vqs get their + * own worker. + */ + for (i = VHOST_SCSI_VQ_NUM_FIXED + 1; i < dev->nvqs; i++) { + w.index = i; + + switch (vq_workers) { + case VHOST_VRING_NEW_WORKER: + w.pid = VHOST_VRING_NEW_WORKER; + break; + default: + /* + * TODO: we should get the ISR to vq mapping and bind workers + * so vqs sharing a ISR share a worker. + */ + if (cnt == workers_per_queue) { + w.pid = VHOST_VRING_NEW_WORKER; + cnt = 0; + } else { + cnt++; + } + } + + ret = dev->vhost_ops->vhost_set_vring_worker(dev, &w); + if (ret == -ENOTTY) { + ret = 0; + break; + } else if (ret) + break; + } + + return ret; +} + static void vhost_scsi_realize(DeviceState *dev, Error **errp) { VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); @@ -223,6 +279,13 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) goto free_vqs; } + ret = vhost_scsi_set_workers(vsc, vs->conf.virtqueue_workers); + if (ret < 0) { + error_setg(errp, "vhost-scsi: vhost worker setup failed: %s", + strerror(-ret)); + goto free_vqs; + } + /* At present, channel and lun both are 0 for bootable vhost-scsi disk */ vsc->channel = 0; vsc->lun = 0; @@ -281,6 +344,8 @@ static Property vhost_scsi_properties[] = { VIRTIO_SCSI_F_T10_PI, false), DEFINE_PROP_BOOL("migratable", VHostSCSICommon, migratable, false), + DEFINE_PROP_INT32("virtqueue_workers", VirtIOSCSICommon, + conf.virtqueue_workers, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index b65f8f7e97bf..175ed1f1c3a8 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -152,6 +152,13 @@ static int vhost_kernel_set_vring_busyloop_timeout(struct vhost_dev *dev, return vhost_kernel_call(dev, VHOST_SET_VRING_BUSYLOOP_TIMEOUT, s); } +static int vhost_kernel_set_vring_worker(struct vhost_dev *dev, + struct vhost_vring_worker *worker) +{ + return vhost_kernel_call(dev, VHOST_SET_VRING_WORKER, worker); +} + + static int vhost_kernel_set_features(struct vhost_dev *dev, uint64_t features) { @@ -313,6 +320,7 @@ const VhostOps kernel_ops = { .vhost_set_vring_call = vhost_kernel_set_vring_call, .vhost_set_vring_busyloop_timeout = vhost_kernel_set_vring_busyloop_timeout, + .vhost_set_vring_worker = vhost_kernel_set_vring_worker, .vhost_set_features = vhost_kernel_set_features, .vhost_get_features = vhost_kernel_get_features, .vhost_set_backend_cap = vhost_kernel_set_backend_cap, diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 81bf3109f837..bede35cf4686 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -33,6 +33,7 @@ struct vhost_memory; struct vhost_vring_file; struct vhost_vring_state; struct vhost_vring_addr; +struct vhost_vring_worker; struct vhost_scsi_target; struct vhost_iotlb_msg; struct vhost_virtqueue; @@ -71,6 +72,8 @@ typedef int (*vhost_set_vring_call_op)(struct vhost_dev *dev, struct vhost_vring_file *file); typedef int (*vhost_set_vring_busyloop_timeout_op)(struct vhost_dev *dev, struct vhost_vring_state *r); +typedef int (*vhost_set_vring_worker_op)(struct vhost_dev *dev, + struct vhost_vring_worker *worker); typedef int (*vhost_set_features_op)(struct vhost_dev *dev, uint64_t features); typedef int (*vhost_get_features_op)(struct vhost_dev *dev, @@ -146,6 +149,7 @@ typedef struct VhostOps { vhost_set_vring_kick_op vhost_set_vring_kick; vhost_set_vring_call_op vhost_set_vring_call; vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout; + vhost_set_vring_worker_op vhost_set_vring_worker; vhost_set_features_op vhost_set_features; vhost_get_features_op vhost_get_features; vhost_set_backend_cap_op vhost_set_backend_cap; diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index 543681bc1838..694221601dad 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -58,6 +58,7 @@ struct VirtIOSCSIConf { #ifdef CONFIG_VHOST_SCSI char *vhostfd; char *wwpn; + int virtqueue_workers; #endif CharBackend chardev; uint32_t boot_tpgt; diff --git a/include/standard-headers/linux/vhost_types.h b/include/standard-headers/linux/vhost_types.h index 0bd2684a2ae4..0b844969a524 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -27,6 +27,18 @@ struct vhost_vring_file { }; +#define VHOST_VRING_NEW_WORKER -1 + +struct vhost_vring_worker { + unsigned int index; + /* + * The pid of the vhost worker that the vq will be bound to. If + * pid is VHOST_VRING_NEW_WORKER a new worker will be created and it's + * pid will be returned in pid. + */ + pid_t pid; +}; + struct vhost_vring_addr { unsigned int index; /* Option flags. */ diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index c998860d7bbc..6823f3b5309c 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -70,6 +70,17 @@ #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) +/* By default, a device gets one vhost_worker created during VHOST_SET_OWNER + * that its virtqueues share. This allows userspace to create a vhost_worker + * and bind a virtqueue to it or bind a virtqueue to an existing worker. + * + * If pid > 0 and it matches an existing vhost_worker thread it will be bound + * to the virtqueue. If pid is VHOST_VRING_NEW_WORKER, then a new worker will be + * created and bound to the virtqueue. + * + * This must be called after VHOST_SET_OWNER and before the virtqueue is active. + */ +#define VHOST_SET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x15, struct vhost_vring_worker) /* The following ioctls use eventfd file descriptors to signal and poll * for events. */ From patchwork Fri Oct 22 05:19: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: 12577001 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 0523BC433FE for ; Fri, 22 Oct 2021 05:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E76A76124D for ; Fri, 22 Oct 2021 05:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbhJVFVy (ORCPT ); Fri, 22 Oct 2021 01:21:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:49190 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhJVFVt (ORCPT ); Fri, 22 Oct 2021 01:21:49 -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 19M2kco5016504; Fri, 22 Oct 2021 05:19:28 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=KpQ77JjLg75kBKI3jdxp5Qjzn2ANH4HFPLU6cZpl5QO8qrwgZgm5N8yDuIo60LOCmKQ9 v8VcX7lOnTiMoQd1J/Vr2YXUFeRkeNAkGNq6NzI/QrQrzcoWSp94UKek7hn2odUshxa1 VT5HvXF3gj/h3MQ+MUlYkezsKSqjBEfItsAzgOWyuypgBBqq2QBbVwuNKKJP7Gb8tQdx R3acMd0w8x5LmCCOshFV3fiKnZnOnOv5mUjRJjA3oJRTQzl7Dp4maL4ycurkrVqWtgXf b3Fa01CeAgU6/FytNJf3iHIEZdiyXA1RsvBHBwyt94Q1BEgEkniJK+AoHJ4rqsmn4fje qg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btrfm8sxq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:27 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIb139141; Fri, 22 Oct 2021 05:19:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ItZV62dg3/h/nKZR1tnYb/8KbQ1grL9b/6dLdNKsDQzB+OkPIboSeQLkS5evRh/DyRwhfmtjsOzQDolElLEj7OwD+pVpBGRT1pWU9GuJiGkx1blo/sUQaHZGIvESU5tT2cEmVxuIoygrrsMyp+JgZaEcD+sa6bteHnM31v47VEIG4Z3QrQ5xIZDd47g4zw1X2oDktxqj6wNyPZb1EMMP3M5q9mW6AjlMu/RTLEjJKlQ4oiZ8gTtpK1oEnvn9BnjE1hmUa7ea6VDCOLEjgZUFDwK8h5UNNQU94xokcLtWIcDTrhBTp3wyI2fmgBRqVumz0A2ttMocaRquPbR9VPgpgw== 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=Wu7XxHwStinvEKpvKspc9DbZ6yW3P+1tAEnU0XuufHCZrR1tyYuSQgL9d5MLQ+gV4lr+PTYoIiE2a6i1np3SGCB52OeVAhJ1nq2e5Df4lqP2UVbrT99h97uEx63I/Q/MYi1hAxjQJGOMT+9ymZcfl+fV/9en9vLAQx03RqaZxIuESqz4d5ysvGcKT0yewgV9T6Z5WFosSWqGWn++xbhrKL/UEWsavuWvuoJWqyjwie8Y/1J9m/9VqRVA7fnZdM7jClSjHJQ/ALj/qfM/w+GSLD2M3+NOjmQNsEvzDdSZki25bdNg+67T54RZZZOmiYRFYnv6BslDFb6s60mn9CwkHA== 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=dsAIvIxVFaAGVRsKlXmN92lnLmTok91OTKedHvnWtZixZG8yg5C0GJFvuus5huEX62wX47vCJxUnG1hzbDS/EU0CF1cS+UEYfR0L1h+xadU+rgbxCoYOi6Ip/glP9+mG0brENqMOLlug/nC8bZoZNUD9pyLfVs4FyDDtCmdurzc= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:25 +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 V3 02/11] vhost, vhost-net: add helper to check if vq has work Date: Fri, 22 Oct 2021 00:19:02 -0500 Message-Id: <20211022051911.108383-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 335476a4-3d00-409f-81e0-08d9951b8339 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: TZRieUwQCwlbyyfhwwvG9RdJKJ2AP8ouwF046xHq++iboOcFiU3Nk/ir75mYwzTFNuVJCh8g83ABF/g/r1l6Lwxi7zvKcPSieHGGLx7wyDLaLznxF/tW50M+eergZbic3gBLE0F72HmbEl/pPKyRO1MGkaiWZI1K2RwPCJMoWPUL6j5hCe4PEkeT4Fha/bnmy6nCgkvL7w18fbezE4dhUnjaGhi0HOOUBFdLrw5hCsiwGj/PrLG8bL5Ta8b+w3hgDEwxYzNkxrsiZyEdVbjrp9M7M+8DY4tMglsswjveVsA2zFQIpuDQh69NT8sb7Mu0pdaUS209HpQhiVilOYgY1sh0QRZnNGYCXlDUffq7GZoqzJ4XD2LQBmmhDFJs1FblmfPGsaGJfgToNDUhnV1o6702UkW16w94507DygcjPHGsihIs340X84x6V0XoJeIJdVwsWhezZEokDAQNr98N7vz6RJqHgIJZcAQEehpcdsvx3OFL2I4XhwOPuPtYxao730BB1wR/+gLuttnKAJQzQ6VMC6FrplvqjhSuBv+kcADe8XiOv/81kVOWQ30oigGcmKsSmmP5fxH73RmHmxYoLdf8cm7XQJxyB2hv6YxjgTJ8d8UBVSksssDgnkdHr8+tFtoekv4sERbU+Mblt4QIX7/GePN3I98Eb2+hQQaQSlLnJiiB76ew2UVt05r90Z+pWX8aRR0p0GvKIiNPGdPX7w== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VSWXu+HpRuPX7ZG62Gd80PaoXA4j2+AKEvh36V5KjNk95M0Xb1v8sb+7CxaXftMZlMh1pa5fry2YjyE+UPEdH95UKzGmuwLjnqX+bvAkP7/SLmL84IFBi6oruqcDXG8cMxoUVPT59kpHZKW0UY/yt7SnHGDxghT9O7I4b5ur2Qfbu8dLAjGEnkG4EUNhFTl2XRkNN4JDt1DV/yLeVGpOsISwoqWCK22knxXEhWRpfsgoupecPvFynUdgL1bSoujK0x5RLkLdxQ+iw/IeuOk8rHnB2rcOJTm7d75XsrpdmOdnXJhh4er/7FasYrp5s6iwc0ZJ3WaGex/+Yd5ovDVichysU+f9a+73WbxxnSGFkYOvYnt+LtshH10Zpwp2LoFAeD3xQFxPyVwHXEawgaEZHvwmOE9PqN2AcLZfEtdlnp+hPI4f4NeRxi97zOOQcRKMEx233F2Zw8dpkG8Cc426fFlYmB1qGhF2Xhwtc0w9UGTByFYWwCcKAcYHgrqJ5oxysTEF3ALPo0iE9jT5TR8dJ72FT7PCNzNbMQISb2928GFLhUXKIXVUj9e0b4USHSo1H+05+yHXpbCjJboXjspIVbXylTHaW3zC98IghdxK6LUz8P3tvbiLBj56a0eeaxOpah4ulkGNkGu7ltza4MBeKt8rpdlT5wJnwU3ySBVgFYB+HNV0cCRM24w2OAtg/xjrGASv2VLmRpoMEyBCkwDbYSQ1jxjO++mmHTofwzHBuxxs5t/HYnrfvycI/4yaDGdfmj7uQzkxlUHGq685vyZd6ppJnorWrZq+twq236MBZJvp6EOfI1Zj8KmDQvul4VQzE+vzhir4qNn293v3JG4nLlkw6i+D9iiU9WUaZBxbOTv41cSYBmoNUGY2xqmqgw6jITefZ1lMAcJrB5KQ6DIz0Lkw9sqz2MVAeOktl1crvI6sunmZF9/HaJSZXzks1o17+v9JSr41zNZiP9RRQ+ubq0eEY+lGUijbnU7b+j3dmL4Yzut4gzXMa1/C2rZ4myNVMFp+3GT12nmD7agllbvs3Hf1965H5wgmPb9OsuPq0cDX9+EQvkqGUCMVYRUL3sDS46cmoqIhsX4e5XmOKMCff4WIhV6RMIOk2F83i/XHKoGMXzorFEtBvtCBT0MXxi6WWLKQaqCziNCj/xNW/3ukmVy+RueLu63svjGuS9qVlC/sxD1D7+HkkzyHebGe7r+MTDbOOYag9JdrozpM+OUdc1RR30ZarTQqZpfDuUyIWcU/DnslW+3KfMnrhF3gdEegLyBcovEv8KV7imeBdF75vYsdwc5P3VSB1/DurSd+BesUXZ/vebN971epTM1NA7EQ1uw70e5LM7cXt4rnLiH0TfBKnsYHqsJqRQZ88Mxdi2ZD1BaUqsBZLh5JkVPIWqNIbviuNhUIjJvClkMKLy/R+USxItB7nQNR5lReK+UTnaAS5Xgtb8ytZUiAf9OMICHU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 335476a4-3d00-409f-81e0-08d9951b8339 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:24.9894 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-GUID: Mqi6BlBXwjFTfGaNiDtVeuUKBN_hbyN6 X-Proofpoint-ORIG-GUID: Mqi6BlBXwjFTfGaNiDtVeuUKBN_hbyN6 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 Fri Oct 22 05:19:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12576999 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 9A8B3C4332F for ; Fri, 22 Oct 2021 05:19:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84E6F60EE2 for ; Fri, 22 Oct 2021 05:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbhJVFVv (ORCPT ); Fri, 22 Oct 2021 01:21:51 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:37220 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhJVFVt (ORCPT ); Fri, 22 Oct 2021 01:21:49 -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 19M3QuAN008796; Fri, 22 Oct 2021 05:19:28 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=0QrH3RxKeIE8tA+TN0M3cL02p7yfkLCne8Mak90oyiCl4xNs85w+txENCQxsSMj3dGRB qBwL4dk023QfYzFpREpcH1bwglEZjCJLGqKTFzUK8yLmme8qemSKnwHj0bD38bWKLhsh xaQ1DtbXsaermDt+lToIt6j1y/YCxvfNO2lQwNbYHivg+e/nV0rSfrBiboqceR2r8AJV d40VnCI19USAO8dEJKaENC6mWHPtzuXOygJAncKSOdkK0DkTAGcQuq0yQNza7GT4JI3a F7vyTujiBqWodz55cosHJVmomAF4eGbsAzCQStqbkPAxpeOGKI4YfMClaGYHf8gXg1wt pw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bundfg9eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIc139141; Fri, 22 Oct 2021 05:19:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TZIwmzrmcWV2LsiAU10W1JDcq3mJkhp8t/gNPtOCroRAn1gwE0pdMfM/V66AzPy7jN3kkHgtY0StrIIdSL28kjfS218lF8+uXo8jUpFW3d17j/BZBzsP6YrjKpub+cetW0qpNCNrxEoRT68wtnHZInTjEXfpoyhe2DKBG7bGR/zUD3k7isGtrbnzf4DG/R+yVbN5jsfKClA+StCLsWeb23KvLv41m9bycshgbjgPzhGoGhNj7HIzP3ZmNqDVqLtFPWsfc/ib6xvgxTP838J3Ky55xegZvX/UNPaY3MS18bNevNhbZc/glcyfQiMNQuSHV8jHFOEwsTr7L0gLHM4Rlw== 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=oav701Joxivnf480gpTgtbBjTlDhA4hdd4yddPEd800FFO0XupMq/acAlMQqDtZbUYVUnmLf2wsXN1yEGWj6/0qZ2YZSMxk6JnqjI9w3XW2gby8d1CBTjkkqfED34XmOl5DD5c0RgU3HGZ15wCZKTGNWjTdOzDPksHRq/ChLnkRiR4FYOVu14vyih9VyQj1jxFemFmMBvJRBdPJx1wvbKve3YL1+7cR1VxmOTNNcpmoeXcMUMk0bMjyxaetuOA4YAC4U45uB3I5Td3aTXFTO4oDjMRdYtIoyPJMT7ZQTxE9RUdXKwenXNASd7DOhG/YntTjZd08So+R/Ldjf05IVYg== 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=0AxkN+3MEZEkWKJEXe+6697MLpzMcASdxJkb5DxfJY/BELDZJtoY+9hGQIVlwz8H6e9oMtrOXTn/RJpxIvkbpCTV/Ie5sGlyZ1gHUnoxbivGABvk1JMQBOP1RQ4CxXK4Do7kGGK6znEWT7U2G2FilIM39MkxOPqXS8SznDb9SJA= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:25 +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 V3 03/11] vhost: take worker or vq instead of dev for queueing Date: Fri, 22 Oct 2021 00:19:03 -0500 Message-Id: <20211022051911.108383-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6740cf7-65e5-4f5e-e1cf-08d9951b839b X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: glQgvDdCjbVh/lIiuQyz2JpXW9J+Q6SGNi4CBQ9LcCwV0sUbxYokwxptPwA/iwj7v2mLynWKe9q+9TR0UOi7P/XDy1J7rZf6WI15HgMXdog5d1k8ApqRTNf6KTDW3erPZKSydXElDuFiphzMBAYrjwkPBghIT9kHmO5iHUDP9lLHEh2M9RL035bGAP4uPLD21joJ4Er2zpHo8Z15b6RxCg67/fDd/LK3llmp0k3yDtjNSGElRKGxaXDd+B8/zip1FjttOrU+qRKaAcMpV5jViHPBGq/tMbYX2VAZYH28QyI4qJnA7gmPKvWPg9dqpdw40isLhQTZrz4I/MPA4YsRgouNdHdC7hXuwk7JVB78X2icAdfiM+lJkncohrcH+mzKnzkQ++VfuKggSIgK8Vjhzz5zYlsZjZ5N4yK+/lRL449mN0wnLfmEcqR168wgXbCIM2qJkWkBuzRMQZmgyOxDLbOsStrtfQ50xbP4uk7z5au5boYOZuMxpDxEGcRntimzbS42UTjWLKMaOGr87IPU6LcgEQEF0J1/uot5WS1Bsl02GU+EKLYGvax8cS/79o8lGj3pfuIZtvWY9iqr1zvbJxePZBvdy1y8EZMqKYOlIEbQAai1Vu6xQPXFkc23C7aX5u0RUtsLcGKcGmn36ANen4onjZPUA9RIfIL9JNPBZUiGCv9mj+0lcWCv60JXfWbUFMU1wGIZhRJ9MwwF7PXssA== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DiAcV4XjbvINRxjko3PhqAiYXptlav1wMNkZ6ZVH1MMvy41JC0ULp12C/T5/VwbzcqPlazoJNF6N6oVbrvdC78JDyM9Baij17vZC6HPSsVU85Xh4xOM9ZW0WcDvxHFjQUNe2WqfYQCYvwRT6UgTuU9f6cTml7Aq8WYLguiy/nv243sMxgiAorC9UhbA2Y2eRVD1MCxZyML76Ab61HCkURglS5pWWRszpzZLDki+NO6upazZx8bigVKyri6E3PrA0ivuIIGGdvkZlAhBVOGIqanURHDm7X/1DBmxOCjbQY4+EhhpjMdDqJscikb2dNRsy8m1jGMfsH1QPC3W3CJgEhe9RedIHXaIwG7ot3T8k4zZe0QwLbNhNWFOae+7Z9zvNKqPad3eABPrOP1W8p/p2pcCmJqNpRYog5eaJKBlNjJNj5TU+p8L7MxDlN2Mx4CztytcvdXA8qqQT7Yn56CfcxawaJs+YDex0QFObf8y/+6hPnnDuR2QXmhXP6rkyLJ44Sq1yDi6XCW6a7mNxkk0whRJyteVylMnDnHbhSKvXhMaSHMLm30bYMtvu8PgaEgNkeQKz3OkZuDKe4woYb9RJdTLNyVd9D5NcvxKko32n/lQSre7X1G8B3dv0wBtf7IJib2rZKyqHnw0bQHmJSnjwtiHBwujTmuiACvwrIfgxyK86Z4uuV3dToGKoswe6L8Fm/0NKv+8BmiqfCxruislREHg/MP5H58p66sDs5AHtAYebw9Ly+mg2HfESOAZg/AWrZ2CWblq5R9gu0Y5tOGORVjWHD/Ym+sG6YaDc5xgbkT/Zx6DEl6fhFb8TYei9D9TKM58c+0bqZZQ/IAHibnOJ+eJimrDTDKsnXoI0jvtzqQN2eTRS3irAhsVWDr+e7jLvQ0nbC8QnfffSMlGC73hsFeO9AzyaBMNMSmt9mE4dw8pKv+Ayatp69bSX/xgpAWMGmX1Dj8m2kDzTB+dI+W49l3ehEzkj2HE4bcN+qXyyRxjsnIEg4FRrM8YBKeyjT22hfUYPYX478x/b09B9iG/r8U1gj+QebVr3Da9HsNqgiE2jfkbxJR+4YIMk6K/bQDoxg/JAfLFqxe2AAMHXvK2SfriczKupOjWpfxUkDT+5KVD3VvXFhbMy0L+FfgaDIFSFqBJXg2KAFtEJXxi/8cl1n3C76N2tNzuLqmBsWR71nDgIpL7q8F7B4GQkVsEbVTLj5OtZgpgzqbD+VVuc4gju5rp2YMbO/4+GuNOpQ0cudqJOSGnR02v0COB9PgHOxu7gvnDXYcX4gN4D3BTopPzAEsNBjyE9mWfIIE2aDjhXa1iL+BCD0Qre3Vkuv3fFq+lJ3WUickuad2qrGRmzA3GWHjsK9wI6DI+f6e2Fcn498ChjOAyLn0zgBlEN0nfPoc9LPoq+2UBc0m38V73RG6iYnRgr6W1gCRedJ9LfMcKxUy8/hnEiOY3DYuv8pxScv5Xr X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6740cf7-65e5-4f5e-e1cf-08d9951b839b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:25.5811 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: kwZNJUP-0EgNH715__dRMsub7vcuaZYH X-Proofpoint-GUID: kwZNJUP-0EgNH715__dRMsub7vcuaZYH 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 Fri Oct 22 05:19:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577005 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 1EEFAC4332F for ; Fri, 22 Oct 2021 05:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0288660E97 for ; Fri, 22 Oct 2021 05:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbhJVFVw (ORCPT ); Fri, 22 Oct 2021 01:21:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:50640 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhJVFVt (ORCPT ); Fri, 22 Oct 2021 01:21:49 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M2qeuH019167; Fri, 22 Oct 2021 05:19:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=D40tPvmKWcALQ529N71eSOpOGZt4d+MRa6Xymi5OU3A=; b=l9cDYPGlKSUyo8M6v2HQRbA4M80lPNbyBAypeH/vLfJPxgVk7dKvcuRPfAMfkHQCJHcW upZMVDGAktUnk0tFMNGKhJ78GMiwcv1vruUrfZqh8WlgAmlog+dHl6Ah3oPTmZvEPWnL Sl21oXb4bf0+S2TD0Tmg2LOEqKN2Gwi84oNImJ/oLPMX9/KcjQ/S3Jg5hEPTpfXN/jrJ TyDGuznyTrP6eaW44NeOlge5f8hLxUJuTI4SPKG8uG6aaJTfmK/1tkOVrel0S3p1yMvh bYJptir8Wt19pD4qr9FhvZzF7KCNDfLzRM9/IX0gk8OUSiKjtSrvsqN8DjF4gzIi9++D 7A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btqp2s1an-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHId139141; Fri, 22 Oct 2021 05:19:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WJs/LlYYpFPjKWGJtyZ7rg39HBIoCuA3CimQ5EDwlRtUujMESvTqWLEIuozZzg/uZev9WIuKTZ6Ix0Q9Kovbs9sUiiN6RYK2TB9EWIhtScXCZOPBCkEYo+177ZpSbf2AKZeXwtqTv0jFAwXgKHrE3OlYHrY2ZPJiZMJKtnf33V8A6X77H4wfp2hFFPi2lnB0Xc8E20SeKO76VQs7BT2rJv54zZXF81dWakkcgkI+itARjKwhtf2zo0fVvxI17d/BYgBzFhh6luCzsPwW1gZOJ9MR+IT2E3584CjaMcvSu7q5TEPdUaE65hv/fVv55BktmDjhRkWiS/kUHn0ZR8JfnA== 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=gN8SNw4ADdeg1q5nBmsgs1gvogoagQ4Ff6ocYLg8jwovIlGg2svBZIj/8NPyePLNje4+0VWC7GYnWfQ0BnC/Gy03fyV4pbXLZGVVohmTFEze7nelD2cwhlCzJHure8tnPj1ZabZrLNeVIelP7+rDxyx6NeQoOGwzRBO5S811RYDeMmh1aASkiggjm7Iw3HmsQS8Hf1y68the1JAKlknETlR1XYFuR1O+bDa2oYuTun7x9LwOvQXwt901BAwau6RV2cWNWGLbtnJSlw4XKW2qXaA8e7yi6sBYpmu0q9T0hZF5/Eik9cMObNSy0/ojaIvJIjP3dIv9BA51USwvjrslIA== 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=occ3Ym4eOvwPNU4Xt+QKYQ1REvHD8hBbyrVSwExI5oqQcg3nvLmadfOee4AK6tyTBn//iyr7ItBfsssGejNEYsmiArW9UAtxWcUzVWPOWl8xi0iCVGebXVFxn5bc7zxd2os3K7V3lUolgXS5eBu3o3f39WvewT1F0o68lohe+NM= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:26 +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 V3 04/11] vhost: take worker or vq instead of dev for flushing Date: Fri, 22 Oct 2021 00:19:04 -0500 Message-Id: <20211022051911.108383-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d30ffe5b-a092-4441-64c8-08d9951b83f7 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: sDSb5sRiABQHk/RLunRbVjZctnjyBIwXXpdxkMoW8jAo/w7FcUo2vq01mLqJzKIaaH9c6q+AWsb6rnSD6LRpH+aAI9DYMYZt3af8UU48uHMLlK6AqwUsfji9OzDq8JyCkG2YoTTcL44sDESFeZPyLXreHZxer3knbC1cS7XxL31nDvnn8M5RetNUvGH2iIgHrntvK8yjs0/RopNqim3LVPLuyjhz5TAUyQUudX6nlEQpndhM1qbrd9hGn59cWZW4DoqU3sxNQ27ukW213HpQVpMFSrFTQXAUtriRcGEcy9hTxz5fuNu0NaXJkO9S0BNhE4HECooU/px4P8j65onbeTjshxoEYfcWxOpq9TKVKz/Jn1g/mFqpLgsstzuDolywjQ5q1mbjOlQc5nw/O6iWhTo/mMjQHxK/1cx7OBnNX8UhrxlrmvRi4PXBVoPxGSKocSGrU/QRW/4CfDZXxrlMPc+8R1jOzgvvfuGNxqI4fuKeJbjixujmAXLU3XbBaYimj+BgPvSZNtwrwKllXUs51XlUlqHbHhsRjNut50bbGEx0Ad06wV2e73pM2L285A7tWzsD96P2ZRXnT/e+VCIzGP/QtSziptpjQ4uVszW0uaOAW9PsPgKhTyv3mX1Nymq8ksLLLYxo8djjhEo122FgaQV5DvONGgl65Vadp3CddG4FiXOalsqxnthNdiVOjQqsP4a6Re8cXLfjR6lYiLfKvg== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rgzChaSp8qDBY8FNTmU0wpnSssQ9N34N/98kKJrD+UNC88FYNdIxV0rvc4h5wqhZReyP8zcTe8tbhcyUkbz2xtHrTZPBmp52LHD/NQ+uv9cd4dcMlTPlPJXHhvXXEhBC2vMDpCol33Z1JCm+B04DXsG7SN3sUfsmcbI8L1J6flM7FUa1+WG357AA3a5G0CMVb4aVBxhoyjv7Jl2HHl1uX50btiVV5zvNPAxHb+j9su+xopylfWziHgmlfDGPzwk4DQsf8pOvE3HKaGAmKkWBWEQVvwB1okzXOvjCuaFr/ToKf6dB1PLKs6oh4l9p3Xz1fsjPBvF7d5n2fBsyQmEaBOGX8SUzRVE7fEHb1JBxPAtp/NQZwKfn1tRk/e084DINrMFKTGdmTVB3rEhIhHgNSEUlfFV+m9hQSRrXyAVZgENwshE9VL8Q+xngC9cSx6Rnb6SUHdGpllwfwYnS1+tul1Rg1TfB2NToPxUSkADxRTc41JmuoxIynOMfpm6f9ZWAkg6jiK88M8d4B4/eLKoBlAJqoFdRbYg8Fohj8GQjubUHoSAIBNkrB50/0Awm69GTlhQ4XkdgSsocZ8b9v8XoKSkKhclgU3vSHSdc2GLdUlU3tVIobpZWEKKl9xBTybpCNrZ55vSvfnmOcbTwBKkTdUQoahzQb9iCxSLzXROPGJOL2hWD9pS9ot3FTov7EXVx6VTUD7TvngC6+b74k1e0NPqrr5aFtd2oh/P2YkP1SBuYQrgatv9dJu3VKIQhYavyJ399CI8QoEFxyXCpxj2j99YPVyvL+hIBGo2o6/sZSqGaU/7hMm14L07cb8aI/7xdkqpRGxq4qSRK8b+TJuAZh1PqC1sWm37ufw+a69PeX0GExVvRM9FsocOqSvBxFkkQF6CFcm98sY8PMJIlFmLMZ4QdMZGAebrVvSsObfzrTu+Rfgp/GLgBSX1I/+JZEctAXMO3CYfJpKXc2cwLTfGtqKj+gf2FoGeOcIbegg+7SzB5H1Nmt1N+ONv6+swxsrwV9DGh9+HtXDOXyg18yP+f0JfeaVV9Byi0VP2QIAIydEhFlNXRveqGCvkiJ8eifG0UJbXCENen/CcsFEWx4i7BLhwcCmBSM/VMh7GuwA0ahra/5h6AkKTBfU7ZG3ykgqNjATjEo7SMK9Khi/CDFKvgdKQqmvd5wh0YxnYa3SPMsjMqayAacVFNPMxzPWIHuYTtH7Yh/yzJIryBYfO6SRUJy6sCCPKyXiKYkjrdUTi4iXXrtvM2luhDok864bLEgNrJ35aqsc+HSkl/cnV0+BSZA7SNqw7UgmsGM2Lx6KfBBzvuwe9g3t8FPCIf30EmN1wBYrFRDZXg7odlYO1EiQlPlwWWJV4w+WysycH8wZ5VRbg+objpGKY7VnKyMNz4DI4V7rvxu5fuSJOmc6krZsMFYkWvl1o2tVH4xDfbww7leBXoWkopfgT+ds6ZSOVPheRQ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d30ffe5b-a092-4441-64c8-08d9951b83f7 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:26.1889 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: pxOE1s_46WOBfnnedDVximMlFm8FcqOW X-Proofpoint-GUID: pxOE1s_46WOBfnnedDVximMlFm8FcqOW 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 Fri Oct 22 05:19:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577003 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 28AE7C43219 for ; Fri, 22 Oct 2021 05:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21FAC61284 for ; Fri, 22 Oct 2021 05:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231672AbhJVFVz (ORCPT ); Fri, 22 Oct 2021 01:21:55 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:51374 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbhJVFVu (ORCPT ); Fri, 22 Oct 2021 01:21:50 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M2qeuI019167; Fri, 22 Oct 2021 05:19:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=X5HrRn/ql1GFGMZSy1m7FRy5eOe5R4RwTzYfSa4G6ew=; b=yxRs3XLandNJA7CViqQrrKjYN3A8NnNMxf4I2R+fUHH2QDEK4RFmApvW3ItsUmwnTeYH jFyiqbBpCOmgO2n4zmjAjUjyNbAMgWwL6+udSoLAFbm0yQEET1IHZk8GgAx4fTC3GdbK 1+Bx7Qk34GzFLMYa1CxICRBveIfetASBbFzshh407uXFQUwnd4pYXQVWvasJioyJmNLh iRl4BMSUgfXJmkvBikes97AiqBI3Wh0xO+T+ySyl4l44WdPZiWAkOixMfC0J03K3DddM 5BMqrWR/vJUs78cPdNKxregPb6/RvflEMZUBEZQju32J30rTVgjtWY1uN7aApyMHFdSy Yg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btqp2s1ap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIe139141; Fri, 22 Oct 2021 05:19:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aRTDe2Qy9y9xPqpxWOHKjF/rU9EFMeV+yfVJ6OYHUOXxHQS5AB+fd+g6NY41HIRaaEDlBB0gMDxgo8HD6VdWbdPgMcxgVeymKw96Yr/dYxtLstus6xjjg4WMoUhSVGVH69Ov0Ho3r6c2pGCwtJ7iJz0l0PUkXNJMf59HH1R+rTQeAFmGza8A1juKFnWJgzlhOVbBDCcqzOPLAooe6UvHG7a3MwbfxCqw4O0JO7u7WnzjIEy7JtSKIh5w7UvbqPNyD1CJfSUkcIjeIYwb/fBDDwPgUZrFxpDSqGQQb9ZHIkXMAO37iN14Mvilv7bXfPys1An+YyrMWNXOas4W5A5z9g== 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=VFzr51TWJ3fHViXFbkXbhLjcPYsX1n2Y+fTfzR2VDEqOeNpRFvB4DxnQMSSvzp90vkne1wFdXmqiA5If+inNsNbbkCqhxLSoINffkkSaD8ezJA7vyrjA/LPsiRgBMo3wTgPij7Xz+uxteZvL5RepXDz5pLeGx/V5T3hXktjLIK407a9mg/Vev7lE/e4NRSa3dNDHKlMSZ+AMc+qK+7s2a5m/iOf0+8NWJzk2Y95JNViD1xucylXcfBPN2Qb6tX9PV7g+CuK1woiPKBxd2FR7Dl8SUOBtf5lDLkjJiX7l1QZs7HxQw3WQQYTHD+tH0qXtsUTD0ywwU+I5+xP0p97Ujw== 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=eSCGi9cC7cvPF82ZXjVa8G9XQ9LP2xGIMQo3jB/d9YDetRktaKYCG/c3Cs2IBKr9HdKrUZdih2xQNIcS48bBggAmwCezX06JlrBBV6NQlXHrrAD7d9j6tEeDw5GiJ+HZnjIsqMeXO7a5lvMuBtbq/6ATCTNp7N+t3BxvcVmVJ6w= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:26 +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 V3 05/11] vhost: convert poll work to be vq based Date: Fri, 22 Oct 2021 00:19:05 -0500 Message-Id: <20211022051911.108383-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bace67b-33b6-41f3-90ce-08d9951b8456 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: 8bz5AdlUW6Odr4I/jC14pwD+HI7jJP1GaXTIU7kbYfL0CsKpCS2qaa7/1QVTJ5uaw97fyqqbIpKrh3CFQ1wZYyPV9cwt63ArK2bH+G6Zbhn1mRlHX0nWZwuaAwW49kz3Tq3vNwfFDDvo9Mmom7TWDcY8sIa8hqhPILvpOFX1YTqAHjDVlTfvRD3eLPzCz8PUEaStE7X08nDn1Ri3dbSvLrUM5F3IWcC+GUb9e6oGCXimVxSNVDp9TaeeCh7QpjBSPf3k/FCgmwkdjx9vKUDbwqJ6DDq5F9T/QKmrmN1PW4f+BMOvn8fzibe+uxnLdX0l6sGADIXSlBRrCYuJx7LXHUwEQ+nB9PPf66P4mL5bvZUNRGdT7zwJu1QR7NW9KgPYC48fwG5Hf0E6rNQ5/C17UjamAQRMIv3sHC682pWPsQcXqwo0GOy+kM4mDGxbmU2z0PiGy1W98uSdopDWU/oSgsn/JSItyMx4rqsjcyWA2jb97TzQv0UizLsfKemDkX6vMP5xNzpwSa/NZv2jrvmShPE+N93G2OI1vRLiJsnPUH73M5bQU6+smt8MawZxrFiGzWEdRWjsTwbEqPZKmhT/5NH4hTW13wwEcp/4IshTdwIp1l7aIKbgLrR2v93GDrGf18VYi44OZWCt00ceabI7qbCsBiUDc+EV/kbL08QkzbFx9VRtu5c1+Xv5QIPLlbyQ3le+FheOnXdAVzFkMQNELw== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JLPZvciVxCdpXmbziGbAghYR2o8g81ZHyHSZosw9M3xS9EszJ9Ir9XrXNWhB3QpxtqTFSgMoagEszyi/Zqci7JtQK/8t66szfAFE2OKz1bLQFlhg/2xIYUNxZxZhYe/3u7XrnEpw7tg4eRrCCUfGvVFxVSPV8brFiVXBOufW7KFaqz4TsF0ea07DBnJjX0Jqjg20S5Rf/2aKPlbuisH97UUXTqjgWSVaBCBRy4OEFrc27G897yV+jaME/68fRFxFgfvKT+RBiOzcOc6jz2x7/sFkcaoXl+lqYH8sSAEgqNcXNNPKy7eF/YHwC65v9Vkla2/rG8COS6o3m6NZOco3jNGRKlsomv24m5gTwdyLHciUn+ClCKThr/PBgLXEz4eMOYwHJnM5E8gU9DRpzayU6Jas9K8SHlS2oHtd6tz2nce6uE7iAPoli269doeWmuQ8HehH2r/eb2zFGPMZRfFasagM1HdwDR06wGC5G/EE/3YizGAx13MXUD20ExhYNhjIsmdPJKFunS+QYOWVXJZriLBNwztHhXS1LvPeR6HX1/8IEVzyiee1+Dhgzb8jarbC4B7YmZBtcbKTfzLD7nAnT/XKSIGAhaIaCaZBjKzezqyNTOCY0a3VTrfAjq22VOVd8RXGMdR+/7aO4kxDAinU3NXGqr+TXzFCxp42eQcy01JyED9V4YNk2MtXrMn8MrQ4ACumSH+u6SNx7g0OnxelrUgoR+requ4Aj6esnjZZG9kERlixHoE6oI0TQXy3h10gkwX41ukOIyu5DHhY9AoBCqT5qu1c8E7jR6FX6Da3caxqjjz+Gezo+1USk/MacbY3BQbLSxjAIVeSEbvWGD/vc4vNlUD7apFo8Wsu9eob9k98MmKGErayeeyzm2L+IEFW+P0gevIuYphx/Y6dmWB/wAK7d1XcqbuaRVAzhbFDGOUQvco7QqHJ1zSffWhG/yUnP0RGlYc6S/XJczx/bUWSR/TuGWTEL4bkgKOwbwS+RvzGucgVu4wwiaCDMcj2wtjnuoehMz1cKm7ur7hlWvh1fs+wLk4EEtu9iAT+ByRVCUFgy9cDsen+7FlyOWXZNxb3qLxL5GYjx5UcGGIeuWjHISynOJjd97KvwUMkPuiMQUUoxIgJqEga7g4XR/Pfks1+NxHjsgvL7YSjh+1su5sAaz3NmUULGL4JYOhcLe0vjLMn3zSqfixMApJhuPQpjJMgRxV/V9N/HyYUo5xFrhgRNIOSpBw1U/U/Am30fwq1cWFT45sWhYJ0eaNWLWmIGpKE9YWgFbfmUVWcOSQvW66+EBlD5K36Myrr4c5HXxyXAar0e0P0HARaW2KgAQarUZpwOsAixJajE/CWweEixn5z0SRGaEKLmPH6F0XDIWfSfcLew3EpwYRsu2kGKOwXsIf3gUOGIQTiRhaf46KlfNmi2lfKVF6Btc8rO/PN01Am5VSh+gArINOoHJ2WeYOqnQkM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bace67b-33b6-41f3-90ce-08d9951b8456 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:26.8056 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: wrsTdBsWTGTradeIM6sidXu3NcxzS56R X-Proofpoint-GUID: wrsTdBsWTGTradeIM6sidXu3NcxzS56R 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 Fri Oct 22 05:19:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577007 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 657B6C433F5 for ; Fri, 22 Oct 2021 05:19:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5088D60E97 for ; Fri, 22 Oct 2021 05:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbhJVFWA (ORCPT ); Fri, 22 Oct 2021 01:22:00 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:51576 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbhJVFVu (ORCPT ); Fri, 22 Oct 2021 01:21:50 -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 19M3UmKk021717; Fri, 22 Oct 2021 05:19:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=qAivgcfLGbT443JqegSAXld3F+JKJSKCnqohMp+/uyo=; b=tj280fRq2hNE0SxDHjYfOY1MxNuBB/6259cEuosIFrBEfH7Rkb7PMfWUD2p9EYd8Y0XE KVloM9f8XKG4dphWLVqMo8+tkVGRK/z9EFSdC8exNopn8gQeV33dF6sGS8gaaJRvIbAB gx15EM3sleuaSS80zTsOX0rRSpMu7SeKtMyUEJIuLIDtehQAtNxCQJMU6oIOnfPaG9dQ b2s3KHIPMG0L6HjJeXIPbrqxOSvwyts9kLx7ol8tRq05jHsDybPcM2dlXW9JxGRSgZun +4mQuLBCAzu6+iJKnydQ5Knb8p/DaGXDi3DEm2+aFfQSR2OEwvT/KSycckc8+sBclnzC xw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bunf988jd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIf139141; Fri, 22 Oct 2021 05:19:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c36FZxo7owQkgJt4Bze+SUGaExf+bvBFScBFbeaaudJrElTvFvLOkRxk6D0eagyexqAwhCYb532yCUvOyqdisNCOU4sy/AMMLl7P243G6mMqd+KGBkhwfLBtsq0+0hGzfRH4Fcmktud+/w/r/Ix2ErExgpmMN1m6qkBjasA+0P4DySLMBUM5LmdW0aCm9b2vPCPNjfg6pD9MEcEvnpuOogGJwhcqjH5vIJ52k9MCdyZUcYROj4qQAP00l5M+V/1GG+0wcTCX0NFBn+0C26lgHiZrzoyoxMNQBgCZj4RH3mvAUIAJS1RHSGupLslcmZaKJtRLyFRQ0yB8wHaLCVdOQA== 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=qAivgcfLGbT443JqegSAXld3F+JKJSKCnqohMp+/uyo=; b=W5rnAe/hC4Igbv/tyhbL50LCGgx2T3+5x2IQxN5aSYRyugFEo2G65Qdxnea/GzCVvqKpuhdbUCNeYSNxCyoiZuJdMKglyMUIrfaLzCsaTPGBIvs7ibIkuljzUqEMB2AusGoA9d8WBWz43xzoHqa39O7AxjbrwTvS0LCUh3+doYlSYKiFN+/KfhQkmrksB5KI4NLQJbaG6mYDBH0bxxDjJVgBFDe14wsaBgE54AdsDnk5XwfeauQ/FWaNJFA5cHvGfCzQnhRvP83Zg6IhQJRDTnxgQtFpUR4QnQrpd0h8ttCYkHiS4CuN0BI68FF0iDQ4G/GFmMrJMD99SII+xigRTg== 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=qAivgcfLGbT443JqegSAXld3F+JKJSKCnqohMp+/uyo=; b=Wt8tBfSgbB5w5W4As+RsdqE0kYnk7IXizcRtdm7wsc0RdDe1qZ2JPDX7/03oVmxMpXLA1Oah1IvzBk+ZNoklKwwD8f6NN6z0GB1AFiWi6EgbOy6xr0dueCNxnR5GFPKLFv4y83CNuclyQB7mteAjklOr1EQFzVr1ksJ52neYTP0= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:27 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:27 +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 V3 06/11] vhost-sock: convert to vq helpers Date: Fri, 22 Oct 2021 00:19:06 -0500 Message-Id: <20211022051911.108383-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e91aa27-a51a-4b9a-4c1c-08d9951b84b3 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: fj6rok1YISsW2Hm2nsmWJ16fthESy7Dcj0t6X4h+Vz1N7iGdIDJJhaJMsdCRrRGElyUZ58Inw1Ntn2tTqpzeKIQ4rXMP4Tqg4rSX7fCR9sN30hFze6tpsGBHe3YpuYGOKKP6yO+ByRgcaQoRYV/3OcigiiIuK9EUQRHtuzKVOthJez3O9HIwD9igtKXmiIf4yl89Fktm8XPI7+HEUWRbHssma+c/tHpdro2FgvKn/a1Bs542oRYquvLD/Bmn3FTwlXh5v13jSU/ihs7U7aeXlTMS1h9S2cvwZkKhMSLIG+hC8OcfnhU3mlvWCJ5SN+S6UH9FKBP0rGjv9/clg6SD6XkxRF9KpE15cMIqf7H459MA5ZBCRt39SsBymGJnQ3dqGf8J4NzRBNJdPKxumeWb6Mr4EE/CYVjwWfPhCXpUj2zU8/70BSS83hqU64Teg1BAV+LaGHdgO0whzsJUSn6Do9IQlop9Okxw9mW7uDMb/qvPqZDhS0LTHXn68GfEuGcrKnvDGrFvH4l2ehs4fV6dIKDPmYhqaKBcQTgOM9Il3OTI5PyvFL4J6ovw0Km/u79oBe2wGhAiUW1/3rIktNTFj0x8HNVAQ1BT9pqz/r1nGu27z+J5q/5Rn2SpEsOhlxyGPqGXbAyEr5llU/0Z64KNkNiLLgANc88m8mZLLu8AK5TKRo3bcanrNnAWzs4emzNf+Cs3SNM1GjPZZP8FmsGEyQ== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yzj1VVPV5EoiGY0AzdAh+Y/9QXKDaVfk3fE0v6xCpmzE+l2rSFDhDuOPW2z3BKgBt2yusV5uq4CNEqho/HNHAXj8HvTRMzkuebvt76ucPY527cxA2+xabsdb8LJlkP3xkD9Ndtd/zXAmpNJFjF56Us/oO2cI1FNd9449IQvVDKr9EF/gOebD95uW3fdwPWyYOrdDosA98GJaYIBAJ7o18AXyq9FhNYfRiF7LA0qAuooQAQlXAV6Ez7tEkBeIEdmlVqVxbWLiHD8aVOWlLng8RAnzxRusEDNNsgY0yBpXndh5zePedtwIDSj0g7Xgw9e5ZyomuEwfZsKtZFNKxcS+Ga33NpTncKxk7PZ4kiQzPbS1AaPlSQ+fTuBnxPtLSq7A4jSCPrjb2IBeHM4nbDVRUcui0lAewyO8u1nF/Fl1mDIiSIBUmv2+u5RHHrmACZHQWTQ++FcUYLh5b9dc+APn6zqztTwDUsX3djQbTYN9TcV54NL3oA7opvWSrEqzewHhG3NiC9m6Om3jq1ZG5MRsa5vT9xcIlBTGJd52MidWHIjtz6pdvtaDKUx+dghsW5OLvq0OzsQqWcXXlaPfXWAMflBPkCy2JIfOTweokvQHXXduRiN8L00xd7aNoRVwx8gaFGvHFN4/2QEI5MT8JEIqrtb0GLbziNrX5LS/uos5JQnqD3o2Yet4P6NFNijdLRP8asOMyEtO2TcEs+PeO73wnuDx0typMF634Qo/WrnykCq9z//6efJsPG3rYemn2ZtjwGg330PjNuH4VhXMo6B+b1q5YxbTW8vQ+GZALwLAMwe3kqocn7oPmYNoRVTvU/M3s0qln9iWGzTPkEneUPwAh3gDVyFK066NiWQFuIiBSaFjNdTrLkEdw8YNgBlndBD16RIpx+B6Yoh4L6wjDzKaX2kWfXXBPoocN+mMep98oRmG8JxryHF6SIZYR2SbxtZuwRMBVKgTtTISRGK2fo19IllrpY12WP+r8P2geL028mT0qkJYI/JItzeiALR36O2tViNwKEJmEA0GPFNKzD6ZhFC+fLxIuCrUyC1wqWZJcG7BlaeFM+M2M+k+to0N+hmGgzq1yTg7Dpjk7KDkBO/ifjhJQ2qcSO2fyKvJ7FAWacrxRRc+7HuJyuRJIxOEVngAjNaECss56/Vk5o2w4K8EL6cfh4gITLmd/E+7lAMw9Q52ej+1no62RPpfN5KfhcGppBLbTC959x8F5d66Fl/13L1Y4c6tcYLyaARm7t59IQHukfdKDI6m5FmNgiy31s/VzvbwJl+mUchi/7XLNgRB+l3a5qzi7dfUmHeyz5P4I/dtSFa66rHpOmLB6PtoqGD3u1CF7HF1h6qJKtnwE5FCdXo6LArVwouLvc7BiBjTeC5ouYvTDE4b4cnbuMPdGAQJ9VprOTBh/ehr/Mx57ifabW07y+6NvU2rN4Idwz9s0J7djV78rfNEFUg1//zr7ZKm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e91aa27-a51a-4b9a-4c1c-08d9951b84b3 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:27.4553 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-GUID: DofVkvXyumaqwJ9jMVkdAJniid3IFMWz X-Proofpoint-ORIG-GUID: DofVkvXyumaqwJ9jMVkdAJniid3IFMWz 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..c50c60d0955e 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_TX], &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_TX], &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 Fri Oct 22 05:19:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577019 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 E1FFFC433FE for ; Fri, 22 Oct 2021 05:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C943061215 for ; Fri, 22 Oct 2021 05:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbhJVFXU (ORCPT ); Fri, 22 Oct 2021 01:23:20 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52962 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbhJVFVv (ORCPT ); Fri, 22 Oct 2021 01:21:51 -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 19M2lxtA016493; Fri, 22 Oct 2021 05:19:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=V2BiWlWONQB9Fkj62gZN5o6V72Nn3xht8vO97+bmBR0=; b=S2hL5lYYUYy05FGRzU8wrFBIZAaH27CirioSn3MWP0i6xFNuTR4jaBzzUgTn8dHbFjCP JdDg2f6uzcp4sOeN9OnogVqrv+chkvQKW2XRXMJDxmXmof8ZJhTXf2qD4qRpqCVw8UjK vzoGz2GnDfMHKxw2VN2CKl3X/mlIBrZ2nIsnfugcknNIU++sLl3rNACMsDD0s5T8TTqB mRD6pgVI0nC89GneWOwXs2t5Zo/CZi+DjOzfcQWKkgDU+WQsSew5Ykh4VOMiNPpNQ53f o7pujvhKBdSVEvIP55WPGIau+INqs2tqDrSH/pztOpqvNOsByr3IJI+KHoO2vK2X5Bl4 /w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btrfm8sxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:30 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIg139141; Fri, 22 Oct 2021 05:19:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYo6GTahHcIvsr2D9WzrJS454XQbePr4mYKl3juEtD0KADITWrE5r5XIXyzseflk+9RizMLH7jfJ//2oes/DzTqkx8Thusr0nXGCcNurb3I4XNy95mMrqD1QAsbpIFeQMZkuelSWIHsWNl0TQS87ocfweo29fycWBKMrg7bGQTb4kzDiw5xWPve7pYoPDp0ejpopAtwhUkd/ahHljT27EkWtelCC9mzoSRdDFOWQedWZGRjUNX9iTpVKwuk634YJq/zlbVDB2O83pmSEPCC/ZWruHDOtlUyW/nrSCQRtjNMehgNYOZ0PZYRkXUYTMF7GYQIhx2ZwCavbrqn9nF/QEw== 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=PPjxz2W6Fy3iQ0rtwmwpTI1tBmMSv+rNvNJuoLcLzBmkS6YL9QHADmBKmXDb2y96KJHa4t2QPslEYw3hYW7KuKAzh9huBiIw4vmL8jD9c8IZ3S78Yjt3+rAyzHO91Q7AcQ/JGwW/aAmH+LuE4VKrP5K+1WEZikTulX2q09k3wvOknkn9IH6Ag8y/Bi7mzhwF+/tJ0I3xVMNxITQ6/2vefX27azKpIUSS7/Yyo+nn8or3FHKpdRzZEKSHj5/50NFSTPyIhTb5THvebkgO6pS4fgNbOE/yL/tIw1gE2bQz8ffRzmfySjKdDrWBZUM8pY2BAwPv5znxUmTfxwkjyGCIew== 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=Ga2Gw9vRbcMwziva9O2tERnAYY8/L+sywdnGJeCzTLPJYB9NQgP5PKgq4M2YWgYBXS4123bhSUBoXbm+WNyqkc5Kvs4zle/CzhgC4bAvaohk/MZot38qz4hXsBaL+Ho3/ogRcpHgTPt9R5UdbliO8bPLUqGSMEbYT1pP5MNyMuI= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:28 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:28 +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 V3 07/11] vhost-scsi: make SCSI cmd completion per vq Date: Fri, 22 Oct 2021 00:19:07 -0500 Message-Id: <20211022051911.108383-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4db59406-8ecc-4920-6673-08d9951b851a X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: 8KlhOjs17IOf2mwLaUbPcd0WqzzZPqstKfyxh427jwxKz7MpFDwAHf+T4nb/qU/Ty16b+P8ZYgw2g3KH1NFl7UXbeltdcY8oQZsFZjpzaVQxkA8sIx9XQz88dgQhbTxwyqWRem2KzX5VwJ3rMXmwagY9qJ3R1kHGdsQni8FjwXkR8Nd1cqpofiXwzUc2PIQC/M/a1wRBMVXDXPUKabtBXZ+6s8LFqIddvyFf+O24vxure24jfA5Ag7XARbEvs4+0u6RPhvqYw9fkk7Md5d6F9g/1/ordJICQGkP9IgSXNXe/jKIEPazktPEqE7dCL6rujuCNZbwDn2n7iy2M46qlAjXLTUe04EYz7Q3j4CFq8s/Wxe1/Xr3ZvTrwKB3DHkC/yQFWtM7g2N4pHBQCQQTSb1JqcOh3bz7wbyGT05WHjJHTgX3nvdo6RKG1oVY6zm/SOn7hj2IyFdQQ5WfbE1CLlys+kvCd2g7heeFBlbpVektHZ+dfe/lbFXWHT5VsJ0Xcl0eVHpOAf4ZioL86MasapOFyqg6XeADDGoFyg6eR8Zm/HjYfFtfR5DxWHKjrkruwfFFrF0xzR2AlO5Y4sej4+nrt+/UyZUzhey9pRDEvtBjeJIhC8M608uk/iIfNmBF1pn7jb/v8oBS8l8YvhNbFgcVl6ZhxWA3o7K5ymC+AFd2cqdlrtcPLvPmeT47CgwEO7BcqZG5ZN4gx+11FJAus5w== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6T9Ztn5ZY0rxYmBzfGfA2MPe82hyr9W56k/VNdak60Y+P0NXuwsU+QcSs0Oaie39h41B2wUgoSPrpCDMT7Qt4xBdvA6FesrMewNSANOIoCtQWT++s1XAjHpjquHmnr808lRDHBgjgwZi5TM2RN9UNUxrk8cWVWiFeXHQ82oKDVZ1aNR7wDn6MPhaaOWvOY9oaDpH8DuXx+zucwak/kAQMTRVOFom6Y8wZPrtRqjP8A/1C6xJYgtdGTL21l1b7sCTRpUCOG3Cu4vZRuPJ9LFce94RAzT6d69XDAJG8vM7hVHVHyIglAbQ4K/01qu6Js8PkW4Ej+Jz3B0mCAAdwMEpYHyJQom40Um4UlplJWTW9DK9GVSqD0oPL9A2UX4E83Lx29gy4VcGoW3Ig0fTyHSRbnK7KvmTUcu+WYWkUGtq8Lfx2CqOZ05aOZLnlYzDo2SmNBeVIQEA20O/p5SpgSQwxt6SClJaNe4Sjp2bHPVWqmy3aK8aRUtZzbtIv2J/LbSDGS2CNw7unJifpet7lSbE3nkl1krBZAO6bliyEj6N796YGIGmRf8PsmNHe9triTmwDuvV/HYGa+eomi0EnYtlmpeeiWwLPKth6+5Ryqf0+Ip2dNG7UaS+4ewFHo8JWR0Wbc2MlMCZvPV3QHkhkpuGXRqNrePGA0rMEgKhneobR/ZQccjPYiP415d1LfyWFauBk4bdMFt/aRhHcF7Zrs33O3VPKUoy3q4eMYoVEEl4o42iqNMkpTXgN3u+ugTuJhcbrEozJCvLYoKXyEtx3sW8iR4cPUkcn5DZeBRlsSMGn5GBmtuIfBx4rEV7P/JXsQg112+oi+/ToaL16Zh2FOuYQSybRNvuyPwk8ZcTdSGuPBzhF0gAIRIM2elEKgjuFwgP49nGhtNwWiTHIjRaMc5NXWFRtU30BD8CMsjruImfpPwreHWpnYZafSBu0t9YzcRu6ETYQTOXhy060tVCq6aWTbNCk6fpz4Jszr8Lf5/PCv+VrIwVp4wBl2f7SDFakWcVGbHL0+lO4FXfSemr2c814jZ0N/VvivQSQl3iDLn+4SKKk6cU2gqrsvMeAUoFMfXyE0rD75Ocu+pqntEg3IFdwNsesSLRgzHEQrbHSTBTyfEj6xrrR1qY6plOFkmZ3mAmIvRSUhqFtxuwyfHl+7qQVFlDSlmyldOVfFTsOZNRr3bIe26es/C+xjbPSPcIukzjdtflDHPV81IRukAw0qLmKCCCewoppnciT11Ha22CT3Yh1RZAr7akoiAl7iBeIvs0/wbc9MrBqAAqalxODQgg1Y/zkGcnFPc17kKoukoPRX467NnJjPFgQWAtFy2Kgd2YLp/yWyXQNkxjvny5e4g9jTIrXwkpoI/oQU89BW6BJ1Y0V/E/iSe5cag6eRJoV80mbs1hRUagzGxJYt8T84nb0417wK+AEDqQwupoBvOOUwM8UdTEmURV9J6xqhUpmQ5z X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4db59406-8ecc-4920-6673-08d9951b851a X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:28.1270 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-GUID: u7MvQBTI8INCS3GcmfYuDqq-kIN0x8GH X-Proofpoint-ORIG-GUID: u7MvQBTI8INCS3GcmfYuDqq-kIN0x8GH 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 Fri Oct 22 05:19:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577011 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 6427DC433EF for ; Fri, 22 Oct 2021 05:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FBC660E97 for ; Fri, 22 Oct 2021 05:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbhJVFXQ (ORCPT ); Fri, 22 Oct 2021 01:23:16 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:40828 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbhJVFVw (ORCPT ); Fri, 22 Oct 2021 01:21:52 -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 19M2nhxm010959; Fri, 22 Oct 2021 05:19:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=BGDDUIOqDwyhFnOlbOmNwt4zkp0IVmaJ2y7UYayCi0g=; b=m45YG3YKgZAgwanPEKpwoIeEG63ACSHVVuE2ZKWy/5gSDV1ZjolsheBrwttGnn2WIBAa tF2ONkyCY/E9f+jJmgO9ki/CqiC5QvzJzKM4ZlE1n2gbZe7nsFbXd64oPI8pKAaPrpyG 6oKQgi4ewsmePZ21AKkJY8G5tDMmYJjG6tOMgdQ8GZ9Z6oLbc9A6JY9uC0tXHVv4hdb5 u6FdxG+dUwlAv15xCbnWn+uL05mXSxy7mFA22WLrszWv4KlKkkDaEQoRt/WzHvvAxaOX Ur0u3wzzaeP6zCOFN6aSi9q/wiqhgc3JbHxW+YXx9F3tf90m6a1/txeXrI/58FlekbjU vA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btqyps42k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIh139141; Fri, 22 Oct 2021 05:19:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PqR9iLy/mYl97VnTVOAZrIvFIIC/SxY6rIZe8djRzW5jbdqbzeR3zhSRjmZaXkSd+HCbnXJpPZXpY9fQ87lBjgG+agqI4Z2/HVjH/GkjQBsSWOrSdlmEDJRBc4pVSfe1ANwjnK4pHjf6vQk1srN1n17trDwnEcjy2c7rFK14Knm9t6hssQRdnrit7Ze9+99e4SgqeMqL1FV6ttM/9Zq5J6wb4svO3LA9D1tN9gT6o2ulxEPFK+p9pT9EjAGugZAmmu7wpZCKcm1L6GhJzdXv+uGWaCT8cdeTKPwtSjIHaCiOb1y/7HiryTbchURJ7vk0t1rNRT9CzgWFc7glZucQ8w== 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=D3+8xtvs+OPiHyboEFBQziIWPVoUlhEI3Vrdzvj8145l0jXkiHWJ+F3N/VBJW/Jpnv+k/eae7YV4USwVaIeTM8MifsJo3gd5Kd0H9EFZq2t5rNgaawBzOljjX27CQnOUDIbVz5DhVViMArT0dMJGWPalXTNi+vmA9N8PCiKmTIyQddQI3dCQjqCPar8Bdpw+xD6Zg3kgcmYYuKeILLviNMcXYOJWlzdrXOgJqnjfJWM2Eu83BwllYyCEU1XyN5dn0R+3DPg5h2Dt/iP0K07XK2zv0YZh6htY+CCzcthUjRlMYyvO091CsUvBH4tBbMea3vV75eOu6W3L4a6TCUA3xw== 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=o4kTvd1fHDyezQj1Mk3DsAq7kNwH4fr97mqX0e4dd5PlcCf9YR9DCCGSVd11+bEFNMbZf/mC1gRVwYwv5K4yPRDCjFUF7u03XdrNr3+3FbgsdPQsk682eJoDT6WxKy4w8QZbWnUPyWOBigUuEk49yBexGVA+36GshiZ8Mkvg8Gc= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:29 +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 V3 08/11] vhost-scsi: convert to vq helpers Date: Fri, 22 Oct 2021 00:19:08 -0500 Message-Id: <20211022051911.108383-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1775d962-ee9e-4a62-73ea-08d9951b857e X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: HiEu35uMP1ug477/fbdzjo77qcT5bwUAbCqRxEMzrbstDM1X4Hg213A774wwiQPMP4vrbPU7nm/Hm/KA6gLUayFlqTBJt7ypwcqu379ph0kpK36SgHvXwIe7cCTFjQ64SQI5OzJqtNJjZ3k41e2vN00YGTBqZiVhPCs/RbuuIm2C1/tVuzoNt+KtO18SRpPExWqUG8/sUVbe2Y7O0T7YVhwWlRxZSZGdRcdWQK9qtoSmXUo7M/r0NxKcfQy4cr1bMSUu/dtZdYtN1sh9tGDnik6JtAuoGrGYqTDpN/hUugsH4m9o+tYufj1Ll/kVNsVVAOV8+oeDtkMHv5iG4qgneFDtIgHKU0YwdWzoeUUiPKgbtset/CZKwiaLVD3VUVGwkdpyjHLVbMxvHjcptzBs0s9MLLiuOTRb/tDQtCEUzJOKBmpFj7sxWTEs/G9MBJ1oRaQm9o1+sT5ZeQshgD8rqTTODGnmjLmDiQpVI1jPnKNGJ34Ske6UulkLH85MO+oAIjdz63fuEsbF40AK+6RqRE+oOhtCdU0Naov9yrY7LGQejZinp2mkc188x4NinlPJ7aNOk0edUp1aGW4Qu9u0RlXpIGT8+U5qeBNc1H4PeePNgYBpDb8mufLQHXneNl78xTYaGNFXz+eIOMutSJd74yU90CCzGTGkW2Rn7uypoVqZDr0wRhhrMRUUX5bAYrZjS50pVwA6Cb0JukJWv1tEjA== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q3B6HX5rR8kxxHJ2rKBrKBxITvJ3l2YalqHtJ+3f7uwM7tHEKIsFecjMTwHQGkFuxpHoyUkkK6DJgLeXhjtvTD/VDxgUGj5+AjRsaqLgNh0rYSjoRmUC+QgisBmCxM/B0fG7lS1CaPUYsowUlK6pYVCb3wyrMp67r1YtNyumMziMWKnupJ+CwMn7QvMq6Sadt/kfRvkUug8+nSBZZr+YYXNDhBLs9Q8LHevhMDRquD7crDl5klC34BAWeMZ+CsN50GGE5CymjJCjaRkG2dS6qFtX4IzY8sJ7sxJtlHLQehF5Aqc0qutc3hdjbFYrXoH49AZLy/TaQ8gvgO3OXcGmX4IMGqfP8VXboy4OJpwS7jAxCpXo0TLCKcRfdJAACWKOo8Uh2I0OyfcYRMFVHLjHikyiawudF/QkjCRVSaJkglYBcladZM1olxXg6yVgCNx16gkfHi3XRkqYvi0jU2OUYg34Zfx7cA9fX1EUtkU78EYEzwusybAvCcQAi2L70qIwXH5iuA16blbXIRhm+2NFEOsR6d7mS+Ca8gkKFK1MhUfNGRCpXMvi9QD/HgwVMHEC+TazZBFb+smuR7991fiFy0pY8SSv0Am4yvLLdLgsRJ2Z+q/GWLRPgS+HWJUpUbE6y5SCrrWrYXPUaDYy2c5p5VrTKncJOGZZ8zvtDcY4wqyryi7d24ngJKtq6N9PqbtvT0fxg+xYYz1lsVAgF1gruRn8h05CtMgt8vYAlVciW4yOuU+73bstpXalfZIWQEDt/N5o+xpKtdtCVJSOZ8MqzwBDQW36y3wnc7npTMwRBkbgGhGbuPnWeTHp1dS+Silye7a9BxWDupKTiIV3WT82F7zbDpCIPhpl2BtVgWAcCVEhbqUkp1g/CQNh1KQBDDosHEzE2Yg1Nx9bx8WSTmObya2c7uZ918Rs/rwJfoNRWjE2S4NcaTfuO/KRJtm87tYLk5gbIzX1cl+o2IS3lwBktgytDmfFceYLpSJ5gD+AgbV2kMbRH+zWNF126egZ2aaxFbCklTRMFOshKMzR+tWA04RoguRHkwf1i4qiY8Zo3Unq12i6j9FrusE6ZKsd9yITlfyHJAVEa4XMSMAqKQybCpBVcD07sG8bbKiLBLvpzkpGtUY8dsFhy5a6SNatdUdUCVPQ0qan85zF5OvmcuOFy+sFL7XRJ2+aG3c6dOJf1o6Hi+mb9w/ubgu8RDVcXwI9YtevEPbOHP01n89ljGamiKG1kNR+gBSZwV/uKYj6M3+mErqDnhXjn6xVSGrw6jDlL5SfH0Db1GhQAon7CkDbmzpEBDVKTP4y59zlr/j92lAGtjkr8IIm9zT0GqhJ8xR4QZvUotaMXg7bO+MV26+TrG79nbVaoCvhc7ZqXfxZkoWVdLlYSHc/eDPN9zlmOTv8RbdS1j45JDfsvROtd0sO9kqC/Ee0AWk8nAS3CDpdxvXrzLuf6Ks3gbDxjs1kGpLo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1775d962-ee9e-4a62-73ea-08d9951b857e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:28.8887 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: 3hpEvaGvrUQG2WsglbfQLxeiY9sw1qDj X-Proofpoint-GUID: 3hpEvaGvrUQG2WsglbfQLxeiY9sw1qDj 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 Fri Oct 22 05:19:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577009 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 28D73C433F5 for ; Fri, 22 Oct 2021 05:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AC1260E97 for ; Fri, 22 Oct 2021 05:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbhJVFXO (ORCPT ); Fri, 22 Oct 2021 01:23:14 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:41322 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbhJVFVw (ORCPT ); Fri, 22 Oct 2021 01:21:52 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M3wkIm006091; Fri, 22 Oct 2021 05:19:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=VpZb7x7YWa+u43wu7GzcKVXpo2dcp8z0pkMKIqOYlp0=; b=a4F9My+tpnoCSusb3GURXlf48wH97RJTy5LDdk38uuhyxdXGidbYcUO5XjL4P/1ak/qZ BFpTsqeFes6nhqe3H4f6z3zZWmefVa0k0hwjeOJpmFjecjvYhbCOp5O2efZF2K1t2DL6 l6XKk31IXF35FlkrFoXA1zufCvLxJXYBPn+cihGk4HtZeCADgGaL1+WyGqC55LpO51vb 61JEI07TS1uPjISOMGRJ4gcPMapDuNeKWHJPnzyhIoDH65rhVWVv0V1Rb6hp0+ty1rbp wgy2bD+7obnm9BGW5J2z+kPEzcxRb5fQCFzyXwlFYLLG1QSA62ztKvE8tFnCUBXwxaqM MQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3bunvd072p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIi139141; Fri, 22 Oct 2021 05:19:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GBzuOFcDz7I267DrtIcRKaaIWP5a7BtjkXY6RaIDJ1B4qHba3o4LZC84Y2Lk9Yq6GQQ/wWEwCCwO+jaYUQ90W3QnKQ+DLyHpau3yDbtoQzxtes4HkXrtxgF/yLv2GKOETH/PInaGgqK3IjoP6bCccK5rnkoOatugIjFPi/KTP949tKGh0g7XzkFOcWMGQFOPMkpflrVqqhS2E8lzIHyw1iB6R2HT3Z/jO1T5dVi/Eg975kfLR6uMMLpB5ayXJtwh4c/febUihtRXYs0a2WDwUjYn6ouLnrFdFITfGjtJOgyrv1xjZbgtII3d3z5Sf12Vtn7W2Y5QFZ2NRpsMr85zcA== 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=VpZb7x7YWa+u43wu7GzcKVXpo2dcp8z0pkMKIqOYlp0=; b=MCez3NktL/o961D8bgXSZ3xf3gtLrH9GmlJvhZp8SS3+16JGmWkB5fmyHvXc3n+T1ZqP2+lQ36LFl6JiiRJIeKQttaRZSJkMKi8GJ/9fkBtOmZdSkRdPHV6nWP8aCcuE96mtUZ0Dzy+uBaqYh0FJHOaT8qH7+P2Bu1sGjt5wRdtCVeYc3ZHGtrYXzoMU2DYlzdU1GVnj8quF/lGZqq8TDvLuukcUqMkgxu9skiQmqSHYQ4h4jBhiTflZC9lhvVtaZ+TJ6sWCjImOdSJtCnyrhs3COwjRgUSK5RKrGK7t14W7AOLFYEx3NtG/KcHtdoj9g2GnQtooRpfhtig89QgHAQ== 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=VpZb7x7YWa+u43wu7GzcKVXpo2dcp8z0pkMKIqOYlp0=; b=zX57mR3q4dnNPqfJRdugjnnPVyPWFxOOZW4l6Mblak7DPo9V5QBK0FYwA47XdXAgiSCfsFDk4PWzdx+oSJrvRlyjfkVSc7rF7wa6hJ/fo/SQxuMC7mW1e+u14OSfUSeAWMHHxXqPKf9GjO1Ol7hibRQQ/T5q9laypZs/9ibMlCs= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:29 +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 V3 09/11] vhost-scsi: flush IO vqs then send TMF rsp Date: Fri, 22 Oct 2021 00:19:09 -0500 Message-Id: <20211022051911.108383-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 204f2eeb-8a53-46ed-4cb7-08d9951b85f1 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: ZWeXkLBT6fV1MWjnpoxFHlnwKe3LeeRYRk8PgVM8iloLlvBVUHMqDeeOD6cFbjnB9bCWwKhJTrmdGtY2RxDHUe0u22YK8GHEJ+UlHCln4V6HF8fFo0uyJ/VLb/XQGd+RbUg+uJtIH5XXQLcXmCY/Au+PNtDL7CIpqRRxqsf+sTBJySv/yleZfOahWhdTZkXVKz8UXMKKiXozQhXCy0wmFh/yEe0sMDGSnkGQhyBH3t2BKBipuvI/3ohCc+qGlj9MtNjIoKxRls1Nm6ONuWrAaHC9p8GVEt7X0hc5POh3BdjwoxRYbMaGrOdlu6kYUuUaDYqMMoByaOQFNiFb6x4sNw4lC4e82CXBd0cVrTLbuMmgZExDOSvcdpA4Y3NzNT782Rh99lI8OxfMvCmDxL/2447wvfa+QLDkq6PCyxvKxcGqEBPKBy5MX+Jepy2BNnUEbTSNF5tVGYdk4MQBoEyQi4QTE27zfEUA/s4ollMjSAncI1GX+6xeqROZthp9WcKsWOWow2ACLuoOLaN9k5KaliY6luvBhAX1+GBTjC/qehpkSK+jC1BFx+Hu+H6HFyA9yOakeD9OhECSRLqVet7t+0w35UVnzhm/v1VK4IHESzXgyLTo6lYurdnGzi8Z2F6/9NwWEIdy+i/IUusiRwONrqFVlR9qRZrK1kdQaKipiScBbDcl80MBPFfwn63BrLpl3mUtsMKRJErUHqQYukL3Bg== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vEUyhtYTeyZPls1meduPsnHce/O2OYM8uAN2Mo2sqPJpIjR0AtJa7MNSJ3Ks503i3ueTow1V2P6KWKc8KMNFPlAkMIwZYFhmQRo6uj6pse1AZ384m4Hl8Y3sE6FjFrNjk0FGJyLzRY3Nj21zVs3ehlvCzFmDVDLktXch3hRnLiPDDBDdOvx+mTvbprQeABap8qeh+gBkX+nFfaPIbaB5OrkB/KTSx48EJgog2Z+DLRA7pMZVn918P1VLo32LukT+5ayWgZNGASsF/2zuvkqZPQ+GfBpZJU1Qzqz7Di561tTOqnsQ98fTf31fJrAi7lGUhxxIMesXKBfXzjI1BOjdfTsbfStMUm21xUkNe7FFXZ6B682d5jsBxWvHmciU5V/E1/3l5/GeueL4ZF0X3ep0T3HSf7f6htZQmfgrcUEBuOZzfAzXj+EByZiv2ALGVq5eCMnDkbZHWZjW2xWKyrbm7N5h9mia5iSZKvaVigcibLtS1nzA65RcECiMccvu+/JWvtZAq95rrQI8e+bU7148tW2vXaGsZrxJ+eu3Q5CoyRmzqlAdbk/JBrowdNsc7+4qD1oA60RQuhjvYVq8TJ0DOL9EpWniFaFskuC8c3YV4oLdhFs6uVknX6XcF+wh63/4oHFkAy2mY8XfGdZBSYqAadYhOKkmV2XbogtdK/iyeGE7yE1+MN32MZQieNcNc9R6cfLDqVsdMe0mDEep1g7YcrXeo40K5P/ByW7Iye3mq4c37SFuXAM4kPpUq08fsSAgjbP73Z4GpaCLkqRr5iCU/WFIIdRrOXFWg4a3LPGDeNDp9CRBZqVk4O3IIMrvUo5i6OFQwmKAFmAm2yU6LoI0QA6QFbUCr7ThdhJnu6V/s9pBiztPCrxJKeAM9JZn0s2L8Nt+f9LEtpuvB4tnMV852u5+bBYbgbNYKkhUrNp3mofSjNMk7YTn1Ind8tkrwlUlanSbR2XYHY9PfHuOmQ31GHuB/9nNZuKWc5yGClcezSylsTROa5jLf3o++13WF5ryXKf8By4JgDCiHCkJ/WhYDFlHzJcAHXR+AZ9OtIKyKqBtTIioYy0tSNcQmKw4z0XHXKY+/kkc2u4E68Rj147dCl84tmNmsPudCHQ6PF4bGpxdgbalREpQl0vnCdw1yJJA/8MyIb95mrP5uVzYw/L4QwIH/Z8oUgpU4BecQONJMKSy8QOJCWnhSUv1IPBr7muizrtVwD8kUmA5yYFG2A1NRgma4GUt0k/TdqZBKrRgN74zlO+0QTuCvNPBH5SKYhmJ1n2Z1jjAr2I1zkKnZ+b550qtqDkNtD42LpQJT4kKuEvVqtg+jmud5qEJlWVmt9NX46+lK40fyQ94kQZrexmiaaHd86nImQnht5sAGtWYQ1nWnoRoE8+oDhLeiaTUiDHQXDbWVzf4JKodyCUBqzB00sfuDK/HLNGk4aazTe4VxU5w3vuS2cK9Ix2CJzCle4Qo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204f2eeb-8a53-46ed-4cb7-08d9951b85f1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:29.5444 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: psLVTeUoHjIzHO3xnunRHWblSXx8CaoI X-Proofpoint-GUID: psLVTeUoHjIzHO3xnunRHWblSXx8CaoI 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 all the IO vqs 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 Fri Oct 22 05:19:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577013 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 53228C433F5 for ; Fri, 22 Oct 2021 05:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BA4960E97 for ; Fri, 22 Oct 2021 05:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbhJVFXR (ORCPT ); Fri, 22 Oct 2021 01:23:17 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:55058 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbhJVFVw (ORCPT ); Fri, 22 Oct 2021 01:21:52 -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 19M2lxtB016493; Fri, 22 Oct 2021 05:19:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=fspmCOXmEpt+I2Zli2AQcYiLadL+u7tR5vrwNrLtu8w=; b=jIslBeu/znzJ0syxoFEXJwiTfxKFw2Ijj+AYLj4aThkRqOnFmdWehdZ++Y/5Oems5k9y QRUT50Ny709V+OkAjirMNyRJ64QuzYMeWeqdJQauRzvP4wDJ4NKqZEbVMGk1bXbEAeLW bzC9xzh4EYnqeKBo0at3iKYmRpbozJqAj+chwtM8yAAnw8cTlSSjzQ3BBKyswCPo5E1k UXFvh/VWO1i1JksTUm9uzQhOYWsBTiargMPVVgFnd/Zay8+EXL53N8nhCA9a1tkSbAcF +pGiiLTUP7apzDJW8nH0FH+yGD0mX8qRpoWIIBeJJzShkPpJaT57dvWvGDpMGCB2/yYi AA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btrfm8sxv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M5BHIj139141; Fri, 22 Oct 2021 05:19:31 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 3bqpja16nf-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPpHjE1IxZmpg8dePmCtzX3lksDjphLcTjoUPfvgpvfNwrYyC/TbXsY2f3PSPZ461aDeSqzpzPNARjJqMtzXPoI8pcN55Pq/8r7xalSG4VleS4n4xNbvtrwh7eV7q7nACNC3MzX8uXlP5GGNYujATjzUmdZISkPm85GfrRiMCjX9dfwYq9ZjrVZl/BnUHweOJeP6FHR4jtOBOlkfqyy6qLCejSdd4jLfuYsCPsyJvJ6D/D0eL/4ZvxL9qWUziO8TQ5yi9oYEVSdb1aw4MmRxw12f3km/IdottnuqCmXZJbLDjd7VbaJRUtaa1E7HyFcGC+Q3DIFDsftW2aFnb9QUeA== 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=mIUZwH4t3qkGbXFznAhHGVCOIOWXjryfuaEwFzeXb++34p1kVRnqN7dttKrYiOIcq/1yhRdCxQAz7pJwiaO7KsIobzE74CSfoXC5zWyZc32RoWHI1eeWU7dibc2pCzHXj6TQUoApqH8vFjMd0dbQXNF76zkME2ed+U+IjgNbK38EI9M318AKJhMj/7H+TzVR+ou6taQ0QuQdW+vMkGc7SFwQljGwoCg8QptqAyyd+Qk98AsW2vA9i2dc1hkoRsNwuZhq2fDMp6GhKT3a7elavlZIiYC/DGfeoBVj2UYz+OvfFiNUptv5MiKPy+yBU31Hh5p7s6fZ+xG3DVGTe8LDlg== 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=kO+R9JyciXyrTqZ4dnIKhD2IV3RY685PprDuofId3LfUEbFk/d7SZlqzybO1d9sUrrHXpT/2FjDuU/HZPXnq43KeOuX1HikcHZQKeEvowqkLRcjH0wpXMY9Ijccnew6LGfWdyLjSdIB8m3JevyrJfPGpXSOA85t9AjiXb3NcnJs= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:30 +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 V3 10/11] vhost: remove device wide queu/flushing helpers Date: Fri, 22 Oct 2021 00:19:10 -0500 Message-Id: <20211022051911.108383-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29dee8b6-e106-4484-e506-08d9951b8654 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: 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: ptSYYqs/iFeTc8sCSVgzyNaJ3VvY3zagY44zGDtZauOOLXtDhu3ZEUyf8HBd7Ie+T6/kDiTn88UcZIMCZ2xHPVdaHKmC5dDwIaL0ndOSbulHZBNuI2ofMK/tq3le91A6cupvvWuezWk/JfdyQMlDiY80UY329/OuDVDJklmxdb5CYKSJiPdh8a6I5OULprbdNV47vuIv9wUwLb7wvpVzt9lJ9H4f91P/tbes7EkKFFB4H+fduuvSiniMnWjwj8s/9GQ/xu7z+g2MZjY/SvmXTUTvYWP8ueoGCg7OuCN355nKOOa0Go/svFTyKPwDnZU47nr2COBP5waexXrtZWH2ZYSk5o/3XP2St7TfpXa00ul3In2tEtQNNDdw6vNEJojM8sU0xoVrfM/iuwCGMdRTjnvw8BKNvSqGYMfW1JMwF9zQYe+dmDqwk3I980LW7ShRif3COmXJbqh7jKwz7u5eVt/l+5MIvEwvkRqllwUouicJiMZ1eD/L9XJWlYOBd4hFJwHLpHVzn0qvNyuPLeBx5zFFqlq9hYgZp5fyCejxPzQ6tluT6PkgwASHZKC8dA35mmz5HbOtIV94fB3jzgwODXXBjbt1zVeopZJ8M0oX+b4eO/Xlet6toWZphYRJw/rKQIDX1L7qUcRrhqEyxpzqLMIx1L4azJnem15TGtM9HZM2BgyGsSOOVZBEfuudYyaV/LDpZni4x4+tp2JpzZ8mGA== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8xzvUgQyx770zfJEKy5KOjbxNA3aQA1G4WGMVaVGSnhM68BvRcLqSRAUism2DzsOzhxj+ANjwt6HDSXI/Pf5cTj4rmWkSD40VtulY/Rf7eO6aTeR79U2mGeiAblnxNNjkLwJknYmpNlxJFF8mE3YHlF81A9Yg5YhLpYf229lDLB4vBXZTripND7zYCy+c6zGDAm69ii/r2E1QDVQj7wJFfDgQaCcB+2gawp/6HqodLcrBqEAq+8/v1setSt0bBLPp6q4Wu4Kwbc+Zpi0XcCViu97TpRj5kX+Vze1195pzjfEyT5LwpZ8rmCkaOVukUBZqndTbk5DbhtCBKcQv9pbz1COy1ScPZbQDEo4hU1N/uFdBtblRG4aD1vZ9/aXzS2qpEt0Gx7fG/gPQHboWO96t7fGpTIHYBSBT/MAiVUy5K+FKUvtHem2KPsiW3MznOIxjVsp66E8WUy5uQAX3SEvZ+QWSSjtX3I2hh4OnRtxP+hrY8oHoviUeenSkhqUIHtzqrZmGGd6F/CyL4d9vv/4E4oUo3+q1K72ojyG/d2Lpw1Z+BP9+hokxqJmDtmJU5EAipXnFLjrk0CrXelqRsdrxMEDsWNba1Oww5Mhf9eqOgaEtaeJT0PxC+rm0t1E9FAnd4L2uYX3qlyVV5BrxVHhjXgqGho2xlI0B76Q8a9aL0IHVFV3YUr+NF+2jFffp7lSpJpFN41J4wBU+fapM/5o2YZZTBgN6PDnZ+E7EmPZTLNhD1It5Ccpkut8NQamOc9hcFJcliykeihNCjmzWutKDZX+YKLlNGU7bKNC6h4ZawznKRzMZ7JW4PaACxQjjpJQ73HUtU7pF0wEdlPOG1J2z0q70bFXHysYvgSiVGjZRr/WcOIzq7yeAFoeCv86m1GRxz4J34JZQH+9xfPv0rUmwXi8f3LVrB4i+/BNVmVtR+8t61NDmRYgXac8VNCL+zHV92hOS1N2PjM9O1U+DWVDlZJZIUwuWo4V1MjoR6T/Hb0as+Ap0L6MIo3k7Y7+ld6NAZVFpoS8dlQ4ik0ejhxCQxfdaCvxgAKkoY8SYdR+9K4D7xf/X3FE9wZR285061xQFnGoLk/08WgqczkVrS9KDbQ8PXLnQaLLQqJv9BjYKrM6717xYYbaLUXfWgbUE6hgKGyPXaWEcZdc/AbI0Rh4JqQswCusHxiE9UnEKuZqPtPYQjJ+jT6+wiM7CFpPgPxe0jEOzl7Q0baUQDjr5zA6h04nKeBfYlBhBvuFxNj6OzQ7+F59r+THo6Aqvl8mm1QzJhSkvQAlRSXolXa4LP5WK9FaWZyNoeGaVINRf4zZU72lrDyHWug2Hyr32e2TVlps+yZFuIJWYZKocBtQF0DSPbTBZo0o8cDMa7YMxcpPZbo0z+fJH7zxMff7FLnJHqwRB3if8NAU8TcrKvGKMNQW7fkylf2B+DQq+LSycNQ+cimpRfNG0knwXsxMmg2GZtDN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29dee8b6-e106-4484-e506-08d9951b8654 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:30.1321 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-GUID: nJRjA_Zh2jCWSmzoJzALE6WRGxJg97qR X-Proofpoint-ORIG-GUID: nJRjA_Zh2jCWSmzoJzALE6WRGxJg97qR 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 Fri Oct 22 05:19:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12577015 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 CAD14C4332F for ; Fri, 22 Oct 2021 05:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B761560EE2 for ; Fri, 22 Oct 2021 05:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbhJVFXS (ORCPT ); Fri, 22 Oct 2021 01:23:18 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:46692 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231773AbhJVFV4 (ORCPT ); Fri, 22 Oct 2021 01:21:56 -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 19M3R0C5010002; Fri, 22 Oct 2021 05:19:35 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=3KYSseobhLsX3CCyduMS8iQ/XqjAJDgW1U5mrujvZwY=; b=gVvCtJ7kYdcYR+vmUWoJxAOdhjm/XE+yd3M3b4b3t7uvlPvOVYDA+JR7WkD8YQFlD/6Y aHhDpXDo8WMrWJ9QKGezSZBXOqzItMyQJrjs5qGoOmGPKh36MBVhTig4JY4c18+51k89 LNabbxVD0D2jy8fAooq/ZCPyNcixBX4LMCv3DpskKYLOWnKvF1VSH1vteE9+AwQqfh2b J/QbFdKU8k1K8onnM06BK9WqDhH8k9nbdoJEoHD47ldvIXdp4+KFGxpa2WOOH7a56pUj ASzayaxResreh5Kbej/3AwuyPu7RLiYmZZtGJAVoFWbEJOPBuNMCyXLXL4uOK4ibf+Zb yg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3bundfg9ek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:34 +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 19M5BfsG096761; Fri, 22 Oct 2021 05:19:32 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3030.oracle.com with ESMTP id 3bqkv35pvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 05:19:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcumpIpgeoChP7/mC61QL+WN5K4BW5RC/+JW/wMnf8TJKO3vstY1s3cae1uDC04wXodxa9asEj45I+Beq1+vF1Sl7UrVsfIVHkaLqo3AnuFwolwTqQW5fWzoJzUBu1EHKByZ+kJRkNoNxojrhwnWyR56WGGQuhDjfrzCXLqDxIrGZ/Qns2GpCGwukqFYuU2f5uDuF7InCWVS7E8cuWs9ysM9fkfFlImuXm5htp2MvD2TKZgGc/wFSrNiY3iTDMufXEsjZoeMK7tpId1r3RYtPdGzb4la7Qxojc0JwzlFVjokU+e/pdM20YKtStWn2jobP3RB4vgRiSuaKyXJw60ydQ== 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=3KYSseobhLsX3CCyduMS8iQ/XqjAJDgW1U5mrujvZwY=; b=M7Z8gnflnx1a3D601AgheVJ0ayVBmm+D6iY53c3OzWeu/OySxv/WJ/gQBj/1aXYQIkIX3r62i/aSG75cfkOi+4IhoknJ+/s9YDW0KUC2hkWSVrv/EbqTLqXL9Oc5eguAVfTrVsR3QQDpuemkmMoQ6QOjhvzOId7ZkBrWWLHeHYKDmIUAMZvI7u6FohJbGoeHw8Na5Q5zCw5JCJJEEjybIW9x+6EVu5MqLWSm+CNYkawZu++6+fTcrnvOWff5luOj4ZPGY2qC5W6uIkmQyemZQuTf1t828KTCeOAsq6oGFAwWqWDa+hFMfWnaFWtbML471RghCbJpI3YL0KadCNehWw== 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=3KYSseobhLsX3CCyduMS8iQ/XqjAJDgW1U5mrujvZwY=; b=OZyFbL6CafpkJtLNfPB0n1zjUiUJFTHCaFZ4bdSkZE1DdTxdiogBtVYYhAbSp0EFJDCgEcKQ0qpQ3nbmD3wb9x/LMdFw/Ku1d4C4DGcfAIK+Vy6tGoNrS+svyzQ4GgzH4i9N02hCR7BMpJzWuRvNSfWw3GnQfSvU4VyZY3CjZWg= 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 DS7PR10MB4974.namprd10.prod.outlook.com (2603:10b6:5:3a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Fri, 22 Oct 2021 05:19:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4628.018; Fri, 22 Oct 2021 05:19:30 +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 V3 11/11] vhost: allow userspace to create workers Date: Fri, 22 Oct 2021 00:19:11 -0500 Message-Id: <20211022051911.108383-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022051911.108383-1-michael.christie@oracle.com> References: <20211022051911.108383-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM6PR08CA0012.namprd08.prod.outlook.com (2603:10b6:5:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 05:19:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed2c5601-2585-4285-26c6-08d9951b86b3 X-MS-TrafficTypeDiagnostic: DS7PR10MB4974: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:324; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hQqsgnKD0yZYPLRegDrRyoj3npC6mydEDFYSULyCgiDsoGqS8upSQuhOXAsyLTMugBbT+eKVwvufjqrujr44FD4obRXQguD2tKu4zT86yQ7JbkTYamvF/MyKJ+kzThMPRqK6OAQeBPZAccViL5g8FZraWu5djYITBsvE83OaHNfxy5zEuzE9OiMPFdsfGNUfrteJvdMriA/EChhYEX0maHwutjnlv6sK5Cbi9ajmzLoULR5bXX89zoXO7X0+OcuVVBMFnQBNA/pzfLRwlBvSooaF1SxsaaXN3PBxsWt+/g7/8ndKdTFaWEjrOKoq4QuYuimQHhq0lVcxPPeTrJ95UKSE0N5kK7F+Py2/+7glebvhW4mxmmNAR+Yu0BSF5sx1f1yVFKiFG37GJv5JsFadkhNryfRPKubvAvTkso5mxRmj8tJBzFVJm8jv8QnGn71v+p9F9KAQVug9sEc2RdUU4Mtcio/FhxTyxAdAOV4WbAA1vn9tvahKllkBitKKwRqRgsR1mfbpKUP3gNF2g7lPCI5muNjQh42exGUigHabnUJyegvg0DOpsPl3eXBqoXTHZc5Cqmj2ndb/f/KImxRvX8HXgLb6ms74/7WP/mZIHaq/VLO3RE8IeAokq0JOcdsW5ce1WySKhYoxTYG46rSXjMzidjuhjNLntrfdWcHNxUQRB43Q9W1j6ql6KySypSs/B2NgBIeSn2pZy57XQIlkoA== 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)(8676002)(107886003)(38350700002)(66556008)(4326008)(36756003)(6666004)(1076003)(508600001)(2906002)(66476007)(66946007)(8936002)(38100700002)(316002)(6506007)(186003)(26005)(6486002)(6512007)(83380400001)(52116002)(2616005)(86362001)(5660300002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: igNS9s9a42JXBULYqgHELn4SIdULhLJvti0VcgWIFLxUcYcA0EzpxSVi7c5yD9M54izml33D4lPKyad5WO3Tf46NZHHYNYXWqMKScenX/BZGGLoK4A4LMzA8ATuD2v60uMBqLvbAJ/OMbvZe+AABo2s8LqojBy7Zcy0zGIoEk0BDllU1MD1j77UemcbhfVIqI0NRuW/Hnq8yXoHflI5TOQxE1dMmzIwO19xUEqllYSnirZ5JW7mw+12GgDAaeLW7H7ycuuSHDlvUqSQ4gEHvxklds+syd97MTCZieXs7niExZp0ByU9VKKmtHPnhR33Z8n+BDMXeTwZR9Y7XAktQNhHUr4PRh1bY5yDEaIIQi4UdK3Sf7mPWo1asGrq1n8M5BG1KPvY2nDLQd9ygU3S/Y2dUJR2ZHCqIdRLl5dfiEIUCwhKs91m88GdyHToa/PQYOgj5mwNHiF289AzLj/T2UbqeCUFFaCq36rWoNJrB6tKM596YFd3JWc2vRaEZkVj3mkHz7YV4KM1sFVktfqFCk1HN5hSp+9pkGaA/DcxEo2VJCN535YBmvBjcIjDgBIziuNmTICH2ceYPaWnjpRPIEEB60V1882GtBu3whLXqTGCCIWLFSMskvPu1Yrk8F8DREKX79XFHV+blDX0aplrOk5IO+lBEoK8XNfCozc/G6Z+UTlNhnfUQsUzDf6FHOnwI6EIS55hV6a1lgzMA6ujG0nQApRMMT/pao/b/D9lVrgPvMr4HxThwCyK78tYquuus0h+iKJkwFgxx+B6kPqo3xzivMqZJzmlPxOpBJ0q9hzpH/vqlohLKLpiIp3joa8tNbt9vWNpIBmi2jd9leEN4rYyTvIcJiABpA8gpUHKGz94hqHb5MfUIA6+I6QgtahjRy1sa/Y65gk5t00EaJu4+bbdXsidAIya7BJadA/KizqbzwHqml5l59RSCdripO/dyfXMJihxhA9uoJSqXyM2RMutloYarvnNm0OW2UDI6sPTKLJb48hMa8RP8ySQBS/jDFfWNMGq85szyUioXz1F14azKs+cFh9+CkQvz263BbsuFdJHRy2PZR4YReIa4rWc9cZXvQE6P/lyLzX+Z7FUomqwPfoMhexQxAEPvx946Ctjl1rAzT3heKN6v90EYM2KiVOoels6tNmwKrDTdT9A83fz2thTxQa9ZTieT41b/oCwmj3OZEUc1AelaT6jrsV19GJt+h+3Z3OY3MrdrF+XU+UQS4HXJSOBCxbVMAdAbDXcN1+HbUxLDwQ8Ik5+Q3Y+bFignoEXLW8B/g/uEhGrCePEXhQ5S1UU3NFS3uqFXyxV8L2smgC/flBm6EIc99TdGruthrUFnyYo+JIABOuX2uwU0/A3+iawRQfvSmntJNTXkrmPCwUKEy4nUTTRQeqS/UlXqSiXrCpVKqL6jrV8oPkkZjP2gvjTjUq1q5y8yl59sCk77HQLekN8a5mTDFkIb X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed2c5601-2585-4285-26c6-08d9951b86b3 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 05:19:30.7998 (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: michael.christie@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4974 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220028 X-Proofpoint-ORIG-GUID: dsdACF8mSAPZprrxMjka07R7BkqYeXl7 X-Proofpoint-GUID: dsdACF8mSAPZprrxMjka07R7BkqYeXl7 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 | 99 ++++++++++++++++++++++++++++---- drivers/vhost/vhost.h | 2 +- include/uapi/linux/vhost.h | 11 ++++ include/uapi/linux/vhost_types.h | 12 ++++ 4 files changed, 112 insertions(+), 12 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 04f43a6445e1..c86e88d7f35c 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; @@ -576,20 +575,40 @@ static void vhost_worker_stop(struct vhost_worker *worker) wait_for_completion(worker->exit_done); } -static void vhost_worker_free(struct vhost_dev *dev) -{ - struct vhost_worker *worker = dev->worker; +static void vhost_worker_put(struct vhost_worker *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); kfree(worker); } -static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) +static void vhost_vq_clear_worker(struct vhost_virtqueue *vq) +{ + if (vq->worker) + vhost_worker_put(vq->worker); + vq->worker = NULL; +} + +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_clear_worker(dev->vqs[i]); +} + +static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev, + int init_vq_map_count) { struct vhost_worker *worker; struct task_struct *task; @@ -598,9 +617,9 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) if (!worker) return NULL; - dev->worker = worker; worker->kcov_handle = kcov_common_handle(); init_llist_head(&worker->work_list); + refcount_set(&worker->refcount, init_vq_map_count); /* * vhost used to use the kthread API which ignores all signals by @@ -617,10 +636,58 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) free_worker: kfree(worker); - dev->worker = NULL; return NULL; } +static struct vhost_worker *vhost_worker_find(struct vhost_dev *dev, pid_t pid) +{ + struct vhost_worker *worker = NULL; + int i; + + for (i = 0; i < dev->nvqs; i++) { + if (dev->vqs[i]->worker->task->pid != pid) + continue; + + worker = dev->vqs[i]->worker; + break; + } + + return worker; +} + +/* Caller must have device mutex */ +static int vhost_vq_setup_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; + + if (info->pid == VHOST_VRING_NEW_WORKER) { + worker = vhost_worker_create(dev, 1); + if (!worker) + return -ENOMEM; + + info->pid = worker->task->pid; + } else { + worker = vhost_worker_find(dev, info->pid); + if (!worker) + return -ENODEV; + + refcount_inc(&worker->refcount); + } + + vhost_vq_clear_worker(vq); + vq->worker = worker; + return 0; +} + /* Caller should have device mutex */ long vhost_dev_set_owner(struct vhost_dev *dev) { @@ -636,7 +703,7 @@ long vhost_dev_set_owner(struct vhost_dev *dev) vhost_attach_mm(dev); if (dev->use_worker) { - worker = vhost_worker_create(dev); + worker = vhost_worker_create(dev, dev->nvqs); if (!worker) goto err_worker; @@ -650,7 +717,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 +809,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 +1679,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,6 +1787,15 @@ 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; + case VHOST_SET_VRING_WORKER: + if (copy_from_user(&w, argp, sizeof(w))) { + r = -EFAULT; + break; + } + r = vhost_vq_setup_worker(vq, &w); + if (!r && copy_to_user(argp, &w, sizeof(w))) + r = -EFAULT; + break; default: r = -ENOIOCTLCMD; } diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 33c63b24187a..0911d1a9bd3b 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -35,6 +35,7 @@ struct vhost_worker { struct llist_head work_list; u64 kcov_handle; unsigned long flags; + refcount_t refcount; }; /* Poll a file (eventfd or socket) */ @@ -160,7 +161,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; diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index c998860d7bbc..e5c0669430e5 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -70,6 +70,17 @@ #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) +/* By default, a device gets one vhost_worker created during VHOST_SET_OWNER + * that its virtqueues share. This allows userspace to create a vhost_worker + * and map a virtqueue to it or map a virtqueue to an existing worker. + * + * If pid > 0 and it matches an existing vhost_worker thread it will be bound + * to the vq. If pid is VHOST_VRING_NEW_WORKER, then a new worker will be + * created and bound to the vq. + * + * This must be called after VHOST_SET_OWNER and before the vq is active. + */ +#define VHOST_SET_VRING_WORKER _IOWR(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..af654e3cef0e 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -47,6 +47,18 @@ struct vhost_vring_addr { __u64 log_guest_addr; }; +#define VHOST_VRING_NEW_WORKER -1 + +struct vhost_vring_worker { + unsigned int index; + /* + * The pid of the vhost worker that the vq will be bound to. If + * pid is VHOST_VRING_NEW_WORKER a new worker will be created and its + * pid will be returned in pid. + */ + __kernel_pid_t pid; +}; + /* no alignment requirement */ struct vhost_iotlb_msg { __u64 iova;