Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2037061rwj; Sun, 18 Dec 2022 21:24:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Eku7OZjxD4M2HRy44oQZaiuybWowtLi8ZxCxHClvCHJKAzU+mWgvwAfgAm1MpxzOeum3j X-Received: by 2002:a17:902:bb8b:b0:186:af3d:dd6e with SMTP id m11-20020a170902bb8b00b00186af3ddd6emr41625177pls.21.1671427463147; Sun, 18 Dec 2022 21:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671427463; cv=none; d=google.com; s=arc-20160816; b=SU035WSl0zntgjNNLriAvO3ghkaFKG8qLHqnagQoEGl1n6GDD3Ktxvf4ekBOnqJ6bl cDJsRRAs6MOKQNXiBB1HwGdv97LHSu7Fy+TTUt5dMwP7JkQFmydbTPzr6hgOx+y3lvpT BH6VrFlQl//QErXgyybgr5CzWVX00JGpVah7RJa7wrDkBh9cGJ+yCUsMh0v4GvW5tBwA g0wlwzr170HwWidSxXMFnXB1/gIqVBQwP7RBDWo5hjBRchWyE7u8OBunw+I6HdJ7DGv8 Q7XWZmFj67UV3B6IVfayWPJABsf/1WBDErSmnbxSiVoam7ZUm0R3brvTOzl3mC0Ftzqs SOUQ== 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=9rD7i+tYqqhFJuFa94OR1meePFZcnKCYoZpo52/JXrU=; b=TJhZOi3SurND9bXJVBmv53NEgRADl13cjPftREyhobQahtUcOcJ3/A/qomLUvU+oca VTVLXYuIKvTtkNTt9KfvO6yCFmUC4uwS5xQH4BzWg0LI+SplGcxCGoCSxoi1D3tqPX1l MVrUlBHvF9NnmrnOq2mOYdVMc78cPVvuhBx+p7+xOH/NUKKyLh0+xp1+O9BRtxCk78Y8 /jkTp8jicgwFsBl/jPf4u7UuTUmLzlloRciIRUwIGSjCG1cFsf3klxZOOXZ6QEEsnBeR CdFyQ9c+MUoX+1PVcYWfAwDFos3qX/Mwm3xWdi3tXPoBGhNG5oB2doK/UNjP99r2foAI tZ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=BkFRMIs8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a170902860300b0019111dd0568si5466085plo.459.2022.12.18.21.24.14; Sun, 18 Dec 2022 21:24:23 -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.20210112.gappssmtp.com header.s=20210112 header.b=BkFRMIs8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229528AbiLSFFb (ORCPT + 70 others); Mon, 19 Dec 2022 00:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiLSFF1 (ORCPT ); Mon, 19 Dec 2022 00:05:27 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9B64AE66 for ; Sun, 18 Dec 2022 21:04:55 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id m18so18818995eji.5 for ; Sun, 18 Dec 2022 21:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9rD7i+tYqqhFJuFa94OR1meePFZcnKCYoZpo52/JXrU=; b=BkFRMIs86ingc8zd+K8pvyXtqPTXhXRk+jMvwoEdSgX+daJ7qnkS1XAAVaUYdSAMVH Mif3j5HHykOJLjajwyjNKmJrZsNIQl6FAN0aeJqvX0HqXsWAfr1AbQKNxypC6sT0R3aK kIxkOsEhI19Yh3w3xddomdDltjZtDWrV0Nuhkk8zUjjri8s9rBuAbA3Ca3b0E5+rkVIn 2oypP2FAjIjhSnxyXhfRcxcJG4EwHULVDN3u8lO6KgMh0HWLG6llMCGvaM4xwzzrPF9O 8MTODvvpVDELGdifUiLGYOLqBCFJnfiFCCTKJoGT3sObst8plgM/sosrmNOSRGX6hUgn wnkA== 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=9rD7i+tYqqhFJuFa94OR1meePFZcnKCYoZpo52/JXrU=; b=5XPdmghLOXhy2WBpaxjOCp9i/g4hOhtFSIg1xJ19K2bmoRkDgtf32NvI/BBsvtywkR oRrDzFbw9pC1Ln7Aui5m2ttV98bRLPwS/u1fxGLKaZ+F53NPTDARhSHuWh87ph8JSYlY BPVqaxmyXp/IDFLdFFip4QQ7O/F28PvMVpkbr6pjxXtI5979sBTx0sTiQi7RG4oIOoY5 LcACxkot3K37llKROI3ofr8XV8dn8Q5wQiMEumjb88BYj7bm8edTcll2oWN1ClhAhqH/ 3YqDJyMHJ3ND82s9JpKEPmsMmBoEhssHMHJZN90QyapEg9Vy1ULpUutEv8lkrUsAgJSM UU6g== X-Gm-Message-State: AFqh2krJNAjeNMjXTEMsdosyUB9T4+iWFKZ8zPuld8ydfQfS4BqJ6RcH UnSU1UOmdQrr9iJueyCRtPFmSYVAPrXIZUXZyaqf X-Received: by 2002:a17:907:d68e:b0:7de:de2c:7bbe with SMTP id wf14-20020a170907d68e00b007dede2c7bbemr1406303ejc.141.1671426294383; Sun, 18 Dec 2022 21:04:54 -0800 (PST) MIME-Version: 1.0 References: <20221205084127.535-1-xieyongji@bytedance.com> <20221205084127.535-6-xieyongji@bytedance.com> In-Reply-To: From: Yongji Xie Date: Mon, 19 Dec 2022 13:04:43 +0800 Message-ID: Subject: Re: [PATCH v2 05/11] vduse: Introduce bound workqueue for irq injection To: Jason Wang Cc: "Michael S. Tsirkin" , Thomas Gleixner , Christoph Hellwig , virtualization , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 16, 2022 at 12:02 PM Jason Wang wrote: > > 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. > This variable represents the CPU that runs the interrupt callback rather than CPU affinity. > > }; > > > > 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? > It makes sense to me. Thanks, Yongji