linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: fuse, get_user_pages, flush_anon_page, aliasing caches and all that again
Date: Thu, 21 Dec 2006 16:57:44 +0000	[thread overview]
Message-ID: <20061221165744.GD3958@flint.arm.linux.org.uk> (raw)
In-Reply-To: <E1GxQF2-0000i6-00@dorka.pomaz.szeredi.hu>

On Thu, Dec 21, 2006 at 04:53:56PM +0100, Miklos Szeredi wrote:
> I'll first answer the last paragraph.
> 
> > I suggest that in order for fuse to work reliably on ARM, it is modified
> > to behave more like a reasonable device driver, and use the functions
> > defined in asm/uaccess.h when it wants to access the current processes
> > VM space.
> 
> Fuse needs to use get_user_pages() to work around certain deadlock
> scenarios (see Documentation/filesystems/fuse.txt), that are
> problematic with copy_*_user().

Hmm, okay (though the documentation doesn't really provide enough
explaination for me to get a grasp of exactly what's going on.)

> > However, and this is the problem, we need cache maintainence _after_
> > that memcpy() has completed - with a write allocate VIVT cache, the
> > memcpy() itself will allocate cache lines in the kernel mapping of
> > the page which will need to be written back for the user process to
> > see that data.
> 
> Yes, note the flush_dcache_page() call in fuse_copy_finish().  That
> could be replaced by the flush_kernel_dcache_page() (added by James
> Bottomley together with flush_anon_page()) when all relevant
> architectures have defined it.

I'm not entirely convinced that it can be replaced.  What if the page
is in the page cache and is shared with other processes?  That quite
clearly falls under flush_dcache_page()'s remit.

> > Now, throw in SMP or preempt with a multi-threaded userspace program
> > touching the page in question, and the problem just gets much much
> > worse.  In such a scenario, we can not guarantee, no matter how much
> > cache maintainence is applied to the kernel, that this API comes
> > anywhere near to being safe.
> 
> This is only problematic if multiple threads are touching the same
> page, no?  If the page(s) used for reading/writing requests are
> exclusive to each thread, then there should be no problem.  This is a
> reasonable requirement towards the userspace filesystem I think.

Such a restriction needs to be clearly documented against get_user_pages()
so that users don't expect something from it which it can't deliver.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

  reply	other threads:[~2006-12-21 16:58 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-21 15:26 fuse, get_user_pages, flush_anon_page, aliasing caches and all that again Russell King
2006-12-21 15:53 ` Miklos Szeredi
2006-12-21 16:57   ` Russell King [this message]
2006-12-21 17:51     ` Miklos Szeredi
2006-12-21 21:04       ` Jan Engelhardt
2006-12-21 21:30         ` Miklos Szeredi
2007-01-01 15:04     ` James Bottomley
2006-12-21 17:17   ` Russell King
2006-12-21 17:55     ` Miklos Szeredi
2006-12-21 18:11       ` Russell King
2006-12-21 18:30         ` Miklos Szeredi
2006-12-21 18:55           ` Russell King
2006-12-21 19:05             ` Miklos Szeredi
2006-12-21 23:51               ` Randolph Chung
2006-12-22  8:43                 ` Russell King
2006-12-22 14:45                   ` Randolph Chung
2006-12-30 16:39     ` Russell King
2006-12-30 16:50       ` Russell King
2006-12-30 18:26         ` Linus Torvalds
2006-12-30 22:46           ` Russell King
2006-12-31  5:23             ` David Miller
2006-12-31  9:10               ` Miklos Szeredi
2006-12-31  9:45                 ` David Miller
2006-12-31  9:23               ` Russell King
2006-12-31  9:27                 ` Arjan van de Ven
2006-12-31  9:47                   ` David Miller
2006-12-31 10:00                     ` Russell King
2006-12-31 10:04                       ` David Miller
2006-12-31 12:24                       ` Miklos Szeredi
2006-12-31 17:37                         ` Russell King
2007-01-01 22:15                           ` Miklos Szeredi
2007-01-01 23:45                             ` Russell King
2007-01-02 19:40                               ` Dan Williams
2007-01-02 22:53                               ` James Bottomley
2007-01-02 23:19                                 ` David Miller
2007-01-02 23:34                                   ` James Bottomley
2007-01-03  0:20                                     ` David Miller
2007-01-03 14:16                                       ` Russell King
2007-01-03 15:00                                         ` James Bottomley
2007-01-03 15:09                                           ` Russell King
2007-01-07 16:09                                             ` James Bottomley
2007-01-07 16:30                                               ` Russell King
2006-12-31 20:40                         ` David Miller
2006-12-31 20:58                           ` Linus Torvalds
2006-12-31 21:12                             ` David Miller
2007-01-01 16:44                               ` James Bottomley
2007-01-01 23:04                                 ` David Miller
2007-01-01 23:23                                   ` James Bottomley
     [not found]                     ` <1167669252.5302.57.camel@mulgrave.il.steeleye.com>
2007-01-01 23:01                       ` David Miller
2007-01-01 23:17                         ` Russell King
2006-12-31  9:55                   ` Russell King
2006-12-31  9:46                 ` David Miller
2007-01-01 14:35           ` James Bottomley
2007-01-01 16:21             ` Russell King
2006-12-30 18:21       ` Linus Torvalds
2006-12-21 16:29 ` Arjan van de Ven
2006-12-21 17:35   ` Russell King

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=20061221165744.GD3958@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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).