public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: mszeredi@suse.cz, linux-kernel@vger.kernel.org,
	fuse-devel@lists.sourceforge.net, polynomial-c@gentoo.org,
	akpm@linux-foundation.org
Subject: Re: [fuse-devel] [PATCH] FUSE/CUSE: implement direct mmap support
Date: Wed, 10 Feb 2010 20:22:07 +0900	[thread overview]
Message-ID: <4B7296DF.207@kernel.org> (raw)
In-Reply-To: <E1NerZ6-0007N6-UY@pomaz-ex.szeredi.hu>

Hello, Miklos.

On 02/09/2010 11:59 PM, Miklos Szeredi wrote:
> On Tue, 09 Feb 2010, Tejun Heo wrote:
> Okay, I'm a bit confused about these offsets.
> 
> Client asks to map a file at an offset.  Server receives offset, may
> change it (but only by multiple of SHMLBA) then returns it to the
> kernel.  The returned offset globally identifies not only the mapped
> region but the page within the region.  Sounds neat.
> 
> But then fuse_do_mmap() goes and changes vma->vm_pgoff, which will
> show up in /proc/PID/maps for example, which is really not nice.
>
> Can't this page ID rather be put in vma->vm_private_data?

Yeah, sure, it can be put anywhere.  I just never thought about it
being visible under /proc.  Will move it inside fuse_dmmap_vm.

> Also can we take this page ID abstraction a step further, and say that
> the ID has nothing to do with the original offset, the only
> requirement is that it'd globally identify all direct mapped pages.
> 
> And the coherency requirements would be satisfied by the
> fuse_dev_mmap() code.  Haven't looked into what that would take, but
> it sounds doable.

The coherency requirement is not really between the address and offset
but virtual addresses different maps which may end up sharing the same
physical page.  On an architecture with virtually indexed but
physically tagged caches, virtual addresses which map to the same page
must end up hitting the same cache group; otherwise, the processor
wouldn't be able to determine whether the two addresses point to the
same page (as only the tags inside the same cache group are matched
against the physical address).

This is achieved by enforcing address to offset alignment.  IOW, all
maps are forced to be SHMLBA aligned to offset so that all maps are
SHMLBA aligned to each other.  And without knowing which maps are
gonna end up sharing which pages beforehand, enforcing SHMLBA
alignment against something is pretty much the only way to achieve
this and that's the reason why something as low level as processor
cache orgnization is exported to userland as SHMLBA for shared memory
in the first place.

FUSE dmmap has exactly the same problem as it basically is a shared
memory implementation with slightly different interface.  Unless we
can know which maps are gonna be shared beforehand, and we can't know
this either for between the client and server or between clients, the
only way to make those shared mappings fall into the same cache slot
is aligning them to address space offsets.

So, I don't think it's feasible to do the address matching from inside
the kernel without a lot of convolution.  The only way to do it would
be adjusting the mapping addresses but this has at least two problems
- 1. the VM layer isn't made that way and virtual address is
determined by vm generic and arch code before ->mmap() is invoked and
can't be changed after that.  2. the SHMLBA alignment is good in the
sense that it gives the userland something to rely on when determining
mapping address for address hint or fixed mapping.  I don't think it
would be wise to break such assumptions which hold for *ALL* existing
memory mappings.

Thanks.

-- 
tejun

  reply	other threads:[~2010-02-10 11:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09  6:08 [PATCH] FUSE/CUSE: implement direct mmap support Tejun Heo
2010-02-09 14:59 ` [fuse-devel] " Miklos Szeredi
2010-02-10 11:22   ` Tejun Heo [this message]
2010-02-10 11:29     ` Miklos Szeredi
2010-02-10 11:56       ` Tejun Heo
2010-02-10 12:15         ` Miklos Szeredi
2010-02-10 12:35           ` Tejun Heo
2010-02-10 15:02             ` Miklos Szeredi
2010-02-10 23:43               ` Tejun Heo
2010-02-11  9:31                 ` Miklos Szeredi
2010-02-11  9:51                   ` Miklos Szeredi
2010-02-11 11:54                     ` Tejun Heo
2010-02-11 12:25                       ` Miklos Szeredi
2010-02-11 12:49                         ` Tejun Heo
2010-02-11 12:46                           ` Miklos Szeredi
2010-02-11 13:05                             ` Tejun Heo
2010-02-11 13:08                               ` Miklos Szeredi
2010-02-11 13:40                                 ` Tejun Heo
2010-02-11 11:47                   ` Tejun Heo
2010-02-11 12:34                     ` Miklos Szeredi
2010-02-11 12:56                       ` Tejun Heo
2010-02-11 13:01                         ` Miklos Szeredi
2010-02-11 13:30                           ` Tejun Heo
2010-02-11 13:40                             ` Miklos Szeredi
2010-02-11 13:58                               ` Tejun Heo
2010-02-11 14:40                                 ` Miklos Szeredi
2010-02-12  0:07                                   ` Tejun Heo
2010-02-12  0:25                                     ` Tejun Heo
2010-02-12  9:55                                     ` Miklos Szeredi
2010-02-12 13:33                                       ` Tejun Heo
2010-02-12 13:53                                         ` Miklos Szeredi
2010-02-12 17:56                                           ` Tejun Heo
2010-02-10 11:36     ` Tejun Heo
2010-02-10  8:24 ` Goswin von Brederlow
2010-02-10  8:40   ` Miklos Szeredi
2010-02-10  8:58   ` Paul Schutte
2010-02-10 10:02     ` Paul Schutte

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=4B7296DF.207@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@suse.cz \
    --cc=polynomial-c@gentoo.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