linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Benjamin C.R. LaHaise" <blah@kvack.org>
To: Richard Guenther <richard.guenther@student.uni-tuebingen.de>
Cc: Linux Kernel List <linux-kernel@vger.rutgers.edu>,
	glame-devel@lists.sourceforge.net, Linux-MM <linux-mm@kvack.org>
Subject: Re: mmap/munmap semantics
Date: Tue, 22 Feb 2000 13:41:27 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.3.96.1000222133019.4098B-100000@kanga.kvack.org> (raw)
In-Reply-To: <Pine.LNX.4.10.10002221702370.20791-100000@linux14.zdv.uni-tuebingen.de>

On Tue, 22 Feb 2000, Richard Guenther wrote:

> Hi!
> 
> With the ongoing development of GLAME there arise the following
> problems with the backing-store management, which is a mmaped
> file and does "userspace virtual memory management":
> - I cannot see a way to mmap a part of the file but set the
>   contents initially to zero, i.e. I want to setup an initially
>   dirty zero-mapping which is assigned to a part of the file.
>   Currently I'm just mmaping the part and do the zeroing by
>   reading from /dev/zero (which does as I understand from the
>   kernel code just create this zero mappings) - is there a more
>   portable way to achieve this?

Do you mean that you want to go above and beyond what ftruncate does?  If
that's the case, reading from /dev/zero is probably the easiest thing,
although I suspect doing a sendfile from /dev/zero to the file will
ultimately end up being more efficient.

If you are managed to do a read from /dev/zero into a shared file mapping
beyond the end of file without getting a SIGBUS, then that's a bug.

> - I need to "drop" a mapping sometimes without writing the contents
>   back to disk - I cannot see a way to do this with linux currently.
>   Ideally a hole could be created in the mmapped file on drop time -
>   is this possible at all with the VFS/ext2 at the moment (creating
>   a hole in a file by dropping parts of it)?

No, this is insanity.  Creating holes in the middle of files actually cam
up when talking about ext2 changes, and frankly it doesn't make sense. 
For example: on a filesystem that uses extents, creating a hole in the
middle of a file means that you might have to allocate more disk space in
order to free the disk space.

> So for the first case we could add a flag to mmap like MAP_ZERO to
> indicate a zero-map (dirty).

Or teach truncate about preallocation.

> For the second case either the munmap call needs to be extended or
> some sort of madvise with a MADV_CLEAN flag? Or we can just adjust
> mprotect(PROT_NONE) and subsequent munmap() to do the dropping?

Remember that madvise is only giving the system hints about what you want
it to do.  If madvise allows you to mark a dirty page as clean without
doing a writeback, that could result in stale data residing in the page
cache for other users to come along and read without that data going to
disk -- not behaviour I want to see.  If read returns it, it should be on
disk.

		-ben

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

  parent reply	other threads:[~2000-02-22 18:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-22 17:46 Richard Guenther
2000-02-22 18:36 ` James Antill
2000-02-22 18:41 ` Benjamin C.R. LaHaise [this message]
2000-02-23 10:57   ` Richard Guenther
2000-02-23 15:58     ` Benjamin C.R. LaHaise
2000-02-24 10:06       ` Richard Guenther
2000-02-22 21:48 ` Richard Gooch
2000-02-23  3:49 ` Eric W. Biederman
2000-02-23 11:14   ` Richard Guenther
2000-02-23 15:44   ` Jamie Lokier
2000-02-23 18:48 ` Stephen C. Tweedie
2000-02-24  2:35   ` Jamie Lokier
2000-02-24 12:13     ` Stephen C. Tweedie
2000-02-24 12:24       ` Richard Guenther
2000-02-24 13:51         ` Stephen C. Tweedie
2000-02-24 15:01         ` kernel
2000-02-24 15:03           ` Richard Guenther
2000-02-24 15:15             ` Jamie Lokier
2000-02-24 13:06       ` lars brinkhoff
2000-02-24 14:42         ` Jamie Lokier
2000-02-24 13:41       ` Eric W. Biederman
2000-02-24 13:49         ` Stephen C. Tweedie

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=Pine.LNX.3.96.1000222133019.4098B-100000@kanga.kvack.org \
    --to=blah@kvack.org \
    --cc=glame-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.rutgers.edu \
    --cc=linux-mm@kvack.org \
    --cc=richard.guenther@student.uni-tuebingen.de \
    /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