LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-14-2007, 07:58 PM   #1
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Rep: Reputation: 0
Can Demand Paging be disabled or circumvented?


Is it possible to turn off or circumvent demand paging in Linux? I need to be able to load an entire executable into memory before it executes and not just have one page at a time be loaded. Our application cycle times cannot tolerate page faults.

Thanks.
 
Old 12-15-2007, 01:37 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,554

Rep: Reputation: 182Reputation: 182
Try the swapoff command:

swapoff -a

see:

man swapoff

------------------
Steve Stites
 
Old 12-15-2007, 04:57 PM   #3
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Swapoff

Wouldn't that only affect a program AFTER it is already loaded in memory? That would prevent it from being swapped back out, but would it fix the problem of demand paging the executable in in the first place?
 
Old 12-15-2007, 06:03 PM   #4
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,554

Rep: Reputation: 182Reputation: 182
Quote:
Originally Posted by ajmayhall View Post
Wouldn't that only affect a program AFTER it is already loaded in memory? That would prevent it from being swapped back out, but would it fix the problem of demand paging the executable in in the first place?
Turn swap off before the program gets loaded for the first time.

---------------------
Steve Stites
 
Old 12-15-2007, 07:25 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
In another universe I would allocate page-fixed storage, fetch my (entire) executable into it (once), then transfer control to it.
Sorry, I don't know how to do that in *nix. Got me interested though ...
 
Old 12-15-2007, 08:54 PM   #6
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Original Poster
Rep: Reputation: 0
That's what I was thinking as well

I was thinking the same thing, but don't really know how to do that in Linux either. I have done that on SBCs in the past in assembler though.
 
Old 12-15-2007, 10:00 PM   #7
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 241

Rep: Reputation: 45
check out:
Code:
man mlockall
 
Old 12-15-2007, 10:18 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Looks handy.
Got any thoughts on how a program (and any shared objects) can be force loaded in their entirety ???.

Just academic interest in my case ...
 
Old 12-15-2007, 10:28 PM   #9
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 241

Rep: Reputation: 45
Sorry, I don't know anything about using it, but like you my interest was piqued by this post.

I googled a bit and found this, where the guy wrote a C wrapper for his program.

Norm
 
Old 12-16-2007, 07:05 AM   #10
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Original Poster
Rep: Reputation: 0
mlockall

We use mlockall, but if you notice, there are two flags used, current and future. It locks the pages in and keeps them from being swapped out AFTER the fact. It won't force the executable to be paged in completely at first. If you look into the source for exec.c, the comments from Linus tell the story. He only loads the header and lets demand paging do the rest.
 
Old 12-16-2007, 12:27 PM   #11
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 241

Rep: Reputation: 45
You've probably thought of this, but how about loading the app to a ramdisk? Would that speed things up enough to make the page faults tolerable?

Norm
 
Old 12-16-2007, 01:06 PM   #12
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Original Poster
Rep: Reputation: 0
RAM disk

We tried that Friday, it still didn't eliminate the timing issue, the page faults seem to still be taking too much time even using a RAM disk.
 
Old 12-16-2007, 07:00 PM   #13
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
What if you ran an assurance test when the program loaded? If you run each function that you need and access each memory location, then your application can start it's real work. This will increase load time, and may be risky if a part of a function lands in a different page that doesn't get loaded.

(I'm not qualified to help here, I'm just curious.)
 
Old 12-16-2007, 08:04 PM   #14
ajmayhall
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Original Poster
Rep: Reputation: 0
We do that now

We try to do that now, unfortunately, we cannot guarantee that we take all the branches the programs will take when they run. That seems to be the only current way to ensure all the pages get pulled into RAM and get mlocked in, we also try to make sure that we initialize all the data as well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on Paging !! rdayal73 AIX 1 05-24-2007 06:10 PM
Possible paging problem? Roasties Linux - Server 2 04-23-2007 01:46 PM
Paging malru AIX 1 06-16-2006 09:34 AM
Paging Linareuser bigiron45 Linare 4 01-09-2005 01:19 PM
about two level paging c12ayon General 1 04-14-2004 05:58 AM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration