From patchwork Mon Dec 5 09:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 29617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2148192wrr; Mon, 5 Dec 2022 01:30:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf64YnjkVDpryBBDDBiqWXh+W1RoLb/TFqPnSk0oz6heWCvv/Ref6bo5QzkkWbQiEDUpghor X-Received: by 2002:a63:530f:0:b0:476:bfca:38ad with SMTP id h15-20020a63530f000000b00476bfca38admr58053910pgb.576.1670232646596; Mon, 05 Dec 2022 01:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670232646; cv=none; d=google.com; s=arc-20160816; b=KxOvZEQ76oHs7i9vuve0yXuPMvri67isC09J8pKgXqDgKGsbmoz3BkkNOWjkAvI2iF t/lE0dwC3491FX5vRNSxVE1bGCIjwIGyOLqe+04cKB7E3wehqagfAmCz+GYOnzRNR0ST Eyiafzm73O6N5hu5+RK66sj4qzX+kaOF3llzjzDELdAbU/h6pbnvXSAu2i6u9LV0iXhI yLF6ah/sE6+vtqzrlhxxVFjcDN68sVyGYGXTjboEkTGrLqg2V0Bq2wxyqjkUAdkJIwtt 2XqHibeoVXnX8DS5F8B0hVr47wWJGgYj5yttsd2KK2XUNiwHrnq/48DLHov2TbY7kmHK 7qEQ== 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=OshPsK9iOwiWj6ej55hHDAz7FEiazePp8poCkCFNGxA=; b=Ek3LvEiSM6vf1dNoJjRMIGWz7HVlbVZbNp9aHXp+NvQQKS7ghRoWkBgupdW+Qk6TEo aaWamlO8WqPBNhue0jpOLqJ7pMeUEcB6GhYapd1kHOssA5y/ARVaNNzpPcCCH5uPMsFz jp7Teu8CsDDeLSObS0WSL4KeqRAy3KhHyti6El4Sxzj5tZWZlWYcpIyI1Vs8wQe60w+L wz6ZhOSbeFkSDokrEWhLHlshuKMAztlccDLIQSQaO5LZefICkonQvY7tJBOHjzXci6Uj L+QJnO/Rf7nuH3CHDqo1ekRRcRZck/khMKEvoxu0MmrBF0tF+iPW1JIkbbWAD3M4KnbX SW5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=68OaXWJD; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a65580e000000b0046ae2a8ea9csi14334166pgr.733.2022.12.05.01.30.33; Mon, 05 Dec 2022 01:30:46 -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=68OaXWJD; 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 S232491AbiLEJEF (ORCPT + 99 others); Mon, 5 Dec 2022 04:04:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiLEJDT (ORCPT ); Mon, 5 Dec 2022 04:03:19 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B9CBF70 for ; Mon, 5 Dec 2022 01:02:55 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so2201768pjj.2 for ; Mon, 05 Dec 2022 01:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; 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=OshPsK9iOwiWj6ej55hHDAz7FEiazePp8poCkCFNGxA=; b=68OaXWJDpO+ve8DUgOhH/3nWT7HjsJAD5UDl3Z+88p6a5Vim4LqU1I2tSIIwxP8fgj 1fkb9Q8lYcK2DuDZMQO1dwegp5qlvIqCfvwMsbQvubp+K5E7EDWHXEyo7UsaL1X9eVg3 oq4vPdFpyQX4lQiu2ABhqckhKOoKHF5+UPgwbAqOvgpu3SoEV3GzdloDSxeHlJePZIp4 02JJ+j2kb/s9r6Kz0EFxeJII6nBQnMP2cjglR5mURMsjMRI4o4lQ6aL76i7+Tr6tqays B9WYsOelbTKR74i51N6FQ8RxLMrjHDaLkobY6/PmmpOcbsGsRwvaWJqxP3xtvMqsPEHF nuYQ== 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=OshPsK9iOwiWj6ej55hHDAz7FEiazePp8poCkCFNGxA=; b=hGxb5tMaDyXyEb7T4SGEYZFUAvDAMiPx3us31fHHMjlxTxHP37wZeDVGJlFrmFH6TX MQZxZxl4uF51htLobfEEX3d8+DBUAewQuIqJhac9MhM0rEkyZRU/ylnga8AmA2xJkA/D e1dn+6IqFh076+fcv69S4Q7vAT5uKicN7juvBgCx3nRGlfHuXrYOEskTAg9xKMpULD1i dnlQrpuVXDJKRZc62ur284C8GCt/Hdil8hmph3405EOgGSH0kFg/Vxi/27iKH81U4OTu 71FfJnaz/1FghRjRumS2hflIuITWSc3LnuOw9IC7BrWpX9oxZsOeoCm788+mDopr6ksY 4oaQ== X-Gm-Message-State: ANoB5plGe5IqFmQPA+5eFGwoMhiQCGj8H8uKFg/T+QwpAcz5vmzhc3ID WU0QDEXPZVBFexl/eBPC04NvgNF5Ok0UWxs= X-Received: by 2002:a17:90a:6408:b0:219:a82a:97f3 with SMTP id g8-20020a17090a640800b00219a82a97f3mr10420293pjj.95.1670230974969; Mon, 05 Dec 2022 01:02:54 -0800 (PST) Received: from localhost ([101.229.232.206]) by smtp.gmail.com with ESMTPSA id z5-20020aa79585000000b005764a143be3sm6022700pfj.103.2022.12.05.01.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 01:02:54 -0800 (PST) From: Xie Yongji 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 v2 07/11] vduse: Support set/get_vq_affinity callbacks Date: Mon, 5 Dec 2022 17:02:39 +0800 Message-Id: <20221205090243.791-1-xieyongji@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221205084127.535-1-xieyongji@bytedance.com> References: <20221205084127.535-1-xieyongji@bytedance.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751365867592580902?= X-GMAIL-MSGID: =?utf-8?q?1751365867592580902?= Since we already support irq callback affinity management, let's implement the set/get_vq_affinity callbacks to make it possible for the virtio device driver to change or be aware of the affinity. This would make it possible for the virtio-blk driver to build the blk-mq queues based on the irq callback affinity. Signed-off-by: Xie Yongji --- drivers/vdpa/vdpa_user/vduse_dev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 90c2896039d9..6507a78abc9d 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -739,6 +739,28 @@ static void vduse_vq_update_effective_cpu(struct vduse_virtqueue *vq) spin_unlock(&vq->irq_affinity_lock); } +static int vduse_vdpa_set_vq_affinity(struct vdpa_device *vdpa, u16 idx, + const struct cpumask *cpu_mask) +{ + struct vduse_dev *dev = vdpa_to_vduse(vdpa); + + cpumask_copy(&dev->vqs[idx]->irq_affinity, cpu_mask); + vduse_vq_update_effective_cpu(dev->vqs[idx]); + + return 0; +} + +static const struct cpumask * +vduse_vdpa_get_vq_affinity(struct vdpa_device *vdpa, u16 idx) +{ + struct vduse_dev *dev = vdpa_to_vduse(vdpa); + + if (dev->vqs[idx]->irq_effective_cpu == -1) + return NULL; + + return &dev->vqs[idx]->irq_affinity; +} + static void vduse_vdpa_set_irq_affinity(struct vdpa_device *vdpa, struct irq_affinity *desc) { @@ -807,6 +829,8 @@ static const struct vdpa_config_ops vduse_vdpa_config_ops = { .get_config = vduse_vdpa_get_config, .set_config = vduse_vdpa_set_config, .get_generation = vduse_vdpa_get_generation, + .set_vq_affinity = vduse_vdpa_set_vq_affinity, + .get_vq_affinity = vduse_vdpa_get_vq_affinity, .set_irq_affinity = vduse_vdpa_set_irq_affinity, .reset = vduse_vdpa_reset, .set_map = vduse_vdpa_set_map,