LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-12-2006, 09:52 PM   #1
ideasman
LQ Newbie
 
Registered: Mar 2004
Location: Australia
Distribution: Home brew
Posts: 25

Rep: Reputation: 15
Advanced Linux memory management?


People often say how stable linux is- but There is a problem I have come accross that can crash linux fairly easerly.
Possibly there is a different solution then the one Im looking for, so bare with me...


Basicly the problem is when a system runs out of ram it uses swap but in extreame cases this can practicaly lock up the system because its swapping so much.

So Id like to set some dynamic limits for memory usage..

The first rule is that certain processes should ALWAYS be able to have some free memorty- for eg. X11, window managers etc have access to say 128 meg of reserved ram. - so if some app deciedes it wants to use all the memory, it will fail a MALLOC if it gets to the point where there is only 128 meg of ram left.

There must be options as to how big the reserved pool is, and what processes can eccess it.

The idea is that an app its self can get crash if theres no memory, but not put the system at risk..


One thing I have noticed about WinXP is that (Mostly) - applications that try to use too much memory will crash. but the UI its self will remain responsive. - Windows probably has some kernal link with the UI so this happens.


I have used ulimit, but this is not a good solution, because it dosent account for loading more then 1 program- where the combine ulimit may still use up heaps of memory.

Is the solution to have a user that has limited memory usage?

- Would be interested in how others have overcome this problem.
 
Old 02-12-2006, 10:36 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
There is a kernel module developed b the audio people a SE Linux called realtime-lsm that uses the kernel security structure that to give essentially realtime privaledges to users groups or processes.
with that you can give whatever you like the ability to lock memory.

and this has for a long while been a part of SE type Linux distributions
Quote:
Red Hat Enterprise Linux 3 now allows non-root processes to use user-mode memory locking system calls within the bounds of their RLIMIT_MEMLOCK resource limit. The default limit is one physical page per process. Limits can be reassigned by the system administrator on a per user-id, per group-id, or system-wide basis via the /etc/security/limits.conf file. Root processes are no longer constrained by this resource limit.
you are sugesting i think that x out of the box be like this but that decides for people x is more important that stuff in the background which seems like the opposite of what it should be.

what do we care that on rare instances x takes a few seconds to respond ?
is x doing something horribly critical ?
 
Old 02-12-2006, 10:38 PM   #3
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Just out of curiousity, what are the system specs of your rig, and what steps/actions do you take that can cause Linux to crash? I'm interested in this for sure.

Overall I'm not sure I can answer your question, but if if you are using swap heavily, then any performance slowdowns are almost certainly the result of the fact that your system has exhausted RAM, and the system is being forced to write memory pages to disk, which as you know is horribly inefficient. In terns of resovling this issue, could the simplest solution be to simply add more RAM?
 
Old 02-13-2006, 02:06 AM   #4
ideasman
LQ Newbie
 
Registered: Mar 2004
Location: Australia
Distribution: Home brew
Posts: 25

Original Poster
Rep: Reputation: 15
foo_bar_foo- its not about X taking a few seconds- it that X can be so slow that killing the offending process can be imporrible because X takes so long to respond its not useable.
Sometimes X11 even quits because the system is so overloaded- and thats the best case.
The worst case is I need to turn my PC off risking fs-damage.

I probably need to expand on what I do...
My system is a cheapish workstation, not a server- just a amd64, 4gig ram- 1tb storage, all stock parts.. I do some batch imaging (sat imagery) - or dealing with many images...
Most of the time it runs quite stabaly- but Its annoying when some app is able to crash the system. - say thumbnailing images in XNView was able to crash my system..

Also, X11 dying is not mission critical- but it may mean lost work which is not ideal.


It would be nice if say. X11 and spesific desktop processes could reserve some memory for themselves.
 
Old 02-14-2006, 12:18 AM   #5
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
it is not normal for you to be able to crash your system.
so something other than just normal ram preasure and swapping is going on.
i'm trying to think.
you don't say what kernel you are using or how much swap you have.

i think you just don't have enough swap !
64 bit processors don't have the same constraints 32bit processors do on memory bandwidth so you should have lots of huge swap partitions.

what you are doing must be creating alot of unique data that is not disk backed and goes in swap cue.
so when memory gets used up there is not enough swap to hold all necesary data plus keep x and freinds unique data safe and room to load necesary code.
kswapd starts shuffling out code to compensate. even the code for the process you are running may be thrashing all the way from disk to cpu and still not able to have enough room to hold on to all generated unique data.
it's a crash situation exactly like having no swap at all.

Quote:
It would be nice if say. X11 and spesific desktop processes could reserve some memory for themselves.
they do ! any data generated that is not already on disk like in the executable itself imediately gets a spot in the swap cue.


for your amd64 128 different swap areas are permitted, each can be up to 16 Tb huge.
so you are certainly not lacking for a way to fix this problem.
the kernel is ready to use a couple of thousand disks as swap partitions.
if you can't make new partitions at this point (swap partitions are faster) make swap files.
like
dd if=/dev/zero of=/extraswap bs=1M count=8192
mkswap /extraswap
swapon /extraswap

now you got an extra 8 Gb swap

Last edited by foo_bar_foo; 02-14-2006 at 12:24 AM.
 
  


Reply



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
Regarding Memory management in Linux alfredhitchcock Programming 4 09-07-2004 03:20 AM
advanced users management tux2002 Linux - Security 1 05-04-2004 10:00 AM
Linux Memory Management beatlelane Red Hat 5 10-04-2003 12:39 AM
linux memory management kb8doa Linux - Newbie 1 06-18-2003 10:36 AM
Advanced Power Management rdanda Slackware 6 04-09-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:09 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration