Question about RAM allocation and what 'seems' like very odd swap use
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Question about RAM allocation and what 'seems' like very odd swap use
I'm running Slackware on a notebook and even though I stick more or less exclusively to Fluxbox and not KDE or Gnome, I sometimes have literally a dozen or more instances of firefox open simultaneously along with a number of other programs scattered about - but my swap partition never gets used... I've on perhaps 3 occasions in 3-4 months seen it claim to be using somewhere around 100k of the 400mb partition, but it almost looks like I managed to somehow or other make it just plain unusable -- so here's my question...
Am I just too used to Windows after having used it all those years? Or isn't the swap partition available for use for some reason? Here's some of the hardware info...
AMD Athlon XP 2800+ (2.12GHz), IGP320M integrated graphics (set for 64mb out of the 512mb total ram), 60gb HDD with 1 primary partition and the rest logical, in order: 20gb NTFS, 15gb ReiserFS (v3.6), around 20gb vfat, and finally my 400mb swap. It's definitely marked as being of type swap, and swapon happily loads it, etc. Oh, and I'm running a 2.6.12.1. Kernel now, but don't remember it having been any different with the others I've compiled.
Also, if I eliminated the swap partition altogether, how would the system react if I filled the ram to capacity - Kernel panic, crawling at a standstill until some of the RAM cleared, or...? The likely result I mean, I'm sure it isn't quite that predictable in reality.
if you have 448mb of ram (512 - 64) and fluxbox there's really no reason why you should have swap usage if all you are using is firefox and a few other small apps...
if you've seen your swap usage go up to 100k then you know it's working...
if you would eliminate your swap and your memory would run-out then your system would crash and you'd have to reboot...
win32sux, if the kernel detects that there is no
more ram available, it begins to kill processes
until some amount of ram is free'd
The system won't crash
Originally posted by keefaz win32sux, if the kernel detects that there is no
more ram available, it begins to kill processes
until some amount of ram is free'd
The system won't crash
okay maybe "crash" wasn't the right word... but still, it would "crawl to a standstill"... i know because i've tried it and all i could do was reboot...
as for the "it begins to kill processes", i honestly didn't know that... could you please elaborate?? i was under the impression that what it would do was clear cached memory and make it available - but that once the processes had no more memory available from anywhre well they'd start going into shock and die a segfaultish death... how does the kernel know which processes to start killing once memory runs out?? and why doesn't it seem to do that when i intentionally run my box out of memory?? i'm using 2.4.29...
PS: i'm gonna test this right now again just to be sure... last time i did this i did have a defective ram stick which might have contributed to my crash/freeze... i will now proceed to disable my swap and open all my little apps... i only have 128MB by the way... i'll report in a few minutes...
okay, tried it... my system didn't crash... X11 was automatically killed/restarted (as were all the apps i was running in it) and i was able to log back in and do it all over again - without having to reboot...
so yeah, the crash i was experiencing when doing this before was due to my faulty ramstick - something completely unrelated...
thanks for clearing that up, keefaz...
BTW, i'm still interested in learning what methodology the kernel uses to select which processes to kill when memory runs out...
Originally posted by keefaz I think it kills process by PID order
The highest to the lowest (init has PID 1)
No, there's an algorithm used to determine which process should be killed. From the top of the oom_kill.c file
Code:
/**
* oom_badness - calculate a numeric value for how bad this task has been
* @p: task struct of which task we should calculate
* @p: current uptime in seconds
*
* The formula used is relatively simple and documented inline in the
* function. The main rationale is that we want to select a good task
* to kill when we run out of memory.
*
* Good in this context means that:
* 1) we lose the minimum amount of work done
* 2) we recover a large amount of memory
* 3) we don't kill anything innocent of eating tons of memory
* 4) we want to kill the minimum amount of processes (one)
* 5) we try to kill the process the user expects us to kill, this
* algorithm has been meticulously tuned to meet the principle
* of least surprise ... (be careful when you change it)
*/
I've had it kill VMWare a few times recently, if the OOM killer kicks in you'll see something like this in your logs:
Quote:
oom-killer: gfp_mask=0xd0
DMA per-cpu:
cpu 0 hot: low 2, high 6, batch 1
cpu 0 cold: low 0, high 2, batch 1
cpu 1 hot: low 2, high 6, batch 1
cpu 1 cold: low 0, high 2, batch 1
Normal per-cpu:
cpu 0 hot: low 32, high 96, batch 16
cpu 0 cold: low 0, high 32, batch 16
cpu 1 hot: low 32, high 96, batch 16
cpu 1 cold: low 0, high 32, batch 16
HighMem per-cpu: empty
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.