From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2D52C25B67 for ; Tue, 24 Oct 2023 02:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232367AbjJXCoQ (ORCPT ); Mon, 23 Oct 2023 22:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbjJXCoP (ORCPT ); Mon, 23 Oct 2023 22:44:15 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8071B10D4 for ; Mon, 23 Oct 2023 19:44:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R901e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VuoXqpk_1698115445; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VuoXqpk_1698115445) by smtp.aliyun-inc.com; Tue, 24 Oct 2023 10:44:05 +0800 Message-ID: <1698114697.434748-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH 1/2] virtio_pci: Don't make an extra copy of cpu affinity mask Date: Tue, 24 Oct 2023 10:31:37 +0800 From: Xuan Zhuo To: Jakub Sitnicki Cc: "Michael S. Tsirkin" , Jason Wang , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Caleb Raitto , virtualization@lists.linux-foundation.org References: <20231019101625.412936-1-jakub@cloudflare.com> <1697720122.49851-2-xuanzhuo@linux.alibaba.com> <87il6x2rj6.fsf@cloudflare.com> In-Reply-To: <87il6x2rj6.fsf@cloudflare.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Oct 2023 18:52:45 +0200, Jakub Sitnicki wrote: > On Thu, Oct 19, 2023 at 08:55 PM +08, Xuan Zhuo wrote: > > On Thu, 19 Oct 2023 12:16:24 +0200, Jakub Sitnicki wrote: > >> Since commit 19e226e8cc5d ("virtio: Make vp_set_vq_affinity() take a > >> mask.") it is actually not needed to have a local copy of the cpu mask. > > > > > > Could you give more info to prove this? Actually, my question is that can we pass a val on the stack(or temp value) to the irq_set_affinity_hint()? Such as the virtio-net uses zalloc_cpumask_var to alloc a cpu_mask, and that will be released. int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, bool setaffinity) { unsigned long flags; struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); if (!desc) return -EINVAL; -> desc->affinity_hint = m; irq_put_desc_unlock(desc, flags); if (m && setaffinity) __irq_set_affinity(irq, m, false); return 0; } EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint); The above code directly refers the mask pointer. If the mask is a temp value, I think that is a bug. And I notice that many places directly pass the temp value to this API. And I am a little confused. ^_^ Or I missed something. Thanks. > > > > If you are right, I think you should delete all code about msix_affinity_masks? > > Sorry for the late reply. I've been away. > > It looks that msix_affinity_masks became unused - intentionally - in > 2015, after commit 210d150e1f5d ("virtio_pci: Clear stale cpumask when > setting irq affinity") [1]. > > Originally introduced in 2012 in commit 75a0a52be3c2 ("virtio: introduce > an API to set affinity for a virtqueue") [2]. As I understand, it was > meant to make it possible to set VQ affinity to more than once CPU. > > Now that we can pass a CPU mask, listing all CPUs, to set_vq_affinity, > msix_affinity_masks seems to no longer have a purpose. > > So, IMO, you're right. We can remove it. > > Happy to do that in a follow up series. > > That is - if you're okay with these two patches in the current form. > > Thanks for reviewing. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=210d150e1f5da506875e376422ba31ead2d49621 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75a0a52be3c27b58654fbed2c8f2ff401482b9a4