kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Capturing all writes as fault on a memory mapped page.
Date: Wed, 28 May 2014 07:25:29 -0700	[thread overview]
Message-ID: <20140528142529.GA24250@kroah.com> (raw)
In-Reply-To: <CA+aCy1GnDMxjcr9XyKRNrxPAAR1CwEwJiQdijY=nE4bVcJ=Ljw@mail.gmail.com>

On Wed, May 28, 2014 at 07:13:55PM +0530, Pranay Srivastava wrote:
> Actually trying to do something like if there's a write being done on
> the page by a task currently then other tasks should wait( was hoping
> that the fault handler code would be called for write but doesn't
> happen that way).

If you have multiple writers on the same page, why would you want any
other writer to wait?  That's the joy of mmap, you don't have to worry
about any of this from userspace, the kernel backing store handles it
all for you automatically.

> Yes through write operation I can do with mutex but I was wondering
> what if this has to be done through mmap of my misc_device then no
> read/write calls involved so just wanted to see how would I stop
> multiple writes to my misc_device.

Either you don't allow multiple opens, or you just live with the mess
that userspace is wanting to do here.

> Perhaps there are other methods as to how device memory can be mapped
> to user space? or they aren't at all? Not really sure just reading and
> trying.

As you mapped it to userspace, it's now up to the user to deal with any
serialization that it wants to enforce, it's out of the hands of your
misc driver.

good luck,

greg k-h

  reply	other threads:[~2014-05-28 14:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28 13:17 Capturing all writes as fault on a memory mapped page Pranay Srivastava
2014-05-28 13:29 ` Greg KH
2014-05-28 13:43   ` Pranay Srivastava
2014-05-28 14:25     ` Greg KH [this message]
2014-05-28 14:38       ` Pranay Srivastava

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140528142529.GA24250@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).