Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this why my system hung?

0 views
Skip to first unread message

Christopher R. Carlen

unread,
Mar 29, 2002, 11:00:09 AM3/29/02
to
Hi:

I am running Suse 7.3 with 2.4.10. I am aware that the 2.4 kernels
require that one has swap = 2 * RAM, but on this machine I hadn't set
that up properly.

I ran a file search on / the other day with Konqueror. Eventually the
hard disk light was stuck on constantly, I could hear it accessing, and
the system was almost entirely unresponsive. I blundered and didn't
have a telnet or ssh port open, so I couldn't get into the thing to shut
it down or kill the offending processes.

The system wasn't crashed, just so swapped out that it took minutes to
respond to individual keystrokes. I managed to Ctrl-Alt-Fn out of X,
but couldn't log in at a console because after typing a username, it
would take more than 1 minute to get to the password prompt, so it timed
out.

I wound up having to hard reset. I otherwise never have instability
problems with the Linux installation, only the normal app crashes.

Did this happen because I don't have swap = 2 * RAM?

Thanks for comments.
--
____________________________________
Christopher R. Carlen
Principal Laser/Optical Technologist
Sandia National Laboratories CA USA
crc...@sandia.gov

Thorsten Hirsch

unread,
Mar 29, 2002, 11:42:39 AM3/29/02
to
Christopher R. Carlen wrote:
> Hi:
>
> I am running Suse 7.3 with 2.4.10. I am aware that the 2.4 kernels
> require that one has swap = 2 * RAM, but on this machine I hadn't set
> that up properly.
> [...]

> Did this happen because I don't have swap = 2 * RAM?

No, you don't need a swap when you've enough memory. My machine has
384MB RAM and no swap and I experienced no problems so far (Mandrake 8.2).
Perhaps your disk is full?

T.

Christopher R. Carlen

unread,
Mar 29, 2002, 2:22:08 PM3/29/02
to
Thorsten Hirsch wrote:


Maybe you have had no problems, but I think it is important to realize
that 2.4 kernels want swap=2*RAM. I read this in an article about
problems people had with the 2.4 kernels when they first began to be
employed in servers. They crashed all over the place. Things improved
a lot after people realized the swap requirements, but 2.4.x still had
stability problems to make it questionable for high load servers until
more recently. I don't know where this fact? is mentioned in the kernel
documentation. Hopefully some knowledgeable person can point this out.


~ $ df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda5 10080488 3086684 6481736 33% /
/dev/hda1 101089 4402 91468 5% /boot

Doesn't look full. I changed my swap partition to 1GB, and put in
another 256MB RAM. I ran the konqueror search again, and watched in
top, that kdeinit ate up to about 450MB of the RAM in the process of the
search. This time I didn't have any problems.

Before, I had 256 MB and about 120MB swap. The system thrashed to
pieces. I am not sure what would have happened if I had 256MB and 512MB
swap.

Still not sure what it all means. I suppose find may be better than
konqueror for file searches.

John-Paul Stewart

unread,
Mar 29, 2002, 2:55:33 PM3/29/02
to
"Christopher R. Carlen" wrote:
>
> Thorsten Hirsch wrote:
>
> > Christopher R. Carlen wrote:
> >
> >> Hi:
> >>
> >> I am running Suse 7.3 with 2.4.10. I am aware that the 2.4 kernels
> >> require that one has swap = 2 * RAM, but on this machine I hadn't set
> >> that up properly.
> >
> > > [...]
> >
> >> Did this happen because I don't have swap = 2 * RAM?
> >
> >
> > No, you don't need a swap when you've enough memory. My machine has
> > 384MB RAM and no swap and I experienced no problems so far (Mandrake 8.2).
> > Perhaps your disk is full?
>
> Maybe you have had no problems, but I think it is important to realize
> that 2.4 kernels want swap=2*RAM. I read this in an article about
> problems people had with the 2.4 kernels when they first began to be
> employed in servers. They crashed all over the place. Things improved
> a lot after people realized the swap requirements, but 2.4.x still had
> stability problems to make it questionable for high load servers until
> more recently. I don't know where this fact? is mentioned in the kernel
> documentation. Hopefully some knowledgeable person can point this out.

It was mentioned on one of the kernel developer mailing
lists, primarily. Last time I checked the archive, though,
the requirement had been lifted. (I think that happened
around kernel 2.4.7, maybe later, but not sooner.)

The machine I'm currently using has 256MB RAM and 128MB
swap. I don't need swap = 2x RAM here, because I hardly
ever hit the swap space at all.



> ~ $ df
> Filesystem 1k-blocks Used Available Use% Mounted on
> /dev/hda5 10080488 3086684 6481736 33% /
> /dev/hda1 101089 4402 91468 5% /boot
>
> Doesn't look full. I changed my swap partition to 1GB, and put in
> another 256MB RAM. I ran the konqueror search again, and watched in
> top, that kdeinit ate up to about 450MB of the RAM in the process of the
> search. This time I didn't have any problems.
>
> Before, I had 256 MB and about 120MB swap. The system thrashed to
> pieces. I am not sure what would have happened if I had 256MB and 512MB
> swap.

OK, that was about 376MB total RAM+swap. If the process
(kdeinit) was using 450MB...well clearly that's your
problem. Probably 256MB swap for 512MB total RAM+swap would
have been adequate. (It depends on the memory usage of the
other running tasks.) But with 512MB RAM and any swap, you
ought to be OK in those circumstances. Mind you, you may
need 1GB swap and 512MB RAM sometimes, depending on what
else you do. Only you can judge.

If you're routinely using more than about 10-20MB of swap,
it's probably a sign that you need more RAM. OTOH, if you
seldom use swap at all, it certainly makes no sense to leave
it at 2x RAM, if you need the diskspace for something else.



> Still not sure what it all means. I suppose find may be better than
> konqueror for file searches.

Well, part of that may be personal preference. But the
command line utilites will almost certainly use less RAM
than their GUI counterparts.

Richard Pitt

unread,
Mar 29, 2002, 3:07:40 PM3/29/02
to
where did you get info on needing 2*RAM for 2.4 kernels?

Linux uses paging - individual pages of processes may get pushed out to
the (now misnamed) swap file based on whether they have been used
recently or not.

Older Unix systems used to swap whole programs out of RAM - and if RAM
got too fragmented, needed enough swap to push almost everything out to
disk and rebuild RAM from swap - this is where the 2*RAM rule of thumb
came from.

Linux swap can get fragmented, so can RAM - but if you get to the point
where the system slows down because of it, you need more RAM.

Rule of thumb today is - if you see your system get more than about
10-20% of its RAM size into swap then you need more RAM. There are
exceptions, but not many. They include really badly coded database
systems where the expectation is that the whole array of data is kept in
RAM but sparse matrix doesn't work correctly and they need to push
"empty" matrix entries out to disk to conserve RAM for the rest of the
active data (only seen this once on a VAX system years ago)

It can also happen if you use the /dev/shm (shared memory) area as
something like /tmp and put a big file into it while the rest of the
system is using lots of RAM. In fact, this may be where you got the idea
that swap should be so large as the default size of /dev/shm seems to be
1/2 of RAM

richard

--
Richard C. Pitt C.E.O. Belcarra Messaging Corp.
ric...@belcarra.com 604-644-9265 www.belcarra.com
Embedded Linux Systems: Design, Creation, Integration
Specializing in USB, Flash, and all things TCP/IP

John Hasler

unread,
Mar 29, 2002, 2:42:56 PM3/29/02
to
Christopher R. Carlen wrote:
> Maybe you have had no problems, but I think it is important to realize
> that 2.4 kernels want swap=2*RAM.

Not in my experience.
--
John Hasler
jo...@dhh.gt.org
Dancing Horse Hill
Elmwood, Wisconsin

Floyd Davidson

unread,
Mar 29, 2002, 4:07:13 PM3/29/02
to
"Christopher R. Carlen" <crc...@sandia.gov> wrote:
>Thorsten Hirsch wrote:
>> Christopher R. Carlen wrote:
>>
>>> Hi:
>>>
>>> I am running Suse 7.3 with 2.4.10. I am aware that the 2.4 kernels
>>> require that one has swap = 2 * RAM, but on this machine I hadn't set
>>> that up properly.
>>
>> > [...]
>>
>>> Did this happen because I don't have swap = 2 * RAM?
>>
>>
>> No, you don't need a swap when you've enough memory. My machine has
>> 384MB RAM and no swap and I experienced no problems so far (Mandrake 8.2).
>> Perhaps your disk is full?

That is absolutely *TRUE*.

However, in fact on a machine with 384Mb of RAM it perhaps would
be of some benefit to add at least some swap. That is because
the system will page out all or parts of programs that are never
active, and the free'd up RAM is then used for disk buffer and
cache, which does make the system faster.

>Maybe you have had no problems, but I think it is important to realize
>that 2.4 kernels want swap=2*RAM. I read this in an article about

That is absolutely *FALSE*. It is based on fact, but confuses
two issues and draws the wrong conclusions as a result.

>problems people had with the 2.4 kernels when they first began to be
>employed in servers. They crashed all over the place. Things improved
>a lot after people realized the swap requirements, but 2.4.x still had
>stability problems to make it questionable for high load servers until
>more recently. I don't know where this fact? is mentioned in the kernel
>documentation. Hopefully some knowledgeable person can point this out.

When first released the 2.4.x kernels simply had a buggy virtual
memory system which was not properly releasing allocated disk
space. The bug was fixed.

That is often confused with the BSD derivation of that buggy virtual
memory system. BSD 4.3 (and I'm not sure which others) required at
least a 1:1 RAM to swap ratio because in order to execute a program
it *had* to be loaded into swap as well as RAM. Virtual memory was
not more than RAM until the swap space was more than RAM. Hence to
have virtual memory equal to twice the RAM size, swap had to be twice
the size of RAM. (That will provide virtual memory 3 times the size
of RAM on Linux.)

The current 2.4.x Linux kernels are not using that virtual
memory system, and it did not have that requirement even when it
was being used.

>~ $ df
>Filesystem 1k-blocks Used Available Use% Mounted on
>/dev/hda5 10080488 3086684 6481736 33% /
>/dev/hda1 101089 4402 91468 5% /boot
>
>Doesn't look full. I changed my swap partition to 1GB, and put in

Clearly "df" does not show stats about either RAM or swap. Try
running "free".

>another 256MB RAM. I ran the konqueror search again, and watched in
>top, that kdeinit ate up to about 450MB of the RAM in the process of the
>search. This time I didn't have any problems.

However, the *ratio* of RAM to swap didn't have *anything* to do
with the differences observed!

>Before, I had 256 MB and about 120MB swap. The system thrashed to
>pieces. I am not sure what would have happened if I had 256MB and 512MB
>swap.

Given what you describe, it was not thrashing to pieces. It was
simply totally out of memory! If you commonly run processes
that use 450Mb of virtual memory, there are some hard and fast
rules that must be followed.

You *must* have more than 450Mb of virtual memory! Virtual
memory (VM) is equal to RAM + swap. Of course using RAM is fast
and using swap is slow. Hence any process that uses more VM
than the amount of RAM is necessarily going to be slow. But if
you have 256Mb of RAM and 120Mb of swap, thats only 376Mb of VM
and a process that needs 450Mb of VM is simply not going to run
at all.

Clearly having 512Mb of RAM not only solved the out of memory
problem, but also avoided having the process run from swap too,
which would have been slow at best. (I'm ignoring the
possibility that other processes may be running at the same
time, and the combination of all processes is what actually
counts, not just any one process.)

Think about the swap should equal two times the RAM concept for
a bit in relation to practical systems. If you have 64Mb of
RAM, and only 128Mb of swap, the machine can't run total
processes exceeding only 192Mb. The way to allow it, with only
64Mb of RAM, to run a process that needs 450Mb is to provide at
least 400Mb or so of swap space. That is more than 5 times as
much swap as RAM.

On the other hand, put 1024Mb of RAM into that box, and there is
simply no requirement at all to have *any* swap space!

The ratio rule of thumb simply does not apply to Linux.

>Still not sure what it all means. I suppose find may be better than
>konqueror for file searches.

--
Floyd L. Davidson <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska) fl...@barrow.com

Christopher R. Carlen

unread,
Mar 29, 2002, 6:22:47 PM3/29/02
to
John-Paul Stewart wrote:

> OK, that was about 376MB total RAM+swap. If the process
> (kdeinit) was using 450MB...well clearly that's your
> problem. Probably 256MB swap for 512MB total RAM+swap would
> have been adequate. (It depends on the memory usage of the
> other running tasks.) But with 512MB RAM and any swap, you
> ought to be OK in those circumstances. Mind you, you may
> need 1GB swap and 512MB RAM sometimes, depending on what
> else you do. Only you can judge.


Yes, I only rarely have trouble with running out of memory with 256MB
and 100MB or so of swap. Occassionally I have a few 10s of MB in swap.
I just stuck in the other 256MB today because it's been sitting on my
desk for a few months with nothing better to do. Don't really need it
usually.

But what puzzles me is how the system behaves when you ask it to do
something that requires more memory than is available. What are the
rules about what Linux will do when it runs out of memory? Shouldn't it
just kick the offending process out?

I suppose I could do something with ulimits to help this...

--

The Real Bev

unread,
Mar 29, 2002, 11:00:23 PM3/29/02
to
"Christopher R. Carlen" wrote:
>
> Hi:
>
> I am running Suse 7.3 with 2.4.10. I am aware that the 2.4 kernels
> require that one has swap = 2 * RAM, but on this machine I hadn't set
> that up properly.
>
> I ran a file search on / the other day with Konqueror. Eventually the
> hard disk light was stuck on constantly, I could hear it accessing, and
> the system was almost entirely unresponsive. I blundered and didn't
> have a telnet or ssh port open, so I couldn't get into the thing to shut
> it down or kill the offending processes.
>
> The system wasn't crashed, just so swapped out that it took minutes to
> respond to individual keystrokes. I managed to Ctrl-Alt-Fn out of X,
> but couldn't log in at a console because after typing a username, it
> would take more than 1 minute to get to the password prompt, so it timed
> out.
>
> I wound up having to hard reset. I otherwise never have instability
> problems with the Linux installation, only the normal app crashes.
>
> Did this happen because I don't have swap = 2 * RAM?
>
> Thanks for comments.

You weren't running Netscape 4.75, were you? Something like this happens
maybe once every other day, and if I don't notice the little xload box filling
up pretty quickly and kill it before it effectively locks out the keyboard and
mouse (I once let it go for an hour to see if anything good happened. It
didn't.) the only thing I can do is a hard reboot, sometimes with severe
punishment. (FWIW, SuSE 7.2, kernel 2.4.4, 128M RAM with 2x swap and plenty
of HD space; it acted the same when I didn't use swap space.)

--
Cheers,
Bev
=-=-=-=-=-=-=-=-=-=-=-=
SAVE GAS, FART IN A JAR

kulls...@attbi.com

unread,
Mar 29, 2002, 8:47:51 PM3/29/02
to
"Christopher R. Carlen" <crc...@sandia.gov> writes:

> John-Paul Stewart wrote:
>
> > OK, that was about 376MB total RAM+swap. If the process
> > (kdeinit) was using 450MB...well clearly that's your
> > problem. Probably 256MB swap for 512MB total RAM+swap would
> > have been adequate. (It depends on the memory usage of the
> > other running tasks.) But with 512MB RAM and any swap, you
> > ought to be OK in those circumstances. Mind you, you may
> > need 1GB swap and 512MB RAM sometimes, depending on what
> > else you do. Only you can judge.
>
>
> Yes, I only rarely have trouble with running out of memory with 256MB
> and 100MB or so of swap. Occassionally I have a few 10s of MB in
> swap. I just stuck in the other 256MB today because it's been sitting
> on my desk for a few months with nothing better to do. Don't really
> need it usually.
>
> But what puzzles me is how the system behaves when you ask it to do
> something that requires more memory than is available. What are the
> rules about what Linux will do when it runs out of memory? Shouldn't
> it just kick the offending process out?

well, sure. but how should it decide which process is offensive? the
most recent? the largest? the one which has languished in swap the
longest without being used? unfortunately, i think this problem is AI
complete.

> I suppose I could do something with ulimits to help this...

yes. ulimit could help.

i figure disk space is cheap. you can get a 40GB IDE drive for less
than $100. even at $100, that's $2.50 per GB. just spend half a
lunch money and allocate a gig of swap.

even better imho is to find a smallish old (but not *too* old) drive
and just make the whole thing swap. for example, a five year old 3GB
5200 rpm drive dedicated to swap is great. what you lose in drive
speed you pretty much gain back in that your head arm doesn't have to
seek back and forth between swap partition and data/program if they're
on the same disk. and even if it's an old drive about to blow out,
it's only your swap.

--
Johan KULLSTAM

0 new messages