Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp52002ybk; Fri, 8 May 2020 13:48:59 -0700 (PDT) X-Google-Smtp-Source: APiQypIA6/TKITypvJU6yX1EZDmiYVymSLR7we596qLIgLwhRWADZSBLhSbUUvWw27jZnR8s64Pk X-Received: by 2002:a17:906:9484:: with SMTP id t4mr3489251ejx.332.1588970939091; Fri, 08 May 2020 13:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588970939; cv=none; d=google.com; s=arc-20160816; b=i6uGBPGE7aCs6fl3aZLu6PJoAfc99RrFSz7ZA7pvcbfI48chyewT6/8asNDALvG4oG Xqgz55zrD2b59oCo2/FX0pDxRk+dg9aQcLg7NaO+SylyshRvEzNJ/+wZE2Sg+AvaoyqE T6EiqhDE0inhNWG2a0Ua2xVp8qfXTsnz7nxXCCg/+/EqLkUOxjWmfB3D6y9hdNkkfJMR 5ObPd1iwOvOdN0nw1ANAfg2s6/4erLy7d/yFoHhhjAlZE9pj3JaaOMOvMnXyqtraBHCT pOMEbe75vu0d8o7RebmTHccQ5IO6mHDgFyKo0881sRgDpvUX1gnDRqSf85wUB2i3a+Oi +GOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=WnVkROmPvoNf8m+L/EzFx7oxDCEVjnhfyv/ODDCNRpQ=; b=NLmZg/UMfflwylLle3N2N46dzGpSXLPRphJLFyihcb4ju6B3tSZ3ZJANdGec5BQlFF ruUJU/EnY4BSnzPfLSlQsG+aLQJKGqxOo+fDB74kLoTCd9xVXt43Uo9nbota/mEPl03V z5kbq0bOJi8ewRY0Lq3eHrEEMbXH3FH5AZf27zBsEUE4brKqeh8sSISxA57BHE3v7Nw8 EIceKJPt6azu8kpYuKCzyGeRYbcGy49TLOnOlQTyK0yzUZQsiiyZUsPVqKnS1UOsUEfC kqUIHnLU4ZYYgAUoN9nu8ZKYJvs4sDzpK8jRabDeaaQNnNcpUkVoIEucXJMGLPtMZ5u8 Mldw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si1658885edr.596.2020.05.08.13.48.35; Fri, 08 May 2020 13:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727778AbgEHUrM (ORCPT + 99 others); Fri, 8 May 2020 16:47:12 -0400 Received: from mga01.intel.com ([192.55.52.88]:15188 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgEHUrM (ORCPT ); Fri, 8 May 2020 16:47:12 -0400 IronPort-SDR: DuKItoW6HSsPJmI6EKlOM9RKO+Kz3gxu7ArplrGslXFAMo/Iqwse1lpMyHjc9Ogy09IVVIB44U BimMnZV9PeWQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 13:47:11 -0700 IronPort-SDR: Ws67Aagq7YgG2snBGVk1C1ZIy3paurbwnrKJK/rpqD2iq5oG5Lx0moxzX7x1HOFOuxtYO7W/k8 GGimup1grgVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,369,1583222400"; d="scan'208";a="296258718" Received: from otc-nc-03.jf.intel.com (HELO otc-nc-03) ([10.54.39.25]) by fmsmga002.fm.intel.com with ESMTP; 08 May 2020 13:47:10 -0700 Date: Fri, 8 May 2020 13:47:10 -0700 From: "Raj, Ashok" To: "Tian, Kevin" Cc: Jason Gunthorpe , Alex Williamson , "Jiang, Dave" , "vkoul@kernel.org" , "megha.dey@linux.intel.com" , "maz@kernel.org" , "bhelgaas@google.com" , "rafael@kernel.org" , "gregkh@linuxfoundation.org" , "tglx@linutronix.de" , "hpa@zytor.com" , "Pan, Jacob jun" , "Liu, Yi L" , "Lu, Baolu" , "Kumar, Sanjay K" , "Luck, Tony" , "Lin, Jing" , "Williams, Dan J" , "kwankhede@nvidia.com" , "eric.auger@redhat.com" , "parav@mellanox.com" , "dmaengine@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-pci@vger.kernel.org" , "kvm@vger.kernel.org" , Ashok Raj Subject: Re: [PATCH RFC 00/15] Add VFIO mediated device support and IMS support for the idxd driver. Message-ID: <20200508204710.GA78778@otc-nc-03> References: <20200424124444.GJ13640@mellanox.com> <20200424181203.GU13640@mellanox.com> <20200426191357.GB13640@mellanox.com> <20200426214355.29e19d33@x1.home> <20200427115818.GE13640@mellanox.com> <20200427071939.06aa300e@x1.home> <20200427132218.GG13640@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason In general your idea of moving pure emulation code to user space is a good strategy. On Wed, Apr 29, 2020 at 02:42:20AM -0700, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Monday, April 27, 2020 9:22 PM > > > > On Mon, Apr 27, 2020 at 07:19:39AM -0600, Alex Williamson wrote: > > > > > > It is not trivial masking. It is a 2000 line patch doing comprehensive > > > > emulation. > > > > > > Not sure what you're referring to, I see about 30 lines of code in > > > vdcm_vidxd_cfg_write() that specifically handle writes to the 4 BARs in > > > config space and maybe a couple hundred lines of code in total handling > > > config space emulation. Thanks, > > > > Look around vidxd_do_command() > > > > If I understand this flow properly.. > > > > Hi, Jason, > > I guess the 2000 lines mostly refer to the changes in mdev.c and vdev.c. > We did a break-down among them: > > 1) ~150 LOC for vdev initialization > 2) ~150 LOC for cfg space emulation > 3) ~230 LOC for mmio r/w emulation > 4) ~500 LOC for controlling the work queue (vidxd_do_command), > triggered by write emulation of IDXD_CMD_OFFSET register > 5) the remaining lines are all about vfio-mdev registration/callbacks, > for reporting mmio/irq resource, eventfd, mmap, etc. > > 1/2/3) are pure device emulation, which counts for ~500 LOC. > > 4) needs be in the kernel regardless of which uAPI is used, because it > talks to the physical work queue (enable, disable, drain, abort, reset, etc.) > > Then if just talking about ~500 LOC emulation code left in the kernel, > is it still a big concern to you? ???? Even when uaccel was under development, one of the options was to use VFIO as the transport, goal was the same i.e to keep the user space have one interface. But the needs of generic user space application is significantly different from exporting a more functional device model to guest, which isn't full emulated device. which is why VFIO didn't make sense for native use. And when we move things from VFIO which is already established as a general device model and accepted by multiple VMM's it gives instant footing without a whole redesign. When we move things from VFIO to uaccel to bolt on the functionality like VFIO, I suspect we would be moving code/functionality from VFIO to Uaccel. I don't know what the net gain would be. IMS is being reworked based on your feedback. And for mdev since the code is minimal for emulation, and rest are control paths that need kernel code to deal with. For mdev, would you agree we can keep the current architecture, and investigate moving some emulation code to user space (say even for standard vfio_pci) and then expand scope later. Cheers Ashok