All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier MATZ <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: Thomas Monjalon
	<thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] mem: get physical address of any pointer
Date: Wed, 12 Jun 2013 13:54:35 +0200	[thread overview]
Message-ID: <51B8617B.7000009@6wind.com> (raw)
In-Reply-To: <1371023420-23195-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>

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

  parent reply	other threads:[~2013-06-12 11:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12  7:50 [PATCH] mem: get physical address of any pointer Thomas Monjalon
     [not found] ` <1371023420-23195-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 11:54   ` Olivier MATZ [this message]
     [not found]     ` <51B8617B.7000009-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 15:24       ` Thomas Monjalon
     [not found]         ` <1371050692-16945-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 15:35           ` Olivier MATZ
     [not found]             ` <51B89533.5070803-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-06-12 15:42               ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51B8617B.7000009@6wind.com \
    --to=olivier.matz-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.