public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Michael Schnell <mschnell@lumino.de>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
	"nios2-dev" <nios2-dev@sopc.et.ntust.edu.tw>
Subject: Re: atomic RAM ?
Date: Mon, 12 Apr 2010 17:02:35 +0200	[thread overview]
Message-ID: <201004121702.35237.arnd@arndb.de> (raw)
In-Reply-To: <4BC2EEBD.3070504@lumino.de>

On Monday 12 April 2010, Michael Schnell wrote:
> > You already need that with a non-SMP system anyway. As Alan explained,
> > futex is only an optimization for a relatively uninteresting case
> > (multi-threaded user applications), you really need to solve this for
> > kernel space first, because the kernel is inherently multi-threaded.
> >   
> I don't see why optimizing for speed and especially latency is
> uninteresting (with embedded systems like the one I'm planning).
> 
> Multi-threaded user applications is exactly the case that is extremely
> interesting to me and that is why I started this discussion. The
> non-SMP-Kernel ( and non-FUTEX)  case already is solved for NIOS
> (supposedly by interrupt disabling). An SMP-Linux is not yet crafted
> (and for me its a lot lower priority than decent user-space
> multithreading, but of course it is a valuable task).

Ok. Your initial post didn't make it clear that this is all you are
looking for. While atomic CPU operations would solve this problem,
you don't really need to make the RAM access itself atomic,
only the instruction flow.

> > If you want to have atomics in user space, why not go all the way and
> > make a small extension to your cache coherency logic to do load-locked/
> > store-conditional as well.
> Of course doing load-locked, store-conditional custom instructions was
> an option I did consider, but as there is no way to access memory
> through cache and MMU with custom instructions, I don't see how this
> could be done, as the current way FUTEX works, the code will define the
> DWORDs to be handled atomically anywhere in the user space memory. Of
> course disabling the cache completely is not an option for a task that
> is aimed to improve user space performance.

Right. So if you cannot implement a 'test-and-set', 'exchange' or
'store-conditional' instruction, I don't think any custom instructions
will help you.

You can probably implement an atomic function in a VDSO though, without
any CPU extensions, I think this has been discussed for blackfin
before. The idea is to let the kernel check if the instruction pointer
is in the critical section of the VDSO while returning to user space.
If it is, the kernel can jump back to the caller of that function
instead of the function itself, and indicate failure so the user can
retry.

	Arnd

  reply	other threads:[~2010-04-12 15:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-08  7:32 atomic RAM ? Michael Schnell
     [not found] ` <4BBDA1CB.3070204@davidnewall.com>
2010-04-08  9:52   ` Michael Schnell
2010-04-12 12:54     ` Pavel Machek
2010-04-14  8:42       ` Michael Schnell
     [not found] ` <k2gbca41b4c1004080243nc45a10aereaae18557808c943@mail.gmail.com>
2010-04-08 10:12   ` Michael Schnell
2010-04-08 10:45 ` Alan Cox
2010-04-08 12:11   ` Michael Schnell
2010-04-08 12:14     ` David Miller
2010-04-08 12:30       ` Michael Schnell
2010-04-08 14:15         ` Arnd Bergmann
2010-04-09 10:54           ` Michael Schnell
     [not found]           ` <4BBEECC8.10005@lumino.de>
     [not found]             ` <201004091714.04990.arnd@arndb.de>
2010-04-12  9:58               ` Michael Schnell
2010-04-12 15:02                 ` Arnd Bergmann [this message]
2010-04-13 10:11                   ` Michael Schnell
     [not found]                 ` <u2j42b5547a1004120845x87d7f2f7wd4acea1144153dd6@mail.gmail.com>
2010-04-13  8:39                   ` [Nios2-dev] " Michael Schnell
2010-04-08 13:37     ` Alan Cox
2010-04-09 10:55       ` Michael Schnell
2010-04-09 11:54         ` Alan Cox
2010-04-09 12:53           ` Michael Schnell
2010-04-09 13:15             ` Alan Cox
2010-04-09 13:14               ` Michael Schnell
2010-04-09 13:32               ` Michael Schnell
2010-04-14 12:46       ` Michael Schnell
2010-04-14 12:57         ` Alan Cox
2010-04-14 14:38           ` Michael Schnell
2010-04-09  1:36 ` Mike Frysinger
2010-04-09  9:23   ` Michael Schnell

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=201004121702.35237.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mschnell@lumino.de \
    --cc=nios2-dev@sopc.et.ntust.edu.tw \
    /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