Re: Long lasting MM bug when swap is smaller than RAM

From: Zan Lynx
Date: Wed Jul 01 2009 - 19:16:29 EST


Attila Kinali wrote:
On Wed, 1 Jul 2009 10:04:32 +0200
Attila Kinali <attila@xxxxxxxxx> wrote:

But swapping does not only occur if memory is running low. If disk usage is high then non-recently used data may be swapped out to make more room for disk caching.
Hmm..I didn't know this.. thanks!

This was the cause of the problem!

I just restarted svnserv, clamav and bind (the three applications
using most memory) and suddenly swap cleared up.

Now the question is, why did they accumulate so much used swap
space, while before the RAM upgrade, we hardly used the swap space at all?

I do not know about the others, but ClamAV suffers from pretty serious memory fragmentation. What it does is load the updated signatures into a new memory allocation, verify them, then free the old signature allocation. This results in a large hole in glibc's malloc structures and because of ClamAV's allocation pattern, this hole is difficult to reclaim. This ClamAV memory fragmentation will continue to grow worse until the daemon is completely restarted.

Under memory pressure the kernel pushes least used pages out to swap, and these unused but still allocated pages of ClamAV are never again used, so out to swap they go.

I know this because the company I work for tried to fix the memory allocation fragmentation of ClamAV, but they did not like our patch and preferred to continue allowing the memory allocator to fragment in exchange for simpler code.

--
Zan Lynx
zlynx@xxxxxxx

"Knowledge is Power. Power Corrupts. Study Hard. Be Evil."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/