Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2140637rwb; Thu, 15 Dec 2022 20:33:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ZIAjKOwFihDSquA1fejH7bBYpE67h/KpZI3BPeLv7h2RbUXiV02Zu0XEjv+N8diaJumr7 X-Received: by 2002:a17:90a:e608:b0:219:705e:67b2 with SMTP id j8-20020a17090ae60800b00219705e67b2mr32061254pjy.10.1671165184458; Thu, 15 Dec 2022 20:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671165184; cv=none; d=google.com; s=arc-20160816; b=ysmsZyCkazklHhcLKYFpZJj5gfMvT3yVve4663C3ndffWUhT5crLtnLH5QpUhuL1qu 0XpC63rIA5xaw+w/tEQW69zX37rrLPfSUEsR85ptUW0DjWHmsPR9ZJVHulzsbgNQp6l4 VDVe5WMVq+TDYqtt/c+lS3kbGXxj5mH6O+mGx4zVEav/srHuIlcKqG2W8Kucp0M+DI9o /oQN3kY6ffu0FQY4+lYaqVpHFMmh1smvmJTSIXmQpnF/ttDW2bDxCAw+H2PaC3vzqDs5 QPpCU+A55ZO22fOulq5rnWjxdSTCdH5pQIx9qo2VJbqD+o2IqIKrLyKf940wBxREWddb tdlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bUg7DCrpGftfeECU7OexNPwbmvxXhls2VyJtY/quv18=; b=weBNEnMn1AVX09zS8ILXk/mEYdhoHc7V0uv19of2qFffuVsyCE3NCDLDrzHNh/vtTf ElW6WYsWTh5tsh7OjS7h+p+ajUBVPssPtpzhUbNIe9xk45j7M8wgMkzHRPyMFkV+xf9q MVQiILXHVx0FbP1doPWuBTsZLWaUGJ5Z/RxD7MGsqjMysTyhQo+sBn71KiOCIdcLwA+j DmcvpAu4CqsJKepqjuNsti4dZhnyhAZOSOYPzWF3dsO1IOSS03+zXdeo/d4sVxN7Fh+r n3xy3FtSvEWGZpWR2B4VAQCOcb3Er3s4tqHRYBnYVK13CZYBuC1wbRyPl9xAPdiuRMVl K3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WJQDS0rJ; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b65-20020a636744000000b0046f4d39c588si1452246pgc.580.2022.12.15.20.32.55; Thu, 15 Dec 2022 20:33:04 -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=@redhat.com header.s=mimecast20190719 header.b=WJQDS0rJ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbiLPEDw (ORCPT + 68 others); Thu, 15 Dec 2022 23:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbiLPEDk (ORCPT ); Thu, 15 Dec 2022 23:03:40 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9767FC7 for ; Thu, 15 Dec 2022 20:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671163371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bUg7DCrpGftfeECU7OexNPwbmvxXhls2VyJtY/quv18=; b=WJQDS0rJwV7FlNbKEZuoxpFaZ50wJH9LI2o5GM3npjjKmYlEYepC6JpOrnm+8YHL8NUR5y BgFX3XUu4Rc4MwPgXnkV82xGfj/i+y9d09BeCu2KhfWBgw64g71oX6v6CaETmvsjP+zrsB r87944Zsgm8Z5NVE/GOu1LAhf3uoRXM= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-370-qPuyYvI2MWG4GJqqDFdYQA-1; Thu, 15 Dec 2022 23:02:50 -0500 X-MC-Unique: qPuyYvI2MWG4GJqqDFdYQA-1 Received: by mail-ot1-f71.google.com with SMTP id s22-20020a9d7596000000b0066eb4e77127so683837otk.13 for ; Thu, 15 Dec 2022 20:02:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bUg7DCrpGftfeECU7OexNPwbmvxXhls2VyJtY/quv18=; b=aGCrwi1qXYKEZK9WucGAYDNHIgh0cRecZRTT6XWWRGoYnkMKwHESRQjnlkzUHsys+T YAsxu9UkaAcfnr73KZ/O8CxBltnzP0sd+KuA7X5qgzvUgx9lMfrjQbvnmgkx3xYXQMkZ NkznYHr6qPyArtDHVb8JTyFaKobJRAkZJVjxvr3sKtosGKw5OQYZHhE3Ja3O8Ab9Wtai l57B64IylDpRhJauQ59Ed/69JTRFaGwQbpsMgjIKh4zWKg23iAorWzWqnQWvsjhz1fo9 0UthcUkG2gBrv9RifgJajJ8qr0/O5CSoIR6nkK7NJgV5mNWKCbhNtQj0TuPzxISShIHZ Ii6A== X-Gm-Message-State: ANoB5plKZX3a24+epBgcxvIJvEsCsDiRx1S0DRCJdAFn3aKJByNft+DX yMC8tBoiLggdHp/8i/mdvZful0LgcPuw6xMIbZwusmWa8o2WKI3lpZ57k+Btajie5Vu+0IDMEBL 2ju3HLSZIpxfeK/rQCdfidIqQ856fUkC1R/YnBopC X-Received: by 2002:a05:6870:9e8f:b0:144:a97b:1ae2 with SMTP id pu15-20020a0568709e8f00b00144a97b1ae2mr321606oab.35.1671163369629; Thu, 15 Dec 2022 20:02:49 -0800 (PST) X-Received: by 2002:a05:6870:9e8f:b0:144:a97b:1ae2 with SMTP id pu15-20020a0568709e8f00b00144a97b1ae2mr321604oab.35.1671163369422; Thu, 15 Dec 2022 20:02:49 -0800 (PST) MIME-Version: 1.0 References: <20221205084127.535-1-xieyongji@bytedance.com> <20221205084127.535-6-xieyongji@bytedance.com> In-Reply-To: <20221205084127.535-6-xieyongji@bytedance.com> From: Jason Wang Date: Fri, 16 Dec 2022 12:02:38 +0800 Message-ID: Subject: Re: [PATCH v2 05/11] vduse: Introduce bound workqueue for irq injection To: Xie Yongji Cc: mst@redhat.com, tglx@linutronix.de, hch@lst.de, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 5, 2022 at 4:44 PM Xie Yongji wrote: > > This introduces a bound workqueue to support running > irq callback in a specified cpu. > > Signed-off-by: Xie Yongji > --- > drivers/vdpa/vdpa_user/vduse_dev.c | 29 ++++++++++++++++++++++------- > 1 file changed, 22 insertions(+), 7 deletions(-) > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > index 37809bfcb7ef..d126f3e32a20 100644 > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > @@ -57,6 +57,7 @@ struct vduse_virtqueue { > struct vdpa_callback cb; > struct work_struct inject; > struct work_struct kick; > + int irq_effective_cpu; I wonder why it's a cpu number instead of a cpumask. The latter seems more flexible, e.g when using NUMA. > }; > > struct vduse_dev; > @@ -128,6 +129,7 @@ static struct class *vduse_class; > static struct cdev vduse_ctrl_cdev; > static struct cdev vduse_cdev; > static struct workqueue_struct *vduse_irq_wq; > +static struct workqueue_struct *vduse_irq_bound_wq; > > static u32 allowed_device_id[] = { > VIRTIO_ID_BLOCK, > @@ -917,7 +919,8 @@ static void vduse_vq_irq_inject(struct work_struct *work) > } > > static int vduse_dev_queue_irq_work(struct vduse_dev *dev, > - struct work_struct *irq_work) > + struct work_struct *irq_work, > + int irq_effective_cpu) > { > int ret = -EINVAL; > > @@ -926,7 +929,11 @@ static int vduse_dev_queue_irq_work(struct vduse_dev *dev, > goto unlock; > > ret = 0; > - queue_work(vduse_irq_wq, irq_work); > + if (irq_effective_cpu == -1) Is it better to have a macro for this magic number? Thanks