From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id B7A5111C5 for ; Tue, 23 Aug 2016 15:39:38 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 23 Aug 2016 06:39:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,566,1464678000"; d="scan'208";a="159814190" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga004.fm.intel.com with ESMTP; 23 Aug 2016 06:39:36 -0700 Date: Tue, 23 Aug 2016 21:49:24 +0800 From: Yuanhan Liu To: Maxime Coquelin Cc: dev@dpdk.org Message-ID: <20160823134924.GN30752@yliu-dev.sh.intel.com> References: <1471939839-29778-1-git-send-email-yuanhan.liu@linux.intel.com> <1471939839-29778-3-git-send-email-yuanhan.liu@linux.intel.com> <13f37c6e-b389-a758-81cd-861db7337e1f@redhat.com> <20160823123211.GK30752@yliu-dev.sh.intel.com> <713fbf24-b451-5ffa-0bdf-e8d1a8624bcb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <713fbf24-b451-5ffa-0bdf-e8d1a8624bcb@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH 2/6] vhost: get guest/host physical address mappings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2016 13:39:39 -0000 On Tue, Aug 23, 2016 at 03:25:33PM +0200, Maxime Coquelin wrote: > > > On 08/23/2016 02:32 PM, Yuanhan Liu wrote: > >>>+ > >>>> >+ /* FIXME */ > >>>> >+ RTE_LOG(INFO, VHOST_CONFIG, ":: %u ::\n", pre_read); > >>> For my information, what is the purpose of pre_read? > >Again, I put a FIXME here, but I forgot to add some explanation. > > > >Here is the thing: the read will make sure the kernel populate the > >corresponding PTE entry, so that rte_mem_virt2phy() will return proper > >physical address, otherwise, invalid value is returned. > > > >I can't simply do the read but do not actually reference/consume it. > >Otherwise, the compiler will treat it as some noops and remove it. > > > >An ugly RTE_LOG will make sure the read operation is not eliminated. > >I'm seeking a more proper way to achieve that. Maybe I can add a new > >field in virtio_net structure and store it there. > > > >Or, do you have better ideas? > > This behavior is pretty twisted, no? I have to say, yes, kind of. > Shouldn't be rte_mem_virt2phy() role to ensure returning a valid value? Not exactly. I think rte_mem_virt2phy() is more likely to fetch the physical address of huge pages. And for those huge pages, EAL makes sure they will be populated: it used to do a zero memset before to achieve that. Since 5ce3ace1de45 ("eal: remove unnecessary hugepage zero-filling"), it uses MAP_POPULATE option instead. So, thank you that you just remind me of the MAP_POPULATE option. I just had a quick try, it worked like a charm :) --yliu > I have no better idea for now, but I will think about it. > > Regards, > Maxime