mmap - post/pre actions

Pranay Srivastava pranjas at gmail.com
Wed Sep 16 05:02:35 EDT 2015


Hi Ran

On Wed, Sep 16, 2015 at 1:10 AM, Ran Shalit <ranshalit at gmail.com> wrote:
> Hello,
>
> I need to implement mmap for non-volatile memory chip (NVRAM).
> I already did something simple, but now I understand that it is not complete:
> The nvram need to be unlock and locked after finishing the memory task
> of read/write.

I guess you are better off with an ioctl call to the driver and be
done with the read/write. You won't get
faults once you've mapped it. So I don't think you can do locking via
your driver after that.

If you are thinking of doing something like below

P1--->mmap--->driver [OK]
P2-->mmap--->driver[OK]

You won't be able to get the faults for the below cases as you would've already
filled the vma for that in your vm_fault handler.

P1--->writes to mmaped [No fault]
P2--->writes to mmaped [No fault]

You can't lock once both have mapped. What you can do is provide a
different mapping[?] and then
sync that mapping I guess? But that's just insane.

If you say that subsequent mmap would fail then again you'll have to
code user-space to work with this.

Better off with ioctl rather than mmap.
>
> Does mmap can handle such post/pre actions or not ( I guess that if
> not -  I will need to use read/write alternatives) ?
>
> Thank you,
> Ran
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
        ---P.K.S



More information about the Kernelnewbies mailing list