From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [PATCH] mem: get physical address of any pointer Date: Wed, 12 Jun 2013 13:54:35 +0200 Message-ID: <51B8617B.7000009@6wind.com> References: <1371023420-23195-1-git-send-email-thomas.monjalon@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Thomas Monjalon Return-path: In-Reply-To: <1371023420-23195-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hi Thomas, Please find some comments below. > +/** > + * Get physical address of any mapped virtual address in the current process. > + * It is found by browsing the /proc/self/pagemap special file. > + * The page won't be swappable anymore. > + */ > +phys_addr_t rte_mem_virt2phy(const void *virt); > > [...] > -static int > -find_physaddr(struct hugepage *hugepg_tbl, struct hugepage_info *hpi) > +phys_addr_t > +rte_mem_virt2phy(const void *virt) > { > [...] > + /* allocate page in physical memory and prevent from swapping */ > + mlock((void*)aligned, page_size); Should this function really do the mlock() ? It's a bit confusing to have a function that looks like a "get" that will change the status of the page. Another approach that sounds more reasonnable to me is to let the application does the mlock(), and have the rte_mem_virt2phy() return RTE_BAD_PHYS_ADDR if the page is not locked in memory. This info is well known from the /proc/self/pagemap. Should we also rename virt2phy in virt2phys ? Regards, Olivier