Call me an idiot. How is it even remotely possible that turning off swap restores memory shared between processes? Is the Linux kernel going from process to process comparing pages of memory as they re-enter RAM? "Oh, those two look identical, they'll get shared?"
-Incredulous -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 14, 2002 8:24 AM To: Bill Marrs Cc: [EMAIL PROTECTED] Subject: Re: loss of shared memory in parent httpd >>>>> On Thu, 14 Mar 2002 07:25:27 -0500, Bill Marrs <[EMAIL PROTECTED]> said: >> It's copy-on-write. The swap is a write-to-disk. >> There's no such thing as sharing memory between one process on disk(/swap) >> and another in memory. > agreed. What's interesting is that if I turn swap off and back on > again, the sharing is restored! So, now I'm tempted to run a crontab > every 30 minutes that turns the swap off and on again, just to keep > the httpds shared. No Apache restart required! Funny, I'm doing this for ages and I never really knew why, you just found the reason, Thank You! My concerns were similar to yours but on a smaller scale, so I did not worry that much, but I'm running a swapflusher regularly. Make sure you have a recent kernel, because all old kernels up to 2.4.12 or so were extremely unresponsive during swapoff. With current kernels, this is much, much faster and nothing to worry about. Let me show you the script I use for the job. No rocket science, but it's easy to do it wrong. Be careful to maintain equality of priority among disks: use strict; $|=1; print "Running swapon -a, just in case...\n"; system "swapon -a"; print "Running swapon -s\n"; open S, "swapon -s |"; my(%prio); PARTITION: while (<S>) { print; next if /^Filename/; chop; my($f,$t,$s,$used,$p) = split; my $disk = $f; $disk =~ s/\d+$//; $prio{$disk} ||= 5; $prio{$disk}--; if ($used == 0) { print "Unused, skipping\n"; next PARTITION; } print "Turning off\n"; system "swapoff $f"; print "Turning on with priority $prio{$disk}\n"; system "swapon -p $prio{$disk} $f"; } system "swapon -s"; Let me know if you see room for improvements, Regards, -- andreas ------------------------------------------------------------------------------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.