From patchwork Tue May 25 18:05:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 447704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01474C47084 for ; Tue, 25 May 2021 18:06:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D79B761400 for ; Tue, 25 May 2021 18:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbhEYSH5 (ORCPT ); Tue, 25 May 2021 14:07:57 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:56454 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbhEYSHv (ORCPT ); Tue, 25 May 2021 14:07:51 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI5cg0108029; Tue, 25 May 2021 18:06:17 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-2020-01-29; bh=adkC/lusXAvRBza6cvEif34yOWKLomqy1QYrDWkSuBA=; b=kuSaUPBp7U86jg0/Ffhg9Z0rXdfPqe/4+ePyd402Z+VcPab8soGKX3Kvg2teSZGDjh6n YEg3NbQl2dj4K2AaSFT3xovT708r9leJwm3rzztRfoFNe6aUslGyrwFHvr5VcXBiMV1w pQv44p9STu/QXXeoN6pKpdyHYqOvBqhb/XqrloxZsx0kp749EXuhLbulww/xqLOb/9W5 2DH84NVbTXnIMw82pYF6IZSlNjuwxgWy03KZz7SAB8tdAqKOIHNZ+3i23iC9PaAHLI00 pBIv7FVb7m3i4Ivy/4ZZmX31GLsXnCms7YwMwvcNts1dACHpiTOTxv5rs/hIE+Hl16Kk BA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 38q3q8xc04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:16 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI6D78185054; Tue, 25 May 2021 18:06:16 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by userp3020.oracle.com with ESMTP id 38qbqsga75-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPE6AmzCiBYAvsw5INZUsF0z9u3/7rrlMHLxhbKYSshaaJMXUVqOQ4OkUtcPU3bdW9bDFNSnPXy4O4y+iPL7aSaUQeg4FvDEC9dmdd8PQov80ss23Zi0f4OI7kVj7XbPMrRVQPpMOg+J2PJLPBqcaKdj0U++9JpZuMB+kNWqLhkuS9nYf4KfuYVnI0GctHhr0a7nMn+7BX1HBnFj7rvyA30RTaMAk6v77TWsohLuEmQlle4/cYFb23b+6J/rDLgzNJWs+Ls7Y8l/1Z0M4DOPYoFC9aIuxBzSrqnasMiS+WExv8nAr7+Szh9/QJv1zLj1SFc+n6QFlf6G6MMR53kl0A== 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-SenderADCheck; bh=adkC/lusXAvRBza6cvEif34yOWKLomqy1QYrDWkSuBA=; b=DuVKY6l68loxUuP8aAeyXnl+9kARzHE6ZLGm6DP1fl1xHNWY8j9okvvu94f7JNuBici7vuZ9IZ3zIK62szAlcN3hAteTkwa4feeraSlAuQiPab634uBBuC2Wnygq3gmBBhyMrkEExhCfC9ywZGmu7sgDL/rCryR9l/vxpzyLj8+xZx1O0YAvfGNBi3EtY8A2LYZdEwHxqFE/+pZTWnIRDY9o+NsHWEkcNCEKz8ExnKCegRQdRCwmTgkbBb/gs/vG8baGq5QkV+7oCbpgOcinxS7z5ypEMKGJ8A6kmDtVynCf1TM8eLXtjUAl4NZHiKSnqi2Cd1t6VI3TBdAr/tO4Qw== 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=adkC/lusXAvRBza6cvEif34yOWKLomqy1QYrDWkSuBA=; b=Drolyypvtrn/a3BMn1MhOnu+NyCYRj9JcEvwlgOit/CIxb6xbk5xHCl20nvgLklusSmQOkIDOnk3OvwcrYF1PosvBKWb3fn/NcfJeJl4pAXaHC6CV0M5FD9mO1HXqdNv6TQ3a3kVMYxuNrSxKOZuT1jL8LOglQgsF2AFrQC2BLg= 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 BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.27; Tue, 25 May 2021 18:06:14 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4173.020; Tue, 25 May 2021 18:06:14 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 3/9] vhost: modify internal functions to take a vhost_worker Date: Tue, 25 May 2021 13:05:54 -0500 Message-Id: <20210525180600.6349-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525180600.6349-1-michael.christie@oracle.com> References: <20210525180600.6349-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.12 via Frontend Transport; Tue, 25 May 2021 18:06:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dcf62351-c05d-4a90-5682-08d91fa7c919 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:514; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xSJKwX+OroCDH5GR/LKnWbOUg/uIlUXRjpCn8J26MYhu+PYyWgqlUoULVJdvkuQUhC+9nsc7/AT9SSVnQVTNbc/roP0ZZX3GuoL7zNKpVV2v75Y0XhCsBlLiD8FR2yHxZb3iwPW6HpbnbId7JgGjgEYc2zE9ka0DPK+dobo/28Z0ch0ufPedr+hx1nRd4bZPk/jivqCA/LR618SBi7ptR32NOK7zczi2kDHD0SA83ZCHBb6dA/rIuu951+KCUJTHpjhnpDaOUGDFrpOZUF69DvcEvFwKcqZ9hTAHTvxjYUC3UmrqSeyZY0cqhURn7Wf1ulOlDagklemJAvQy40Nztl3j/k//H/439k80RcFUjyb3AaVvtX/VOmCEI0K4xU+krdQ/FihpbUMneiUg6ioq+vEw4ePyU27R0lgKI4d5y8BMemq9SKap55juWT3M6AJiezx0iWep1l+t4AekHYfYLGDayu1mJr7LfYv22Dj80QQvV1A/W1uEbEW9HxUM96sYoAqMLAPYVMVZoHz78FMfuoAOs4d6VgSiZLHxfnd4E8ys2BM005y6WD4A4nd9ZPM2cz8nCeugSnH8ZfK95xZg4kV1QexRoQsjeiWv0tlswPEdSMe8OZ2wmrYwa/0NZ/2880VuuCElaiMc7EoumDyu9F4cJ7cvr/IdgwBDgU0PSQoDQa1MxaiqgzSRUzmv/k1R X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(396003)(39860400002)(136003)(366004)(6512007)(26005)(38350700002)(186003)(66556008)(66476007)(52116002)(2616005)(8936002)(86362001)(6506007)(38100700002)(83380400001)(956004)(66946007)(8676002)(4326008)(5660300002)(2906002)(1076003)(6486002)(316002)(16526019)(6666004)(107886003)(478600001)(36756003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xAyqJzp0u0yP5CVIgNkU1Tem62okr0P8OHaUAigbgOWAyllMJG0YYd6+R1QnrQZpqSUwHM8HGLhIq/sSubosbdW+b5SS+ALy6ZteXyHEaSL4+2hsZnP1VZ5oWmR6z8Hvx6rVX0om/KQBV4euAZTdMdLzV54I3xrnnp4Xtz84yDoAruUyYzMoqf7IAk5JUx6v7KFiaAmKbjL4XLESpqU1g0vvWWMm2zWC22jwRA/q1BPULCw86bgNc82/QOvd9ez1XN7KHB9qt3Fx7ZjU6aZLgb9bkObnK+EGAC/o8pcr1F0Z+WKLzUZjNIiCaaOL9OyYj0jenQJv5RzU7V+7pEizj0RVlnG5gOLD8q9QxFme85bwOQgGD7Ib2xJgQRptAWJiVLb+HA1+k7giYGxBPwDuyacZzEI8jfDZQxMkcFbtc+Wq280pcS7JjWi2+lUEGBNtJZbMOdnbZ6uEOO3TuVeZqkq4J9EAvp7SWbUK4+dJ0GOS3q6dq1HeeaxX1z//SrhsBJQFgDxl2AwHIDT8RTeuWqX+PAgw5q0I7gPYTxyuBUjeX6Ak3YuNyxRKp8WLQIgL4gXaFYVCuHGl1RPrXxLQLkRb3TRu7f/4ORuNlXxfG+Xwjk+gmEu5dqtVd1BN1bSdFKvd1fh/ykfRjaQuToAZz6cdS4nJD5YnODnvQqRNTBnECZROR0MWK3CdCo+Zq4e0bNGhjMZENpm8ILsLmySZrBa4FSe60e248I2WROZXKgRjGTfVD0wVHAeUdRb00stQPINLh4RRCPjTswp3vefG3ulMVSbh4lsif8LjcmSC8g5oU2W+QtJW6A9ccMini4AapMcye+UN/iZJbbjDtmilLulfS8FHViflfEi6MO+9X3ZdKIJywbY1BjgSBxNeCBttVHzMvTraFEGWUlcFQcgf9rWjvuw2Yh9L7f0mR2a1y5dMS3JwGfnV31jgjq38i3B8XrQMlMGOzgh+/f8zGAuwOreqjvsXFhSPgOZhXvvzC9c+89OKAz2I05Mp74Ga5Kx77sdrG7WXYh/iQ/ozrRFoLtrvnGYpsAjZ4jnvIQIraRV77Sg1sHFFtEaKXX5vo2m4BZxjnmD2Iq16iiTTmJCM757QOC0J4sfDVOPmLnVITYjeoPZa+Y0LGEUZcpZl8G93Q1ekHFz6/cpW/L5803j8kQYbY+HMdXFkJgMttwtkythHRVzP21VQAgKKOM8A54AQsMsITYKqcIgdO+gUf1sKgXorU+2a71NT6qdS4GUHRyw+yYMwEDnpjmnl76aQa+GpmS45UBrRSZkXSDegMcMAIwsjZ7v9vVjqlKPYSx7lmJzXMjxYH1nHaJgInHKAWow2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dcf62351-c05d-4a90-5682-08d91fa7c919 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2021 18:06:14.5125 (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: szG1x4fGYirS8PybSeHoxl3J6Iv6VmRgaa4oLeACQmTiYfRM+M4wjezCEt487qmhN++WlNr+JmFd0rf4EEIb8kjPbx4dz6vRF++SG3cg/bM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 X-Proofpoint-GUID: xJuhYMUr_2PPhfqC9alAezf5bt7_OyAn X-Proofpoint-ORIG-GUID: xJuhYMUr_2PPhfqC9alAezf5bt7_OyAn X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The final patches will allow us to have multiple vhost_workers per device and be able to share them across devices. To prepare for that, this patch allow us our internal work queueing, flush and cgroup attach functions to take a vhost_worker as an arg. The poll code required a change to the drivers, so the next patch will convert that code. Signed-off-by: Mike Christie --- drivers/vhost/vhost.c | 136 ++++++++++++++++++++++++++++-------------- drivers/vhost/vhost.h | 4 +- 2 files changed, 94 insertions(+), 46 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index a291cde95c43..4bfa9a7a51bb 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -231,20 +231,6 @@ void vhost_poll_stop(struct vhost_poll *poll) } EXPORT_SYMBOL_GPL(vhost_poll_stop); -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); - } -} -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) @@ -253,26 +239,62 @@ 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) +static void vhost_work_queue_on(struct vhost_work *work, + struct vhost_worker *worker) { - 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); + llist_add(&work->node, &worker->work_list); + wake_up_process(worker->task); } } + +void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) +{ + if (!dev->workers) + return; + /* + * devs with use_worker=true created by tools that do not support the + * worker creation ioctl will always have at least one worker. + */ + vhost_work_queue_on(work, dev->workers[0]); +} EXPORT_SYMBOL_GPL(vhost_work_queue); +static void vhost_work_dev_flush_on(struct vhost_worker *worker) +{ + struct vhost_flush_struct flush; + + init_completion(&flush.wait_event); + vhost_work_init(&flush.work, vhost_flush_work); + + vhost_work_queue_on(&flush.work, worker); + wait_for_completion(&flush.wait_event); +} + +void vhost_work_dev_flush(struct vhost_dev *dev) +{ + int i; + + for (i = 0; i < dev->num_workers; i++) + vhost_work_dev_flush_on(dev->workers[i]); +} +EXPORT_SYMBOL_GPL(vhost_work_dev_flush); + /* A lockless hint for busy polling code to exit the loop */ bool vhost_has_work(struct vhost_dev *dev) { - return dev->worker && !llist_empty(&dev->worker->work_list); + int i; + + for (i = 0; i < dev->num_workers; i++) { + if (!llist_empty(&dev->workers[i]->work_list)) + return true; + } + + return false; } EXPORT_SYMBOL_GPL(vhost_has_work); @@ -482,7 +504,8 @@ void vhost_dev_init(struct vhost_dev *dev, dev->umem = NULL; dev->iotlb = NULL; dev->mm = NULL; - dev->worker = NULL; + dev->workers = NULL; + dev->num_workers = 0; dev->iov_limit = iov_limit; dev->weight = weight; dev->byte_weight = byte_weight; @@ -531,14 +554,14 @@ static void vhost_attach_cgroups_work(struct vhost_work *work) s->ret = cgroup_attach_task_all(s->owner, current); } -static int vhost_attach_cgroups(struct vhost_dev *dev) +static int vhost_attach_cgroups_on(struct vhost_worker *worker) { struct vhost_attach_cgroups_struct attach; attach.owner = current; vhost_work_init(&attach.work, vhost_attach_cgroups_work); - vhost_work_queue(dev, &attach.work); - vhost_work_dev_flush(dev); + vhost_work_queue_on(&attach.work, worker); + vhost_work_dev_flush_on(worker); return attach.ret; } @@ -579,20 +602,29 @@ static void vhost_detach_mm(struct vhost_dev *dev) dev->mm = NULL; } -static void vhost_worker_free(struct vhost_dev *dev) +static void vhost_worker_free(struct vhost_worker *worker) { - struct vhost_worker *worker = dev->worker; - - if (!worker) - return; - - dev->worker = NULL; WARN_ON(!llist_empty(&worker->work_list)); kthread_stop(worker->task); kfree(worker); } -static int vhost_worker_create(struct vhost_dev *dev) +static void vhost_workers_free(struct vhost_dev *dev) +{ + int i; + + if (!dev->workers) + return; + + for (i = 0; i < dev->num_workers; i++) + vhost_worker_free(dev->workers[i]); + + kfree(dev->workers); + dev->num_workers = 0; + dev->workers = NULL; +} + +static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) { struct vhost_worker *worker; struct task_struct *task; @@ -600,42 +632,56 @@ static int vhost_worker_create(struct vhost_dev *dev) worker = kzalloc(sizeof(*worker), GFP_KERNEL); if (!worker) - return -ENOMEM; + return NULL; - dev->worker = worker; + worker->id = dev->num_workers; worker->dev = dev; init_llist_head(&worker->work_list); task = kthread_create(vhost_worker, worker, "vhost-%d", current->pid); - if (IS_ERR(task)) { - ret = PTR_ERR(task); + if (IS_ERR(task)) goto free_worker; - } worker->task = task; wake_up_process(task); /* avoid contributing to loadavg */ - ret = vhost_attach_cgroups(dev); + ret = vhost_attach_cgroups_on(worker); if (ret) goto stop_worker; - return 0; + return worker; stop_worker: kthread_stop(worker->task); free_worker: kfree(worker); - dev->worker = NULL; - return ret; + return NULL; } /* Caller must have device mutex */ static int vhost_worker_try_create_def(struct vhost_dev *dev) { - if (!dev->use_worker || dev->worker) + struct vhost_worker *worker; + + if (!dev->use_worker || dev->workers) return 0; - return vhost_worker_create(dev); + dev->workers = kcalloc(1, sizeof(struct vhost_worker *), GFP_KERNEL); + if (!dev->workers) + return -ENOMEM; + + worker = vhost_worker_create(dev); + if (!worker) + goto free_workers; + + dev->workers[worker->id] = worker; + dev->num_workers++; + return 0; + +free_workers: + kfree(dev->workers); + dev->workers = NULL; + return -ENOMEM; } /* Caller should have device mutex */ @@ -750,7 +796,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); dev->kcov_handle = 0; } diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index bfc4563e612f..fa1af4106755 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -29,6 +29,7 @@ struct vhost_worker { struct task_struct *task; struct llist_head work_list; struct vhost_dev *dev; + int id; }; /* Poll a file (eventfd or socket) */ @@ -155,7 +156,8 @@ struct vhost_dev { struct vhost_virtqueue **vqs; int nvqs; struct eventfd_ctx *log_ctx; - struct vhost_worker *worker; + struct vhost_worker **workers; + int num_workers; struct vhost_iotlb *umem; struct vhost_iotlb *iotlb; spinlock_t iotlb_lock; From patchwork Tue May 25 18:05:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 447703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E54FCC47085 for ; Tue, 25 May 2021 18:06:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9B1660FE4 for ; Tue, 25 May 2021 18:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbhEYSIB (ORCPT ); Tue, 25 May 2021 14:08:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51536 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbhEYSHx (ORCPT ); Tue, 25 May 2021 14:07:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI5mqO060529; Tue, 25 May 2021 18:06:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=LcfSH+XJGNeXyrQSX3IWZ3JhXGfiut6RzDMivAGG4YA=; b=Nkn2RSruao8FMbFL2/a+kkk89wlblv0J6ItOTizUpo7jQdanvnNllZ5kMB4HYiiHmWT2 hGYe/zcnO/CPYWeeF2717fxV1XnXBPDkojThPTyIrUjFgmcJLHGvX6bLhXCBaZEsedjW t6CCv87NuHnR7Qx6I0o3QKgv2/S2o1nQwdMyCKq3Q++rvc20skZzwo4PoaS3zYK/aJbU AezyRgZh0LmBDgzVMwho2VaHGJKY4/4+VH76D3DDz33tzASBLmFnU8WNqgHmhdkwdzAA QlEnrwO54ggSp5RE7UGlzGFw6p2GcHt8FgAybVCn1eUExEEVMYF89JLowPROgraujiFx 8w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 38ptkp6uqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI6DTx185061; Tue, 25 May 2021 18:06:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by userp3020.oracle.com with ESMTP id 38qbqsga9k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1+MbKX7jp43q60cPosWFbTPI8HTjHyMPedKi2EIipW5s/aMKT6nwxoPfnjHKf7mfiZC7lKnMFLcBVBUxT21l2qyGRIDRB1tio8T8sRSJCb7/FQHIr52lT7prnRUnbYsLDtfZhm0Rydi7cDy3JZvTYPllPFel0zVuQV8w245r7u+e4NLsOGjZXueUGaxD8EAo7wVdv/NYr9OshFJlr9sDI2Ex22VmIciCFqhHy0drgXZZ4SrZmNSIOlvZheAi1eol/xgSj/3GxhH/ukV3J1JH5ACrlddObGsbPtNb+dgCCB+NeOqxvs/00GLiln6pb6/DJfOlgFyIbRzwF94+fsslw== 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-SenderADCheck; bh=LcfSH+XJGNeXyrQSX3IWZ3JhXGfiut6RzDMivAGG4YA=; b=IIi+EH1AW9nqowvqg4nphWRyVFL0pUMo2LYXbg9bI4dNtS3Kj7/WROhMUo3dyxxWFgt9a8KRYauCF/e2q1PLQUCjN8saErJ+KqMhUCBh6zm8FprFEsuXigQz7PCCgLeyvh11e5yrvQl+R9o2zxJ/oNrmQvBDUFKB/H4tdyYmVEXpp7iuDqZ8jrYvobmk/EEH6rUyrlrqaW8S0gRYTWN+h0fu1MM+8D3fghB7Y3ykkIu9mESnalfFhaY6017E8vWFWz5CBEgYr2NWrZkBQOmOOYKiVJagct3x8lhfirfpx5pHCepIJVB/rWqPQvU5tqJMbnS5C2uju30ehX1q1R2Lug== 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=LcfSH+XJGNeXyrQSX3IWZ3JhXGfiut6RzDMivAGG4YA=; b=SDZdv5v8N51J2WUiH1Hf09M77ZzsvZpF384Pq3wxykrQO8djG4WrxomIkU6lEaPBhdv4/O/SUpe2QegeYF3QxFUOR6Qfq72pzGG28oPSc0uDbq56imvtbjUpk9fIJWbZwjrr5sYs7jA13BOa5xuAuD5/TPjP+klAUBIrLwtk9pg= 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 BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3431.namprd10.prod.outlook.com (2603:10b6:a03:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.27; Tue, 25 May 2021 18:06:16 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4173.020; Tue, 25 May 2021 18:06:16 +0000 From: Mike Christie To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 4/9] vhost: allow vhost_polls to use different vhost_workers Date: Tue, 25 May 2021 13:05:55 -0500 Message-Id: <20210525180600.6349-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525180600.6349-1-michael.christie@oracle.com> References: <20210525180600.6349-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.12 via Frontend Transport; Tue, 25 May 2021 18:06:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ea78da6-24ad-412f-c0d8-08d91fa7c9f8 X-MS-TrafficTypeDiagnostic: BYAPR10MB3431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: clEyXZfxKj4XUZgYsdfdEBNL2+B39BnHHbBNFo+P0WatVuXApOQSPQx6gE/dm4oF+r6x9UDudXIhGiG0QCL0WZeuoKrUG28+YUnZY5eaSzRmlnLBEVl0gZgLyh/xeojVGL6FFP6gahSMm5LfkC5CNt9HqI1lbM2zURigVHyDn6RyOei/pK7jV1jxviRudWLSXhoGNpoxu4ms3L6C8RmItt/tmIa7QvpqgODNIYJMCYdEpeT8IcXVsQN9svz0ZqgRmul2QqsRPbNmmJA0pFb/n53X5RIrcdVMjhCi4ZIZT0cYE84S/EluZ3BClMfCpzQxvc/y1V+ypYnVtxbzi+6prSHrqkOw3z0jQXwCV/sqC88JPkZxzYRvwnNyofbjFkQgPUVRjUpBtw2eIt19bzvBzrQPuSWnfPkOGmZ9hyWmKrzT+uYqKeD3Y5Fto8GElDfMjn3Mun0GpXzTXZARp16vCPRegar8AvNqRipMvAZuf/Awt3ClvtGCNCeKNYzssb3emnG2jbZvRDkXZ4+hG+CUwsqB1uBqmS37nE+mIjzzzE8yYf0gY0p7Hq/IQ49hjAY+N/mJzS5pzwfgfxYqCZkIbQZ3T0ID4/8DX8tBCo0xQmk3gwaQ8W9qB6NBo6RdHM2Z1gnYM7FqEaC4clJKBGk7qaWjVHXsRYIqqXy6ECFDH+tU7aZOjTQO2IY3K1FZGCis X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(396003)(39860400002)(136003)(366004)(6512007)(26005)(38350700002)(186003)(66556008)(66476007)(52116002)(2616005)(8936002)(86362001)(6506007)(38100700002)(83380400001)(956004)(66946007)(8676002)(4326008)(5660300002)(2906002)(1076003)(6486002)(316002)(16526019)(6666004)(107886003)(478600001)(36756003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7FskS1m1W9Ol8QNqHH0zbgSayW+0N9pxs5WpniNGkoGrV53jyUI+rmZvpYyleZaIbY+VRkm7NIJiInoglmSM/2Cqt2/YR654driLJWVWXy+8+R5OCnj2WuP7de1jk7WmhSCwp5tFWgNb9NkvKIxa41UrNXbWWGmetEg4MAMWSIbU0xWVq/dmlap8GXGOAedhIrlMxY6D/TqHh+1+WfvCEwd+oqRR+DmPyCE6jF1SaLoUqhOlC8Gm5PKuaARPZIBWYp+Zqjc/Qz0wb10Kt/EubjazSaiekbe/aP/z6vC1rlKQ+4PbVJSkRveXyh9OzHGljCae4htD3H2s0eIIgKj4ARKvp3gZHAYGM7yf6Up05i3jkBkXYxXFJg2oG0qBicOveO6wcbjiIDixjJwqnKvO5l+nBa/1CCX/vlwNPwb9ivwhemMqpyYuMbvg9u4R0Q+8Wgx0NCTC8wyCWodYY4C3qxY1yefuyZQQb+rZvzyA2xN3PwyxnEVEtoyZiRrUMMy2HrzJ8BkY5fILFM3j9eViYBjQfqY6Qdr7/4jIIwsKffkm8p8POLyXcQEsB2SXG1WC9oiygFrraSu/y+U0u/aE9zFASy8uUQb3lcOdseArmsCyrqHJr1fatNn+77KixD03IfywUr5AyMgldynFbApHMEHy6lr5OUsXTziG0PbVbaFtl+M3jR9RKJHupHT4Fn3ijF59UZbRY6rEzVJw6fzVZAHnFwKaQ+fmYgeLU9MDsfMc5OX0TJyGyeYDAlL9GuqKd1MmcyPo8/KJ7t/bfbHg9zrYEYLFCkud92ol/ujJZSFohO5tugWQMBiK3Su7pk5WRAuBI5hdCWe+0Yy3hUA5QG6fH3pqaZvf8RCUNhOk2QKgztjGJsL9jppD7u3r1j5pWs1gXmIlEZ7Tc1v1QiEI6Sb4jBtfKfm/Np90d0npg/dxejHrBNgoZ4GuHrLQcA5AMpBVB/mfgS2FVu9Q9yN8SxWSX9soAcSyeGIYj+ST0+0M2N8e98pDcuOWui2Z4JhWVnYilTBx852QvQQPwmwbpC9pHI0Q0RyOzFEmV06aDxv1MgbQ2y4uhuDZke+uFQ34s9ruHIdlcxOiHl+IbvUvkCoEiPpXaKp32JfdkqhICsrNheFrhsLJSRmHU+JA7qHdwU6bYEfKrVTSmVQNcGdmlZnjNuFemY3iYHs/Dqzob+Ti/ScyFzqgGsEYm0d6prfh4NQAeDVlm2Ta/Pa2WGGVInNaGuoILOgpQMd+X7ptK/SecHL5zF0gQW9OT/ipB5NbqPsNqJdc24+R/T7A3v8J+kUBBj9MuyiF3Thpy6EjMd38iS/WH2g53TyDCuQ7NZAJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ea78da6-24ad-412f-c0d8-08d91fa7c9f8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2021 18:06:16.1456 (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: T8Iq096rX50Lr3cSBd+rmpcqW2oiuo/hteHLyPdQA3WzJVFFU7dPN4X4EgTamCZM+IErlfmKDoLOMuOeq5WANTdIABq4AVYCE/gBj/m7Nmk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3431 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 X-Proofpoint-GUID: wDukkXbXR0u_4V5LcnlE2emKSQl3FE8i X-Proofpoint-ORIG-GUID: wDukkXbXR0u_4V5LcnlE2emKSQl3FE8i X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This allows vhost_polls to use the worker the vq the poll is associated with. This also exports a helper vhost_vq_work_queue which is used here internally, and will be used in the vhost-scsi patches. Signed-off-by: Mike Christie Reviewed-by: Stefan Hajnoczi --- drivers/vhost/net.c | 6 ++++-- drivers/vhost/vhost.c | 19 ++++++++++++++++--- drivers/vhost/vhost.h | 6 +++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index df82b124170e..948bc3d361ab 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -1334,8 +1334,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 4bfa9a7a51bb..3cc1196d465b 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -187,13 +187,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); } @@ -298,9 +300,15 @@ bool vhost_has_work(struct vhost_dev *dev) } EXPORT_SYMBOL_GPL(vhost_has_work); +void vhost_vq_work_queue(struct vhost_virtqueue *vq, struct vhost_work *work) +{ + vhost_work_queue_on(work, vq->worker); +} +EXPORT_SYMBOL_GPL(vhost_vq_work_queue); + 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); @@ -359,6 +367,7 @@ static void vhost_vq_reset(struct vhost_dev *dev, vq->busyloop_timeout = 0; vq->umem = NULL; vq->iotlb = NULL; + vq->worker = NULL; vhost_vring_call_reset(&vq->call_ctx); __vhost_vq_meta_reset(vq); } @@ -527,7 +536,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); @@ -662,6 +671,7 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) static int vhost_worker_try_create_def(struct vhost_dev *dev) { struct vhost_worker *worker; + int i; if (!dev->use_worker || dev->workers) return 0; @@ -674,6 +684,9 @@ static int vhost_worker_try_create_def(struct vhost_dev *dev) if (!worker) goto free_workers; + for (i = 0; i < dev->nvqs; i++) + dev->vqs[i]->worker = worker; + dev->workers[worker->id] = worker; dev->num_workers++; return 0; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index fa1af4106755..6880e7a29872 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -41,14 +41,17 @@ 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); bool vhost_has_work(struct vhost_dev *dev); +void vhost_vq_work_queue(struct vhost_virtqueue *vq, 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); @@ -76,6 +79,7 @@ struct vhost_vring_call { /* The virtqueue structure describes a queue attached to a device. */ struct vhost_virtqueue { struct vhost_dev *dev; + struct vhost_worker *worker; /* The actual ring of buffers. */ struct mutex mutex; From patchwork Tue May 25 18:05:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 447702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B1F1C47086 for ; Tue, 25 May 2021 18:06:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E89F610A8 for ; Tue, 25 May 2021 18:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbhEYSID (ORCPT ); Tue, 25 May 2021 14:08:03 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:56494 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbhEYSH4 (ORCPT ); Tue, 25 May 2021 14:07:56 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI5cui108028; Tue, 25 May 2021 18:06:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=v7Y+n/zT1DDY0nuWoiVGIYe7ZPWqvETQLL/RfPoiY+Q=; b=YLJFzUxT8mDxtnwAuVR4EJo2NOeJpEURIdnE1HAHGEoItQRZK6dbFQzWMZvrdytCx+L0 Dp1ZEzbQj49PvR3EZUB6wB7PYRX2vQSV/YCECO9fLNhgpK7TBFZ63X1Gt/2PO5KWlsJP rAK+iQfdrjkHmhUA9ymf6weN329SMe3jYXvH54Z4BJoOjOfKeTRg+96pVsINdgpRp6M/ IgJKV/Htpkxx+PTH8Hxjm6Rd9ADsUvGj7MFRIb8nA6gTkbhkMaoSEUvEiF+mGxduMXPU PDI6Dk6RJPKPDFo2ueIHhra3Kyx1s11rh/UdeOwcAyfuzWZ8fduoaWimEBLCjlucs1r/ Fg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38q3q8xc0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:22 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PHosu2021990; Tue, 25 May 2021 18:06:21 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2043.outbound.protection.outlook.com [104.47.56.43]) by aserp3020.oracle.com with ESMTP id 38rehapck3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKvlC0286aw6oA6cb76wLHGRaog5IesfPm+TVk++PaT09TNlUwQOuS51/RcohjmZjZA8yMAeJRL7VnxetPN04gB8yY38o0E1i1qMqecDesPmDGuwylmyLwmCnBGw4WVb5NgHmb64JmRSv+rn2MnKa/JMnwKdP0CyjLW5OAJR68vJjMo2QXPHsH3B7k+N6MpUWTkASYWWw8rQYMK+7vuJrnmGW8JoUcje3x/KGcqMupuVxptnCn2AvPbVwoJt+OwsrCJFemWBHi0cnTzLXxrldyS15MbESwcsfwC/Bm+WvmkL3TFiTorkL/98K6nzFt1JEq5k9lGHiD2p6Ueux5D4Hg== 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-SenderADCheck; bh=v7Y+n/zT1DDY0nuWoiVGIYe7ZPWqvETQLL/RfPoiY+Q=; b=QzxlUJWAg//KhX5/FZNHFaogGI66yipuhLbUcdpBSmfkIfg4S5tEFznXO6gXzOy6yEsb3Ap7C+fOjXKH1CXQZuLWV/zijaZvcDKgdrfkm3f5UAbyBlWnRFOnIesQLtmo2AcmM9pGey9K55k8vjHqx3TcNqYRcg1j8qW8OsIaMsQa/E0k0OHPCBTvI7dBm7p4Zz4AmKj5lEwvQW1M/vVmaDxztORB1/gNzxUAttXyVy97KE5JNJBKuXL9ejA2v40NOLYbe96N1zGKjizyKFlw077eZBrkNNe7eGm3hVJJthBclpDZvc61z6XIXsfXycGmBYtm9kENXyZuPUAoieRo5Q== 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=v7Y+n/zT1DDY0nuWoiVGIYe7ZPWqvETQLL/RfPoiY+Q=; b=GSPr8SCG2UUDdO/G2tOSeAKz0Lvll2Bh6DMI4jwEl4BhK41x+l9VUg8CgTIq98N4dqcx1qvCU0N5ekXte0RLhyRgHjNZzKRZqfdR+ebu344pqiUMARkom+L5ZwS0usQnrJ8KYOmnanlKA6wzBqvIdytw5wpdRNIKcVb+JlnOxFo= 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 BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4639.namprd10.prod.outlook.com (2603:10b6:a03:2db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.25; Tue, 25 May 2021 18:06:19 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4173.020; Tue, 25 May 2021 18:06:19 +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 6/9] vhost-scsi: make SCSI cmd completion per vq Date: Tue, 25 May 2021 13:05:57 -0500 Message-Id: <20210525180600.6349-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525180600.6349-1-michael.christie@oracle.com> References: <20210525180600.6349-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.12 via Frontend Transport; Tue, 25 May 2021 18:06:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f339426a-300c-47fe-c510-08d91fa7cbf9 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4639: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TWaRqwwVraO15lVxJbxNMyE6ckk58xu2MX/zU2FltQGmD42KkWzUqlLG3O660+4sL8ootdie+CbqNQ9mu8lCXvM/a4Wa5AxJy7sTJ898k+BZic/mSpwwb9ua+src6L4o/H2v2ggyf/v9IrIX6j832Y1Nx5Pw75ewBAHLl8q9v5PFlqqzFwqzrcKOHZuix/oV7+E80BcRCLLoHXC6GHiHgLJJggWt01JbRvfo/zrXhXUqXMQT6zOBoTrTvbPqeqVHf70e2iY0CHoN38xzrtPOkuUK6p+rhT/+U6YYJRhLVbMnA8iqOHbkaDDKnEChbGs3xaxwrD/G9hj+PLr1oSs2WQ8MJmlDHs6jphwWY5i3/GQCla7Ei/S/ZZtJ5yNiH2BY+vqyvqvnDxe4OXDItKwnjUkGjac53+Myv3ajginiJCjPbBhH7n3VypEbnAyQ7++Q/xZPBmVrlVdbZ7n6zjbaKk4+Jp9D8v22B64Dz6pF7c6fkNHSezdwZShBQuJn/DwhGpdn2nqgTZQNr/WYS71q9GXM9cYJkYlIbzBm40inb7inRqrDflPGEun6ph8pTPaS5hLhLgOjlrKlE0UOyU6aEWE89KbSixlJMsTxh2EZx11mpKUPvs68FdMsLAbWnKdIo72IRDwyX0NFQuGsQCR6WJackmQVSfxv83AIh3IOrYfmGUzU4pLmmoEpBcOYRsg5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(366004)(136003)(346002)(36756003)(2616005)(83380400001)(4326008)(186003)(316002)(6512007)(6666004)(6486002)(1076003)(8676002)(16526019)(478600001)(2906002)(52116002)(66556008)(38350700002)(86362001)(66476007)(26005)(5660300002)(38100700002)(956004)(66946007)(8936002)(6506007)(107886003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kak3ADUNYZj9q4wf5evOgAxpRNG3zT4Zm8rMM0OdPWTvMljNlFJcHWlyq/TfHr2Oz4tsGsL91F8FBOh5HwFO2g6iLTEOZtb43mFYrVNYhnVI1EdQHK1XHk26mYzv37L9ki5ejoC1PLbV45+6QIZ5kVnEQsneMxKr4jGt6jWK+4OCFpIIwlkMbPzfsbjFkIsSqOGt8hSBCgyFnKi7n0RApVJGy4/Hl7fNWEdAywHJOAIMOZrsLUAsQv09mKIGbUoTWf8tnLUW/Pr+B2p+i0+WdtKnKxks9MyA9Lw/rdKwoRhdK2jRp5BkvZmgUDJETgJmatVxVdoP5MqdC/87gElS0GKS91r7Vl1SOtxEWy15XmqaHlstFMZvdSSNXHIuv2CZD7dJYKY8+SuvVwwZk3JydPcBtoKLpQuy4ecSBtRjZm69FDg0jNRTLnOVZdqGrfulTIRhQB1YVMD2XGxA6o6T5HDIwfECqM3oHgJnzkQCizLoDeIX1LZsV9i5De09/ejN0p3HUui7iqBnMLRyXqYwNsQmNTkt07l4X3/3uIZ2l3Aq/HCV/oEoCexi7UszchQgLGq+f0t9O1J5TAkw6pzZ6cxW7jV0B1K1GNUESPlsleY206zALAcjiSztfXksd40D8hs2oTqDXTcMOWlAk8HTAXFtqC1KWJvYo+wliS8QtDWXEpOy39M9HL7UfvYPCs2iESuKE0+fjXuq1xqITcjb5wlmWjGVlv/8Rpmt5J1PiD3eoTHaJLgWGNnQCpKnpO4Zvp9fUEYcnhP3B5Du6Qk/Xv0cZZ4wroY56T25bUvv0vkV+7Yh0rNsVigl6/hwJPAN3iQbetKAStKD95kkQ81UB776y0FuFx8raKDcheW52L3Cri9+aU5RkXisd2uhiUaBRSHsQfDBpXVdtHKYr9bxtIDKwAI8fL2LltxjgM8wRf7jdIT3ReBFu6EKM2DgwsJQMRRINsP6110vSEPGFt7BX1YfmaDH07FKxHPD/CDLl5h+PET9VRGAUGTFgXqYGIEy6i72Fh6vhWGaIgpedNmkwSzvFMq3ENcOcxt2gN4MU42MGAPxHP4AxzInibsN6Sm6vw3rtqV1gzp5L7m9F5+NtRBTHMCQfgS+oht98aPzGDb0edwZz0IIWQSZp4wXcX9z7HWVXJCUgqlhNrpe/8liN5S4Ijr0r5cd+Q+pY6nPP0m7PaBI8j/SM+i0Jcjo9iyIgE+WZ6Lh0fWgMNzhsaBqYEovE9HV9H86pUxIGF8z8+ABuWBRN647e3hq36vVdqqBD7tQGq8duvdbrf3ISb/thnMbPRoHLDw1R36Wpgkw4PJTU5cOSOoRlheCn3Y4Fz5a X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f339426a-300c-47fe-c510-08d91fa7cbf9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2021 18:06:19.3518 (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: 9aLcnVk6h063kOrIm61+AwLXd26WIpRrk6DqSVGu5kLHHnktL5dNb8gTLQHbW4LP477KLGihmNMADA4R0ixYQItYZ+tJWtzknwg3nxo+vz0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4639 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250110 X-Proofpoint-GUID: 5chjdaacP6TVIkVK4PqoEGAhmu96sGU4 X-Proofpoint-ORIG-GUID: 5chjdaacP6TVIkVK4PqoEGAhmu96sGU4 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 patch that allows 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 e585f2180457..b607bff41074 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -176,6 +176,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 @@ -190,6 +191,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 { @@ -200,9 +204,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 */ @@ -377,10 +378,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); } } @@ -543,18 +545,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; @@ -574,21 +575,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 * @@ -1799,6 +1795,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; @@ -1811,7 +1808,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; @@ -1822,8 +1818,14 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) vs->vqs[VHOST_SCSI_VQ_CTL].vq.handle_kick = vhost_scsi_ctl_handle_kick; vs->vqs[VHOST_SCSI_VQ_EVT].vq.handle_kick = vhost_scsi_evt_handle_kick; for (i = VHOST_SCSI_VQ_IO; i < VHOST_SCSI_MAX_VQ; i++) { - vqs[i] = &vs->vqs[i].vq; - vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; + svq = &vs->vqs[i]; + + vqs[i] = &svq->vq; + svq->vs = vs; + init_llist_head(&svq->completion_list); + vhost_work_init(&svq->completion_work, + vhost_scsi_complete_cmd_work); + svq->vq.handle_kick = vhost_scsi_handle_kick; } vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV, VHOST_SCSI_WEIGHT, 0, true, NULL); From patchwork Tue May 25 18:05:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 447701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90FFFC47085 for ; Tue, 25 May 2021 18:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 785EF613D2 for ; Tue, 25 May 2021 18:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232410AbhEYSIG (ORCPT ); Tue, 25 May 2021 14:08:06 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:56508 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbhEYSH7 (ORCPT ); Tue, 25 May 2021 14:07:59 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI6BGH108199; Tue, 25 May 2021 18:06:25 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-2020-01-29; bh=jNoPSS9OR1afYGivf8txMPOzzrt/zQAPB8PnBy4NwRs=; b=rD0DiOzTbN5AsJIYvW3bcrVXpzEiUhst4lcMgkKlaSa+bODrZH0m+Ptw41e5xvXKBNPo +iSLEqjRKFWyUvwsBKRvQLve5eVyVI4lzDzmDWd4VOBWLfnotu7EbmTg8PkN8VzhYuM2 9bHHcc/qQGK1VJSQ0LONKbyILyDj3vEuicZTzIF0zPG0FT355rqrh8tfAvwnKrzWyoyA 06wCLNFDCvaD9C2m2oSeftHN1TjfMzLbDNCgKfuif29HfZw2GXt2JkT7+N2JP+f7r38+ d1BB5gfqHB0oGfGWMkb0KonEDDMD/E7qMyxIxYSJmMp6ICh2NolaM3dnlRE4Q93Vnvxf 3A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 38q3q8xc0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:25 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14PI63vf094406; Tue, 25 May 2021 18:06:24 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by aserp3030.oracle.com with ESMTP id 38pr0c0xub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 May 2021 18:06:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaH7+N5B8bX3jO/2X90JSa1f4clH8KiPBmKwZWsBlPquMbs7S6vfIzQ0I+UFGIiqZeL1EN3CahPk/OGw83UzjKjKXF6e0I6RO4GTXdNNm8eU65zdHVFendBRhSTiLA1E7wsiTV2glYWnln+JYXxGXBHcgWyAX1YalG1bfqVpHoMf3ypsWmgFcd5FwjyqalVMmii5MS3d7t1S3XEsmpV+TNNJ6KY+y9++dEbzGNAWf3WNdVYYMR2jOnU5aJvSRFNCO46smXMab66egUIR49yggjoiOL/oPm9hkcQc7z9mo1KL8FmhPwuNwVXkGLr0NI9XRd0ujo7vlNigxezhSIRy+A== 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-SenderADCheck; bh=jNoPSS9OR1afYGivf8txMPOzzrt/zQAPB8PnBy4NwRs=; b=K0SUzclFkhILEEZJrh6GcvJNHsaarnQ0r+6KkzKpDfai7yvfaAGmuB8NnhwMY1FaNRLGTMgepZZPQlw4U1H1RXpPr8ZzIBS924QD9tcMszZqssOk/za1ybPVIT5QoolvbZgzF9wcj3f4sYXbyRWx11IngewPTHWOYu14tcNxd3AI01gy2U9ROiTmGwW5nYUpatit+kaxgy7OD1Yc+SnRtpeqjWiS2aZNgA5w6ydSpoNUZ6r6/v/5IiXXYYTAyWDQEJgwOAHxWKkJql9PP4Rqlzf9uskDhAbewkzGCZZhnBnlzttmRTdw379b9kkhSjVnslpi2yKV0URR7st/ryDN2A== 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=jNoPSS9OR1afYGivf8txMPOzzrt/zQAPB8PnBy4NwRs=; b=s+EgbGvZTS8AXO7xyCasBeU15Jsomb6faYD7uvdsnO2SBdAwodt4HzNvOnnRzrCDkpp5TP1XTKtoiE+abeLUhny8xD/RbIotmIIXX3Ynf3lshday2e24p9OEauNZH3WzMEWIj5ZDwP0k+LcKJFfppUw0IjhTEsKt2huHJZDDa7I= 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 BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4639.namprd10.prod.outlook.com (2603:10b6:a03:2db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.25; Tue, 25 May 2021 18:06:23 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4173.020; Tue, 25 May 2021 18:06: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 8/9] vhost: add vhost_dev pointer to vhost_work Date: Tue, 25 May 2021 13:05:59 -0500 Message-Id: <20210525180600.6349-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525180600.6349-1-michael.christie@oracle.com> References: <20210525180600.6349-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR13CA0021.namprd13.prod.outlook.com (2603:10b6:5:bc::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.12 via Frontend Transport; Tue, 25 May 2021 18:06:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a44b980-049a-42d0-3128-08d91fa7ce3e X-MS-TrafficTypeDiagnostic: SJ0PR10MB4639: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:291; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 14MhCWrYnmrOerTB/xo9jz4W6X+Hbhp8ckBN8heH+p9+6wckyRGRqlQAfE4G8YgKTZ5pSjWfKzovSI3wSeH7bLPlErIdOicX48dRR876kaawHEjzvkZ80zXtgWpYAZrufg9gmIjJAC0DPgEkaph/EzDQfjmjK1wTyV7NQkKelQ7ttFIJwLf736DX4YMKbS76RRld03qhXQUyn5g4pvfgx9kbXiwj5OSm/U+nIc7olhjChuO3qYt4IMVJZlbUF05oOhGtinncSqQkQ+/w/heC7Y67wigyYs1CyFbqRSHvdjBQuyjSQx4+8px85sV7pFdJHEinHObjD0N/SgO9d8pxUjGU4907IXfCCZ4oY40iBqxuN0olbhu6aNHxq8nthstIid5fMl++qoOs5YvzbcK+d0DAqj79fpLWBXordqjwt5DzGwNdNYTdGaAUDjTYctq/d0jH+w/KLLhXNASVpzfe1wLHyp9gtW5zglk8D7NbwzQ2E1avQfdAez8gxWbwgwW/uhVTzPZ+3vr4O3ICMivQdR28HS7By8PO8J+COEtmA80eIQVr3Ti4ndeB2iuvwgAdlSyGrzyR3z1ZeAzUnCoE7fPGa/eG/0rLmf2Ghe+xvThV2kumh4IueByPf6B+J6BliVBU/7GVdtLjZb7jhvIkNwGs5G2XX0KUJD5isbN4KRCbsT7HEuh6cOBWkhfGQ4+c X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(366004)(136003)(346002)(36756003)(2616005)(83380400001)(4326008)(186003)(316002)(6512007)(6666004)(6486002)(1076003)(8676002)(16526019)(478600001)(2906002)(52116002)(66556008)(38350700002)(86362001)(66476007)(26005)(5660300002)(38100700002)(956004)(66946007)(8936002)(6506007)(107886003)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cJAoJS7YA4ZINs0M82eBteIXyUa5av1Q9j7OoA0wbIb1aP1uCMrA45UKYxEAVJe2Bm+ANos59BlXPg+C8rJwhP7iUjwqre0+sJSuK2pU5Ijj51IpG0uwPb/5nu9IGllF7hWL/+7Qoxn7/Q/B2BbEJOaxA2dYEE5DJkLJRMm2JCiDU4Blkpf6DSMQC/rsbCFjFtErXsz9RY3yUi5aYFcbsutS/5WGKrm3243aQ/ZiGJRt6+cnYCC/4ztV7tMM8v8u2cuIljdNROSrR4dhSgdDT65VPETHS6T5S2XkwETYeNnvxQ0iog2nQelpEITeiHdvSoyTgXwy3GMa+MFoDZuh0PJEdIW4HFZojgy2z2ycxWJ1vaZov1AteZ5/+rvP9oHwuaF5IX56tvAop6XQeihzaZYOE9WAjh4FxfKXN8J7QP/OsYBJwMylO4CdTK3y2Tb3/9nzE0f+3zdxMoFitX8a7iope2fnabqp1HMIQvQ5af9hc0VoASxd35T8JaiMmcuao1AA8WmHUfBJDMZ9C5UlfQGUc/mFWXN1jwsb+7VfODbksVABZOqIrmIw3Txj45EuyNkQY24V/QLxfaJ2FXA2LXK35JELApgBjD9VIlUPwtP0qZMUGsJfDgNiw8iY58/VgJmv7Ov6cgzi/L7yga3iiW9JzuUwWc+5MfSn7GJ44S9+vPdoggX0eItNXcnTxsGtNTQIUBE8kybvG3r3CXeohrO7Dd8Oiq10FlHz7nz7D8+NKPEVfGqKhjZFIPA8hhI7rrI58YIDFpPAWop/lf/5ZZke2u71Bql5Vqubr7YPHcl/l5ei9RHWBopcRwCULoxFiLhQQH+L0i/V3aCgspHBCy4bd6/Q2hzFArM1s18LZrF0lw+mapQqWvVsnHHMm/LaKQJjG+dg2JrX4iho0FhqYlX2vajS2n110UmEMkyzuMfHnJ8kmUrSoZvsii4SxWW7VE/7PhEO2SCRDwtczcUpK/Kyc4LSwBERRIsR4oP7ePvXyrb5UfrFUc59Dl4u+Ymoo1fharqt1Vvk6aRBM7RZwbXqhxWcmevY/Smnyq5NYSryQ8yzI2xS00QhhUkiCPDyAkboQqnqwlTq1H1H13B7X0Z2W30FpJPnemt/DpCCI5oO8AHgxLTeOzj9vcjIBXqFwNFGHzd9lxrNvuzxsxVdD5sFDn/LnJq35P6noyV75mZ92MCmvUA0pBCUkCeaxBUAbCWskJd0ptjdV0VoVxYTefAW9Oe0h9qdLwmSJ58ADEDl59PW/l2qh66xuuiWvJAsGA8KbvtOnrizYDz9GU4ccJuKZNpaavwXdue/mYEFhsGHgcEfGFuURURevqgGH9b7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a44b980-049a-42d0-3128-08d91fa7ce3e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2021 18:06:23.1516 (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: uLh+viGjj9PYhXLI/HmywHqKIjNAPzVPY54IA2vy9/H/pEoSjNyrXMXbl5aOZ5xYcZua9fvOqd4pzHCL8i9jIiAXfsabaXkWkqYqSXp4Z0g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4639 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 X-Proofpoint-GUID: Nr6yb43KqpaReSeoJ46Rsod6Oaj-CrsM X-Proofpoint-ORIG-GUID: Nr6yb43KqpaReSeoJ46Rsod6Oaj-CrsM X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9995 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105250111 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patch allows a vhost_worker to handle different devices. To prepare for that, this patch adds a pointer to the device on the work so we can get to the different mms in the vhost_worker thread. Signed-off-by: Mike Christie Reviewed-by: Stefan Hajnoczi --- drivers/vhost/scsi.c | 7 ++++--- drivers/vhost/vhost.c | 24 ++++++++++++++---------- drivers/vhost/vhost.h | 4 +++- drivers/vhost/vsock.c | 3 ++- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index b607bff41074..073b20bca257 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1808,7 +1808,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) if (!vqs) goto err_vqs; - vhost_work_init(&vs->vs_event_work, vhost_scsi_evt_work); + vhost_work_init(&vs->dev, &vs->vs_event_work, vhost_scsi_evt_work); vs->vs_events_nr = 0; vs->vs_events_missed = false; @@ -1823,7 +1823,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) vqs[i] = &svq->vq; svq->vs = vs; init_llist_head(&svq->completion_list); - vhost_work_init(&svq->completion_work, + vhost_work_init(&vs->dev, &svq->completion_work, vhost_scsi_complete_cmd_work); svq->vq.handle_kick = vhost_scsi_handle_kick; } @@ -2017,7 +2017,8 @@ static int vhost_scsi_port_link(struct se_portal_group *se_tpg, if (!tmf) return -ENOMEM; INIT_LIST_HEAD(&tmf->queue_entry); - vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work); + vhost_work_init(&tpg->vhost_scsi->dev, &tmf->vwork, + vhost_scsi_tmf_resp_work); mutex_lock(&vhost_scsi_mutex); diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 981e9bac7a31..eb16eb2bbee0 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -182,10 +182,12 @@ static int vhost_poll_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, return 0; } -void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn) +void vhost_work_init(struct vhost_dev *dev, struct vhost_work *work, + vhost_work_fn_t fn) { clear_bit(VHOST_WORK_QUEUED, &work->flags); work->fn = fn; + work->dev = dev; } EXPORT_SYMBOL_GPL(vhost_work_init); @@ -201,7 +203,7 @@ void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn, poll->wqh = NULL; poll->vq = vq; - vhost_work_init(&poll->work, fn); + vhost_work_init(dev, &poll->work, fn); } EXPORT_SYMBOL_GPL(vhost_poll_init); @@ -270,12 +272,13 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) } EXPORT_SYMBOL_GPL(vhost_work_queue); -static void vhost_work_dev_flush_on(struct vhost_worker *worker) +static void vhost_work_dev_flush_on(struct vhost_dev *dev, + struct vhost_worker *worker) { struct vhost_flush_struct flush; init_completion(&flush.wait_event); - vhost_work_init(&flush.work, vhost_flush_work); + vhost_work_init(dev, &flush.work, vhost_flush_work); vhost_work_queue_on(&flush.work, worker); wait_for_completion(&flush.wait_event); @@ -286,7 +289,7 @@ void vhost_work_dev_flush(struct vhost_dev *dev) int i; for (i = 0; i < dev->num_workers; i++) - vhost_work_dev_flush_on(dev->workers[i]); + vhost_work_dev_flush_on(dev, dev->workers[i]); } EXPORT_SYMBOL_GPL(vhost_work_dev_flush); @@ -306,7 +309,7 @@ EXPORT_SYMBOL_GPL(vhost_has_work); void vhost_vq_work_flush(struct vhost_virtqueue *vq) { - vhost_work_dev_flush_on(vq->worker); + vhost_work_dev_flush_on(vq->dev, vq->worker); } EXPORT_SYMBOL_GPL(vhost_vq_work_flush); @@ -573,14 +576,15 @@ static void vhost_attach_cgroups_work(struct vhost_work *work) s->ret = cgroup_attach_task_all(s->owner, current); } -static int vhost_attach_cgroups_on(struct vhost_worker *worker) +static int vhost_attach_cgroups_on(struct vhost_dev *dev, + struct vhost_worker *worker) { struct vhost_attach_cgroups_struct attach; attach.owner = current; - vhost_work_init(&attach.work, vhost_attach_cgroups_work); + vhost_work_init(dev, &attach.work, vhost_attach_cgroups_work); vhost_work_queue_on(&attach.work, worker); - vhost_work_dev_flush_on(worker); + vhost_work_dev_flush_on(dev, worker); return attach.ret; } @@ -675,7 +679,7 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev) worker->task = task; wake_up_process(task); /* avoid contributing to loadavg */ - ret = vhost_attach_cgroups_on(worker); + ret = vhost_attach_cgroups_on(dev, worker); if (ret) goto stop_worker; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 75b884ad1f17..75ad3aa5adca 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -24,6 +24,7 @@ struct vhost_work { struct llist_node node; vhost_work_fn_t fn; unsigned long flags; + struct vhost_dev *dev; }; struct vhost_worker { @@ -47,7 +48,8 @@ struct vhost_poll { struct vhost_virtqueue *vq; }; -void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn); +void vhost_work_init(struct vhost_dev *dev, 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_vq_work_flush(struct vhost_virtqueue *vq); diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index f954f4d29c95..302415b6460b 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -648,7 +648,8 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) file->private_data = vsock; spin_lock_init(&vsock->send_pkt_list_lock); INIT_LIST_HEAD(&vsock->send_pkt_list); - vhost_work_init(&vsock->send_pkt_work, vhost_transport_send_pkt_work); + vhost_work_init(&vsock->dev, &vsock->send_pkt_work, + vhost_transport_send_pkt_work); return 0; out: