All of lore.kernel.org
 help / color / mirror / Atom feed
* What is the right way to prefault and pin pages for perfmon?
@ 2007-05-07 11:48 Robin Holt
  2007-05-07 12:20 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Robin Holt @ 2007-05-07 11:48 UTC (permalink / raw)
  To: linux-mm; +Cc: Stephane Eranian

perfmon has a need to get memory allocated and prefaulted for a shared
buffer between user and kernel.  The memory is read-only to the user.
The hardware performance counter values are inserted into those pages.
Pages can not be faulted during sampling as we only have nano to micro
seconds to capture the values with accuracy.  What is the right way to
accomplish this?

Currently, the user is calling the kernel with a number of sample entries
for a single cpu's buffers.  The kernel turns this into a buffer size
and calls vmalloc to get a kernel virtually contiguous address range.
It then sets PG_RESERVED on all those pages and calls remap_pfn_range()
to insert page table entries into the users address space.  Additionally,
it is updating locked_vm on the tasks mm.

I think this should really become do_mmap(), followed by get_user_pages().
I don't think we have a need to update locked_vm and we also should
not need to insert page table entries, but let the kernel do the work.
This will require perfmon to adjust to using a virtually discontiguous
address range, but that seems reasonable.

What is the "right" way to do this?  Is there precedence for this sort
of thing elsewhere in the kernel that I can look at?

Thanks,
Robin

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: What is the right way to prefault and pin pages for perfmon?
  2007-05-07 11:48 What is the right way to prefault and pin pages for perfmon? Robin Holt
@ 2007-05-07 12:20 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2007-05-07 12:20 UTC (permalink / raw)
  To: Robin Holt; +Cc: linux-mm, Stephane Eranian

On Mon, May 07, 2007 at 06:48:38AM -0500, Robin Holt wrote:
> perfmon has a need to get memory allocated and prefaulted for a shared
> buffer between user and kernel.  The memory is read-only to the user.
> The hardware performance counter values are inserted into those pages.
> Pages can not be faulted during sampling as we only have nano to micro
> seconds to capture the values with accuracy.  What is the right way to
> accomplish this?

Allocate the pages using alloc_page and then insert it using vm_insert_page.
In case you need a contiguous mapping use vmap to establish it, but it
would be better if we could avoid that part to not eat up too much
vmalloc space.

Note that all this should happen from a ->mmap method and not from
other magic calls.  Nothing but calls to mmap (or related syscalls)
should change the user address space.

> Currently, the user is calling the kernel with a number of sample entries
> for a single cpu's buffers.  The kernel turns this into a buffer size
> and calls vmalloc to get a kernel virtually contiguous address range.
> It then sets PG_RESERVED on all those pages and calls remap_pfn_range()
> to insert page table entries into the users address space.  Additionally,
> it is updating locked_vm on the tasks mm.
> 
> I think this should really become do_mmap(), followed by get_user_pages().

Not at all.  do_mmap is not something anyone but the various mmap
implementation should call.  Having this function exported at all
is a tragic historic coincidence  involving a few graphics hackers
and lots of illegal drugs.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-07 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-07 11:48 What is the right way to prefault and pin pages for perfmon? Robin Holt
2007-05-07 12:20 ` Christoph Hellwig

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.