Message ID | 20230228094110.37-9-xieyongji@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2918866wrd; Tue, 28 Feb 2023 01:52:31 -0800 (PST) X-Google-Smtp-Source: AK7set/NsXr6IsEbkfk+N/uYI932GSVQnq4IZtHfiHa5tqvH+ANU+btW0Ppzx5hEnFw88zecS7mV X-Received: by 2002:a17:902:e5d0:b0:19d:1bbb:3547 with SMTP id u16-20020a170902e5d000b0019d1bbb3547mr2954430plf.43.1677577951306; Tue, 28 Feb 2023 01:52:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677577951; cv=none; d=google.com; s=arc-20160816; b=QQu7GzfPEPE/H5z698bw2HXpB1nUf6/ldiGRzOVftUR8wptqMdikWrYca4oDrTiZWo psVsNE+NmKgBraGN9nnIp73LzCwhTIPZOvPdwKUP+JnYJjS1naQIFSb8YGmfbYogS857 XflmFx4zuIZcRvdYqXhY++7ABkRdok+7EoSosEIcEXtrJx/N5cpcBRxiog2IdgcNcLVG jaLH5i3DFgBzB1gEiopm1zkRsuMWrvKiOcqY/1TEpQ4Inq7XrFkaDiDdPRPyLhvtsIb6 N9Z+mgJW4ga+21/whKhmI7Sp19FAtORlQ9ai8GeA4c14B7bcswmUylJEdQLzTE/ajzG6 y9zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fwy2X+T9chZ+5E4FxXuZFD79e/GDnXtVfCKv0Zjao+M=; b=AxiFRICNF1qGbD/pSk5wWemJHq6+fhrvMqBsgaU/qfjUXjkD+dxFe/KhWPQnXoVG6c UesXZYyFlMKWcHXU7duVPbB/IMKZorlqObgMCY9DjFThzqKfEAaEB87WwcoLTX2hwHFk r2L7wTN+BppzvMt2xrAHAXareQ4ZcWRUyayO2do5YulF/9ALGmEROkLrfK61qCvMGbuK Uidl6HpiIXlbs30ltA7jpeaS/7U3ZYywoAKZExHQcjJgS8TCChxWP+nkSR/ch3Tu765B efF5x5gpgKqG3+jqgXzEtPg/yJPezN6jgG5+U02Db5+cN3GFW+4uXtDrGYEJNFc60sw5 gHXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jPaZx6FG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a170902a3cf00b0019a80b2e956si8884765plb.412.2023.02.28.01.52.18; Tue, 28 Feb 2023 01:52:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jPaZx6FG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbjB1JnU (ORCPT <rfc822;brysonjbanks@gmail.com> + 99 others); Tue, 28 Feb 2023 04:43:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjB1JnH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Feb 2023 04:43:07 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BE62BF3F for <linux-kernel@vger.kernel.org>; Tue, 28 Feb 2023 01:42:38 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id u3-20020a17090a450300b00239db6d7d47so1896806pjg.4 for <linux-kernel@vger.kernel.org>; Tue, 28 Feb 2023 01:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fwy2X+T9chZ+5E4FxXuZFD79e/GDnXtVfCKv0Zjao+M=; b=jPaZx6FGDOnufngtQJs1CiF5uSwt3y/7YA6kvxHdmJgkmE/5wMiCxi0w8w5IPdsqju Dr5Gyw2DOq1Ju5u/eEX3lfLM8AmYZeLkCmsh/CLI+NgOMtrJtTvfKACUtsRf7Twr+N8n DZTBXIRcVgseIXNnmxfknJ5hBHTvrugOkiG5yeHDY54a4u3cNLSR8P3m/WoB2NYLb28z jJkvMTTI8x3YIKBFw822javuDEecXShcaINxzGoNWsJ77Cjyhxlu40U0a8g9UfNk9Fc9 X8vNY2K3GL2Yr/JR9HDBRcMwuV7zzSoPMFiNy5bB5bnbjjUSgymJ9xYMKuqrRwGk0dFX SwJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fwy2X+T9chZ+5E4FxXuZFD79e/GDnXtVfCKv0Zjao+M=; b=UcSFOeTYDbWuBnAzK5MKoYfQ+1WJDIjd8ywqHMRZDeGQl2cpbD604HkzydyLArnst+ 6ym4pE/8hz+gib+vKfCNbcj7+xI4OnHqzCJvFaYsEHWER5kfq6ON5O9JERNKHB/6m+0E 5ctJT4dIqw9DWNtU3+JIYrXmz19fyefXUrpKl9HB4V7LA+rZs9rxGNbsGmzri0hH5gHG kEe4XjeuLXnsXdkpXmPj1zj6KHSxRBwHQfFyRTkYMFvsIKxndx5qnN1DNEuw2vddO4ei X2DRrz6FIW3xhmUHf7zvPZWfFd7t7eVbTzWjG0pB9bgGz7maXiAXxxl1BMfC2wsIP7j4 1cPw== X-Gm-Message-State: AO0yUKXfq3zRiS5lVWASxXBC2ER1H3Ljsg1697S22KgXvRr0K5sxY4HI GzhxxXcdUMR1l7bVVMVwd0Tn X-Received: by 2002:a17:902:e543:b0:19d:62b:f040 with SMTP id n3-20020a170902e54300b0019d062bf040mr2660180plf.37.1677577357568; Tue, 28 Feb 2023 01:42:37 -0800 (PST) Received: from localhost ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id a23-20020a170902b59700b001993a1fce7bsm6042978pls.196.2023.02.28.01.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 01:42:37 -0800 (PST) From: Xie Yongji <xieyongji@bytedance.com> To: mst@redhat.com, jasowang@redhat.com, tglx@linutronix.de, hch@lst.de Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/11] vdpa: Add eventfd for the vdpa callback Date: Tue, 28 Feb 2023 17:41:07 +0800 Message-Id: <20230228094110.37-9-xieyongji@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230228094110.37-1-xieyongji@bytedance.com> References: <20230228094110.37-1-xieyongji@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759067977940083984?= X-GMAIL-MSGID: =?utf-8?q?1759067977940083984?= |
Series |
VDUSE: Improve performance
|
|
Commit Message
Yongji Xie
Feb. 28, 2023, 9:41 a.m. UTC
Add eventfd for the vdpa callback so that user
can signal it directly instead of running the
callback. It will be used for vhost-vdpa case.
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
drivers/vhost/vdpa.c | 2 ++
drivers/virtio/virtio_vdpa.c | 1 +
include/linux/vdpa.h | 3 +++
3 files changed, 6 insertions(+)
Comments
在 2023/2/28 17:41, Xie Yongji 写道: > Add eventfd for the vdpa callback so that user > can signal it directly instead of running the > callback. It will be used for vhost-vdpa case. > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > --- > drivers/vhost/vdpa.c | 2 ++ > drivers/virtio/virtio_vdpa.c | 1 + > include/linux/vdpa.h | 3 +++ > 3 files changed, 6 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index dc12dbd5b43b..ae89c0ccc2bb 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -599,9 +599,11 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > if (vq->call_ctx.ctx) { > cb.callback = vhost_vdpa_virtqueue_cb; > cb.private = vq; > + cb.irq_ctx = vq->call_ctx.ctx; > } else { > cb.callback = NULL; > cb.private = NULL; > + cb.irq_ctx = NULL; > } > ops->set_vq_cb(vdpa, idx, &cb); > vhost_vdpa_setup_vq_irq(v, idx); > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c > index 9eee8afabda8..a5cecafbc2d1 100644 > --- a/drivers/virtio/virtio_vdpa.c > +++ b/drivers/virtio/virtio_vdpa.c > @@ -195,6 +195,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, > /* Setup virtqueue callback */ > cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; > cb.private = info; > + cb.irq_ctx = NULL; > ops->set_vq_cb(vdpa, index, &cb); > ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); > > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > index 10bd22387276..94a7ec49583a 100644 > --- a/include/linux/vdpa.h > +++ b/include/linux/vdpa.h > @@ -13,10 +13,13 @@ > * struct vdpa_calllback - vDPA callback definition. > * @callback: interrupt callback function > * @private: the data passed to the callback function > + * @irq_ctx: the eventfd for the callback, user can signal > + * it directly instead of running the callback I'd suggest to do more tweaks to mention: 1) irq_ctx is optional 2) that when the irq_ctx is set, the vDPA driver must guarantee that signaling it is functional equivalent to triggering the callback. When set, vDPA parent can signal it directly instead of triggering the callback. > */ > struct vdpa_callback { > irqreturn_t (*callback)(void *data); > void *private; > + struct eventfd_ctx *irq_ctx; There's no IRQ concept at the virtual vDPA bus level, so it's probably better to rename it as "trigger". Btw, should we select EVENTFD for vDPA? Thanks > }; > > /**
On Thu, Mar 16, 2023 at 5:25 PM Jason Wang <jasowang@redhat.com> wrote: > > > 在 2023/2/28 17:41, Xie Yongji 写道: > > Add eventfd for the vdpa callback so that user > > can signal it directly instead of running the > > callback. It will be used for vhost-vdpa case. > > > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > > --- > > drivers/vhost/vdpa.c | 2 ++ > > drivers/virtio/virtio_vdpa.c | 1 + > > include/linux/vdpa.h | 3 +++ > > 3 files changed, 6 insertions(+) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > index dc12dbd5b43b..ae89c0ccc2bb 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -599,9 +599,11 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > > if (vq->call_ctx.ctx) { > > cb.callback = vhost_vdpa_virtqueue_cb; > > cb.private = vq; > > + cb.irq_ctx = vq->call_ctx.ctx; > > } else { > > cb.callback = NULL; > > cb.private = NULL; > > + cb.irq_ctx = NULL; > > } > > ops->set_vq_cb(vdpa, idx, &cb); > > vhost_vdpa_setup_vq_irq(v, idx); > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c > > index 9eee8afabda8..a5cecafbc2d1 100644 > > --- a/drivers/virtio/virtio_vdpa.c > > +++ b/drivers/virtio/virtio_vdpa.c > > @@ -195,6 +195,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, > > /* Setup virtqueue callback */ > > cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; > > cb.private = info; > > + cb.irq_ctx = NULL; > > ops->set_vq_cb(vdpa, index, &cb); > > ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); > > > > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > > index 10bd22387276..94a7ec49583a 100644 > > --- a/include/linux/vdpa.h > > +++ b/include/linux/vdpa.h > > @@ -13,10 +13,13 @@ > > * struct vdpa_calllback - vDPA callback definition. > > * @callback: interrupt callback function > > * @private: the data passed to the callback function > > + * @irq_ctx: the eventfd for the callback, user can signal > > + * it directly instead of running the callback > > > I'd suggest to do more tweaks to mention: > > 1) irq_ctx is optional > 2) that when the irq_ctx is set, the vDPA driver must guarantee that > signaling it is functional equivalent to triggering the callback. When > set, vDPA parent can signal it directly instead of triggering the callback. > > > */ > > struct vdpa_callback { > > irqreturn_t (*callback)(void *data); > > void *private; > > + struct eventfd_ctx *irq_ctx; > > > There's no IRQ concept at the virtual vDPA bus level, so it's probably > better to rename it as "trigger". > > Btw, should we select EVENTFD for vDPA? Looks like we are fine here since we only use the pointer to the eventfd_ctx. Thanks > > Thanks > > > > }; > > > > /**
On Thu, Mar 16, 2023 at 5:26 PM Jason Wang <jasowang@redhat.com> wrote: > > > 在 2023/2/28 17:41, Xie Yongji 写道: > > Add eventfd for the vdpa callback so that user > > can signal it directly instead of running the > > callback. It will be used for vhost-vdpa case. > > > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > > --- > > drivers/vhost/vdpa.c | 2 ++ > > drivers/virtio/virtio_vdpa.c | 1 + > > include/linux/vdpa.h | 3 +++ > > 3 files changed, 6 insertions(+) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > index dc12dbd5b43b..ae89c0ccc2bb 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -599,9 +599,11 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > > if (vq->call_ctx.ctx) { > > cb.callback = vhost_vdpa_virtqueue_cb; > > cb.private = vq; > > + cb.irq_ctx = vq->call_ctx.ctx; > > } else { > > cb.callback = NULL; > > cb.private = NULL; > > + cb.irq_ctx = NULL; > > } > > ops->set_vq_cb(vdpa, idx, &cb); > > vhost_vdpa_setup_vq_irq(v, idx); > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c > > index 9eee8afabda8..a5cecafbc2d1 100644 > > --- a/drivers/virtio/virtio_vdpa.c > > +++ b/drivers/virtio/virtio_vdpa.c > > @@ -195,6 +195,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, > > /* Setup virtqueue callback */ > > cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; > > cb.private = info; > > + cb.irq_ctx = NULL; > > ops->set_vq_cb(vdpa, index, &cb); > > ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); > > > > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h > > index 10bd22387276..94a7ec49583a 100644 > > --- a/include/linux/vdpa.h > > +++ b/include/linux/vdpa.h > > @@ -13,10 +13,13 @@ > > * struct vdpa_calllback - vDPA callback definition. > > * @callback: interrupt callback function > > * @private: the data passed to the callback function > > + * @irq_ctx: the eventfd for the callback, user can signal > > + * it directly instead of running the callback > > > I'd suggest to do more tweaks to mention: > > 1) irq_ctx is optional > 2) that when the irq_ctx is set, the vDPA driver must guarantee that > signaling it is functional equivalent to triggering the callback. When > set, vDPA parent can signal it directly instead of triggering the callback. > OK, I will add more comments for it. > > */ > > struct vdpa_callback { > > irqreturn_t (*callback)(void *data); > > void *private; > > + struct eventfd_ctx *irq_ctx; > > > There's no IRQ concept at the virtual vDPA bus level, so it's probably > better to rename it as "trigger". > LGTM. Thanks, Yongji
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index dc12dbd5b43b..ae89c0ccc2bb 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -599,9 +599,11 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, if (vq->call_ctx.ctx) { cb.callback = vhost_vdpa_virtqueue_cb; cb.private = vq; + cb.irq_ctx = vq->call_ctx.ctx; } else { cb.callback = NULL; cb.private = NULL; + cb.irq_ctx = NULL; } ops->set_vq_cb(vdpa, idx, &cb); vhost_vdpa_setup_vq_irq(v, idx); diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index 9eee8afabda8..a5cecafbc2d1 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -195,6 +195,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, /* Setup virtqueue callback */ cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; cb.private = info; + cb.irq_ctx = NULL; ops->set_vq_cb(vdpa, index, &cb); ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 10bd22387276..94a7ec49583a 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -13,10 +13,13 @@ * struct vdpa_calllback - vDPA callback definition. * @callback: interrupt callback function * @private: the data passed to the callback function + * @irq_ctx: the eventfd for the callback, user can signal + * it directly instead of running the callback */ struct vdpa_callback { irqreturn_t (*callback)(void *data); void *private; + struct eventfd_ctx *irq_ctx; }; /**