Quesion on mmap

pramodh mallipatna (pramodh@ittc.ukans.edu)
Mon, 13 Dec 1999 00:20:57 -0600 (CST)


Hi All,

I had written to the list sometime back about mmap problem.

A brief overview:

I have a device driver where I have mmap() option implemented. From my
user code, I call mmap() system call which returns a valid pointer. I can
check this by looking at the pointer, looking at /proc/my_pid/maps which
shows the same starting pointer. Also, I am able to write (in the user
space) to the memory area without seg faults (If I try writing (in user
space) more than what I have allocated, it seg faults, which confirms I am
writing to the memory I allocated)

Problem:

I memset each element to 1 and try reading in the user space, it shows
only zeros. Also, if I write in the user space, I do not see it in the
kernel.

A gentleman suggested there was probably a nopage() operation happening.
I mlock() the memory area from the user space, but it does not help. Also,
mlock returns Success (I do not know if I can rely on this, but still).

When I looked at the old_mmap() and do_mmap() fns in the kernel, I find
vma->vm_ops initialized to NULL. Now, how can I see what is happening?
Can I assign vm_ops in my driver to check if a nopage is happening?

What else should I do in order to see the changes I have made to the
memory area (both in the kernel and the user).

In my user code, I call mmap() as below.

rptr = mmap((void *)0, (PAGE_SIZE*10), PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd, 0);

Are the flags and prot args correct?

TIA,
Pramodh

-
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/