Re: user_to_phys() without mmap?



Neil Steiner <neil.steiner@xxxxxx> writes:
I'm trying to use a framebuffer from user space (think plain video
ram, not some PCI or AGP video card), but mmap'ing from kernel space
into user space is causing large latencies and unsightly artifacts.
It appears that anything written into the mmap'ed user memory is in
fact being copied into kernel space.

Theoretically, this could probably be implemented with help of the
MMU and some 'weird' fault handling, but I don't think someone would
take the trouble, because it seems pretty useless. The /dev/mem driver
certainly doesn't do this. Only the MMU will interfere accesses to
virtual memory locations from user space, except for faults caused by
this accesses.

What I was actually hoping was that the memory manager would simply
map the underlying physical pages directly into the user's address
space. I think that's simple enough to do in theory, but there is
much that I don't know about Linux kernel internals, so in practice
who knows?

I do :-). But the code isn't really that complicated. What it
basically does is set up page table entries for the range you
requested. Assuming you are using /dev/mem, could it be possible
that you are accessing cached memory?

static int mmap_mem(struct file * file, struct vm_area_struct * vma)
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;

/*
* Accessing memory above the top the kernel knows about or
* through a file pointer that was marked O_SYNC will be
* done non-cached.
*/
if (noncached_address(offset) || (file->f_flags & O_SYNC))
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
(../linux/drivers/char/mem.c)

.



Relevant Pages

  • [PATCH] uaccess.h: match kernel-doc and function names
    ... * Context: User context only. ... * Copy data from kernel space to user space. ... * On success, this will be zero. ...
    (Linux-Kernel)
  • Re: kernel space and user space in RHEL AS3.0
    ... IBM machine has 16GB physical Memory What size estimate ... Kernel space and User space? ... Some Oracle articles say that Oracle VLM can allocate Physical ... Mem to User space as database cache. ...
    (alt.os.linux)
  • Re: User space vs kernel space device access
    ... > limited to it's memory mapped registers. ... > the device by mapping it's memory region into user space. ... blocks of data to/from the device, a device driver will perform better. ... adding kernel space code can make the kernel instable ...
    (comp.os.linux.embedded)
  • Re: [RFC] SPI core -- revisited
    ... >DMA to copy data from user to kernel space? ... >cause page faults which ensure that the user space pages are paged in ... where dev is actually an SPI device. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Virtual memory - user space kernel space
    ... I m having some questions in Linux memory management. ... If you have a 512 MB of memory, how it is divided between kernel space ... you bumble virtual and physical memory. ... memory between kernel space and user space, ...
    (comp.os.linux.development.system)