public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Michael.McTernan.2001@cs.bris.ac.uk (Michael McTernan)
To: linux-arm-kernel@lists.infradead.org
Subject: mm: get_user_pages_fast()
Date: Wed, 06 Nov 2013 19:38:33 +0000	[thread overview]
Message-ID: <527A9AB9.8060306@cs.bris.ac.uk> (raw)
In-Reply-To: <20131106105400.GV16735@n2100.arm.linux.org.uk>

On 11/06/2013 10:54 AM, Russell King - ARM Linux wrote:
> Firstly, please stop this madness.

In the context of an embedded system, where memory is shared between 
CPUs, DSP, FPGAs and some peripherals, and where the SCU is maintaining 
coherency on selected areas, this is a feature of the platform, not 
madness.

 > Placing futexes in IO memory is not supported, period.

Except the _PRIVATE futex calls do work fine in IO memory since they 
don't walk the process page tables to determine the 'key' from the 
address.  These a limited to only sync between threads in the same 
processes though.

 > You can't map random bits of /dev/mem and expect
 > this stuff to work.

Nothing I am mapping is random.

> (b) you are allowed to map memory outside of that, but you get it as
> strongly ordered memory.
>
> (b) means that the load/store exclusives, which userspace mutexes will
> use on ARMv6+, will not work correctly.
> (they're not supported to strongly ordered memory by the architecture.)

I don't see this stated in the ARM Architecture Reference Manual. 
Instead I see it saying that it is implementation dependent whether 
LDREX and STREX work on strongly ordered memory (section A3.4.5).

> In other words, don't put mutexes in memory you've remapped from /dev/mem.
> In fact, as an application, you should not be mapping /dev/mem at all.

It's certainly more standard to map the mutexes() out of something like 
file backed mmap(), but that isn't as elegant for my application.

To give a bit of background, what we have is some memory at a know 
address which controls a peripheral.  Part of the peripheral addresses 
are buffers and registers, but some is set aside for use by software. 
Being able to map this whole section into userspace makes for really 
fast fast-paths where the driver is basically outside the kernel.  Also 
keeping driver state variables in the peripheral RAM means things can be 
restarted if the Linux processes crash or die, or even if the whole of 
Linux were to be restarted for some reason.  So it's more than 
convenient to have the mutexes work there, though as an easier goal I'll 
probably just get the futex calls to work for my applications.

Hopefully this doesn't sound as mad as first assumed & thanks for your time.

Kind Regards,

Mike

  parent reply	other threads:[~2013-11-06 19:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 22:43 mm: get_user_pages_fast() Michael McTernan
2013-11-06 10:19 ` Will Deacon
2013-11-06 10:54 ` Russell King - ARM Linux
2013-11-06 11:07   ` Will Deacon
2013-11-06 19:38   ` Michael McTernan [this message]
2013-11-06 19:57     ` Russell King - ARM Linux
2013-11-06 22:31       ` Michael McTernan

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=527A9AB9.8060306@cs.bris.ac.uk \
    --to=michael.mcternan.2001@cs.bris.ac.uk \
    --cc=linux-arm-kernel@lists.infradead.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