All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benno Senoner <sbenno@gardena.net>
To: linux-sound@vger.kernel.org
Subject: Re: mmap()/mlockall()/read()
Date: Wed, 27 Oct 1999 18:03:00 +0000	[thread overview]
Message-ID: <marc-linux-sound-94105784218465@msgid-missing> (raw)
In-Reply-To: <marc-linux-sound-94095888330340@msgid-missing>

I agree no all topics,

using mlockall(MCL_CURRENT|MCL_FUTURE) on a low mem box,
and trying to mmap a large file would simply not work.

I would definitively use MAP_UNLOCKED on Linux,
becaue it could give us the best possible performance.
(and maybe provide a fallback solution for other OSes) 

I think the best fallback solution is the following (but not 100% reliable
in the case of syscalls):
mlock(MCL_CURRENT);
mlock() malloec()ed aread
( or is there a better way to do this ?)


but strange,
MAP_UNLOCKED seems to not exist on my 2.2.12 kernel !!
I grepped through the entire kernel source and include files but
nothing !!!!!

in /usr/include/bits/mman.h
there are some flags:
----
/* These are Linux-specific.  */
#ifdef __USE_MISC
# define MAP_GROWSDOWN  0x0100          /* Stack-like segment.  */
# define MAP_DENYWRITE  0x0800          /* ETXTBSY */
# define MAP_EXECUTABLE 0x1000          /* Mark it as an executable.  */
# define MAP_LOCKED     0x2000          /* Lock the mapping.  */
# define MAP_NORESERVE  0x4000          /* Don't check for reservations.  */
#endif
----

no MAP_UNLOCKED present ...
is this a 2.3.x feature ?


> > What I'm trying to say: read() doesn't work better than mmap() in terms of
> > behaviour during swapping, because the kernel could easily swap out
> > your buffer where you read() in the data.
> 
> Actually, the last time I tested this extensively (with a 2.0.x kernel
> I think), mmap() was much better performing than read()..for a while.
> When sequential accessing of a file got to a point around my RAM
> limits, the disk activity became insane.  Maybe things are better now.
> 
> > I will add a feature to the pagefaulter thread which uses mlock()/munlock if
> > root privileges are available, so that even
> > Eric is satisfied.
> > :-)
> 
> Eric is hard to satisfy. :)

You are not the only !
:-)

> 
> > PS: mlockall(MCL_CURRENT|MCL_FUTURE) is a bad idea because when you do the
> > mmap() of the large file the process tries to load all into mem,and my scheme
> > would not work. Better to use mlockall(MCL_CURRENT) and mlock()/munlock()
> > areas on demand.
> 
> This is a useful solution in some circumstances.  However, it means I
> can't use malloc()/new, may have trouble with shared libraries or
> dynamically loaded plugins and have to worry about reserving stack
> space.  It's not the way I want to work.

agreed for shared libs, but if you don't make any strange syscalls ,
I think there are not very much problems.
As for malloc : just mlock() the area after the allocation.

regards,
Benno.

  reply	other threads:[~1999-10-27 18:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-26 17:10 mmap()/mlockall()/read() est
1999-10-27 18:03 ` Benno Senoner [this message]
1999-10-27 21:15 ` mmap()/mlockall()/read() est

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=marc-linux-sound-94105784218465@msgid-missing \
    --to=sbenno@gardena.net \
    --cc=linux-sound@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.