Re: do_mmap() question

Jim Garlick (garlick@llnl.gov)
Wed, 22 Sep 1999 08:38:52 -0700 (PDT)


I ended up changing a few lines in mm/mmap.c to create a new do_mmap_anon()
interface that takes a vm_operations_struct pointer and tacks it on to the
newly created vma before the call to merge_segments(). This allows one to
map a new memory object (with its own vm_ops) into user space outside of the
context of an mmap() or other f_op call.

I also added a void *vm_data member to vm_area_struct which points to vm_ops
implementation-specific data (you pass it in to do_mmap_anon() and pull it
out in the vm_ops functions if needed). In this way I can associate a memory
object with a particular PCI card and fault in physical pages from the right
card if there is more than one.

I'd be curious if these interfaces would be useful to anyone besides me, i.e.
are my odds of getting them accepted into the distribution as slim as I would
guess?

Your point about fighting the system is well taken. On the other hand, this
is a port of a large amount of software from two SVR4-derived commercial
unixes, and reworking the basic interfaces will cause much pain and suffering.
(Maybe we will end up redesiging, but for now I just need to get the thing to
work without turning it into an #ifdef nightmare).

Thanks,

Jim

On Tue, 21 Sep 1999, Alan Cox wrote:

> > I need to create a user mapping to some SDRAM on a PCI board, but I can't
> > do it via a regular file operation like mmap() or ioctl(). Instead, the
> > mapping should be a side-effect of a device-specific system call I have added.
>
> "device specific system call". When I hear that I worry. It means someone
> didnt get the model
>
> > Further, I want the mapping to have its own vma so I can override the vm_ops
> > and wire in my SDRAM allocator.
>
> Your driver specific mmap routine can set up specific vm ops if it needs to.
>
> > What's the right way to do this? Am I just trying to be too wierd?
>
> It sounds like you are fighting the system not using it. Your PCI board
> is a device. You open it, mmap it and close it. It may not be the API you
> want to present to an application but that is a user space library
> issue.
>
> Alan
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/