Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3778802rwl; Mon, 27 Mar 2023 20:29:24 -0700 (PDT) X-Google-Smtp-Source: AKy350Z2aAkEkAUJugNNHleUBdExkaJHoKRJGxa5JlIGepCOQIjNVaZ4b+CvFsh00hjydekRrN4S X-Received: by 2002:a17:902:e847:b0:19a:aaac:f4d1 with SMTP id t7-20020a170902e84700b0019aaaacf4d1mr13913285plg.13.1679974164200; Mon, 27 Mar 2023 20:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679974164; cv=none; d=google.com; s=arc-20160816; b=gJE2FV0RuSV/9w2jqtxynwzafFBPvSAGgcsZysA2qNGKValPDY+cNNUvtYUl2cK9cT s2N3uYjwNhrw16OoWrDIsuRjbL2N+NBAVq8tk75n6MdsZnHEA9ItuOxDAmOR9/zA8Rvw nUQo8foHZLmRtXeft+0OwE4DFlveKHoDUUFnLWBmEk4xrE9dqI4xhEyAxuG1+pY5wCrG cVf72qgtoz2ixKT8sg4FzLEqaop6WI69GRGtJ86nwVx8zcTS9EWqFAZAQmdOGSW2XgL0 PCf14KrW0DVYn045ICXgATcY8B33XHJzbgX8I99ggQe3Qcy+Fi0mGVTcjopj5hZg1CNY VLag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GfSd4iprB6xpdvDd+tF+/DbujSEekae1K8j4YlTNtK0=; b=dC4CF2jRJfVpadKHPA896AoVeqBIZGmf9AWC3VxaMmsLsHHrh60Y3V34OA41/xI66k fZyrE8+Jz+flkIN5tCLQAn7o18tlPBiQP9qB9AAnsIwN4iLtCzO+2ggJjjrVAT4JsbT2 grRwUY5MFDdCVCZfM3KlmNWDR4gzs8I8x+2HV23scugEs2lCo5e9xmsaKM7iU2esCHWz uLLQfNMeT+vVb6yy7TI1X6N5hO5LXi4xppT4eMgkUbG7+BNWfxTPs/U7pQWy62aACSz0 dAq+y+kJKKHVQiX+M8ggLiFnBOlGWEmGHDl/Ads38L4RRT0Hz2QWsZBw7sO2HWWBzdsd fxCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Znh9byUZ; 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 q21-20020a170902b11500b0019ca54b0f0fsi28053041plr.638.2023.03.27.20.29.02; Mon, 27 Mar 2023 20:29:24 -0700 (PDT) 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=Znh9byUZ; 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 S232428AbjC1DPO (ORCPT + 99 others); Mon, 27 Mar 2023 23:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbjC1DPM (ORCPT ); Mon, 27 Mar 2023 23:15:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24570212B for ; Mon, 27 Mar 2023 20:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679973264; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GfSd4iprB6xpdvDd+tF+/DbujSEekae1K8j4YlTNtK0=; b=Znh9byUZV/IVjJQXCDv5ZbPe+BJTX/zKPuTmQPosQcC4gwIWcPSN2FGlAj/g+uopgd0qox klhypw7ZXLasJW1sAZJ6DS9U+yg7B21rOOByXXxMpLmtL8//rmbNjWxzyp1Pj7ayC+o+10 Wy/O3BYria6U4fEWiut+8WNEP8MYq0U= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-Ba1pO_7MMpiCRL2-7fsswA-1; Mon, 27 Mar 2023 23:14:22 -0400 X-MC-Unique: Ba1pO_7MMpiCRL2-7fsswA-1 Received: by mail-oo1-f70.google.com with SMTP id t18-20020a4a7452000000b00525456d55f7so2633631ooe.14 for ; Mon, 27 Mar 2023 20:14:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679973262; h=content-transfer-encoding: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=GfSd4iprB6xpdvDd+tF+/DbujSEekae1K8j4YlTNtK0=; b=BrurhtVOs8x8qzRSlM+fk3yy53qO7lxSc5DmENt1ZlEaWjarZ/kiiiib62ahYAvYqp CXGjVrCDpfDwbGYAYis8faY/g3KqYi/qeK3UHSAaeiuHC00nsumBGxF9PRYvjMD02QSV rTOYGKJZK5bCchribKgvapWinQsYSk/z8UQn8hnhX5njPyVRQTruMP/1eXX0ncPWyosz 2EFM79pk6W4ev9qWWGp1GdUSqYmUBSE35CaLR7qDiv1q/BhWmh6qkoEp/UN+dv4DplQa c+SuwBCLuZlM1rQXWZqIctmzJRbppxoLl9BWhUljBnOY7+lGk07JMpmsguSJIpmqP8fA D/VQ== X-Gm-Message-State: AO0yUKWgSp/N8+oh7grNytYGCBDESIWG0R8bpb7CHA5yDgMorKuV5hUz 6TP5MOXgqfFQYmK/Vs/dq0rUoedXm6TvzZ8mWVfH4DJePS+TFQkVVlVG/ELYn2igcbrZE72Dl0P 42y35wJbmKRjMFOIz4vL6pc9yuMXo/DX92DUaPo96 X-Received: by 2002:a05:6871:4983:b0:17e:e3b2:6d99 with SMTP id tx3-20020a056871498300b0017ee3b26d99mr3938743oab.9.1679973262032; Mon, 27 Mar 2023 20:14:22 -0700 (PDT) X-Received: by 2002:a05:6871:4983:b0:17e:e3b2:6d99 with SMTP id tx3-20020a056871498300b0017ee3b26d99mr3938742oab.9.1679973261812; Mon, 27 Mar 2023 20:14:21 -0700 (PDT) MIME-Version: 1.0 References: <20230323053043.35-1-xieyongji@bytedance.com> <20230323053043.35-4-xieyongji@bytedance.com> In-Reply-To: From: Jason Wang Date: Tue, 28 Mar 2023 11:14:10 +0800 Message-ID: Subject: Re: [PATCH v4 03/11] virtio-vdpa: Support interrupt affinity spreading mechanism To: Yongji Xie Cc: "Michael S. Tsirkin" , Thomas Gleixner , Christoph Hellwig , virtualization , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=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=unavailable 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 Tue, Mar 28, 2023 at 11:03=E2=80=AFAM Yongji Xie wrote: > > On Fri, Mar 24, 2023 at 2:28=E2=80=AFPM Jason Wang = wrote: > > > > On Thu, Mar 23, 2023 at 1:31=E2=80=AFPM Xie Yongji wrote: > > > > > > To support interrupt affinity spreading mechanism, > > > this makes use of group_cpus_evenly() to create > > > an irq callback affinity mask for each virtqueue > > > of vdpa device. Then we will unify set_vq_affinity > > > callback to pass the affinity to the vdpa device driver. > > > > > > Signed-off-by: Xie Yongji > > > > Thinking hard of all the logics, I think I've found something interesti= ng. > > > > Commit ad71473d9c437 ("virtio_blk: use virtio IRQ affinity") tries to > > pass irq_affinity to transport specific find_vqs(). This seems a > > layer violation since driver has no knowledge of > > > > 1) whether or not the callback is based on an IRQ > > 2) whether or not the device is a PCI or not (the details are hided by > > the transport driver) > > 3) how many vectors could be used by a device > > > > This means the driver can't actually pass a real affinity masks so the > > commit passes a zero irq affinity structure as a hint in fact, so the > > PCI layer can build a default affinity based that groups cpus evenly > > based on the number of MSI-X vectors (the core logic is the > > group_cpus_evenly). I think we should fix this by replacing the > > irq_affinity structure with > > > > 1) a boolean like auto_cb_spreading > > > > or > > > > 2) queue to cpu mapping > > > > But only the driver knows which queues are used in the control path > which don't need the automatic irq affinity assignment. Is this knowledge awarded by the transport driver now? E.g virtio-blk uses: struct irq_affinity desc =3D { 0, }; Atleast we can tell the transport driver which vq requires automatic irq affinity. > So I think the > irq_affinity structure can only be created by device drivers and > passed to the virtio-pci/virtio-vdpa driver. This could be not easy since the driver doesn't even know how many interrupts will be used by the transport driver, so it can't built the actual affinity structure. > > > So each transport can do its own logic based on that. Then virtio-vDPA > > can pass that policy to VDUSE where we only need a group_cpus_evenly() > > and avoid duplicating irq_create_affinity_masks()? > > > > I don't get why we would have duplicated irq_create_affinity_masks(). I meant the create_affinity_masks() in patch 3 seems a duplication of irq_create_affinity_masks(). Thanks > > Thanks, > Yongji >