From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bk0-x229.google.com (mail-bk0-x229.google.com [IPv6:2a00:1450:4008:c01::229]) by dpdk.org (Postfix) with ESMTP id 6A01D532D for ; Wed, 12 Jun 2013 13:54:25 +0200 (CEST) Received: by mail-bk0-f41.google.com with SMTP id jc3so4568257bkc.28 for ; Wed, 12 Jun 2013 04:54:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=3nQURshVR6IUjgz9BCv4dG+uYVe/8EhylBrIDvhM9sU=; b=cTjafheJ5rbOzl7iT2DCbh9r7yybpCCmCDthKje3h5qqvD+UY97Zkjr/gbJZd5zKd+ 8IYfxB12a034Mt4clhz7OQ4FantJLYgFs4xMAOHEG94/aVZcULTQviDO1eDkYFoIyrf+ CQltrb+jxkgJC5Znt/O9dinY1iB2YnZOMZIvUQsYlz3koE2rjzc8AvZpew9LVZK9kUoi NpbpOzS6mieaAaVX6tyCW8Z/+L+j20GmxsDosHFf1zGEEFCLOFXDU6D8SYxPYjk06KpQ wyuWl95FdtSztGvIDscq5951DKV8AUBaLjVPTUT0+YFIKDAuYIx6o1z8YS2G9Qzib0rg xrFg== X-Received: by 10.205.7.71 with SMTP id on7mr3017123bkb.23.1371038074829; Wed, 12 Jun 2013 04:54:34 -0700 (PDT) Received: from [10.16.0.195] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id so13sm7507735bkb.15.2013.06.12.04.54.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 04:54:33 -0700 (PDT) Message-ID: <51B8617B.7000009@6wind.com> Date: Wed, 12 Jun 2013 13:54:35 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.6esrpre) Gecko/20120817 Icedove/10.0.6 MIME-Version: 1.0 To: Thomas Monjalon References: <1371023420-23195-1-git-send-email-thomas.monjalon@6wind.com> In-Reply-To: <1371023420-23195-1-git-send-email-thomas.monjalon@6wind.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnhDWMZMr1qYSRMIj1pzuHqmpQtxHsHuSgOndyW/vJfP3MdBJrZdBmXEj0hFG6OpWUHRro3 Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] mem: get physical address of any pointer 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: Wed, 12 Jun 2013 11:54:25 -0000 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