Click here to close now.

Welcome!

Linux Authors: Elizabeth White, Carmen Gonzalez, Pat Romanski, Louis Evans, Jason Bloomberg

Related Topics: Linux

Linux: Article

VM: Virtual Memory or Virtual Mayhem?

How to solve the virtual memory problem in all Linux kernels.

(LinuxWorld) -- The fur has been flying in the Linux kernel development community of late, particularly because there's a lot of contention about how Linux should do virtual memory management (VM). Andrea Arcangeli and Rik van Riel have the two most visible opinions on how the VM should work, so they're often seen as at the heart of the struggle. However, it goes much deeper than that. The VM even seems like a hot button between Linus Torvalds and Alan Cox, although I'm guessing they're not as passionate about the issue as the journalists would like them to be to get mileage out of the topic.

Take us, for example. None other than our own Joshua Drake called the 2.4 Kernel the Kernel of pain, primarily because of problems with the VM algorithms and changes. Yours truly complained a little about the VM last August.

I'm about to weigh in once again about how I feel about VM, only in more detail this time. We're definitely into milking this topic for all it's worth.

After looking at the various VM algorithms in play, I've come up with an alternative. I'm sure Andrea Arcangeli and Rik van Riel are flooded with the same old suggestions over and over again, and it's entirely possible they've heard this one before. Nevertheless, I'll propose it, anyway.

First, let me walk you through a little of the history that gave me the notion of how best to deal with the Linux VM issue.

The brain-dead system that wouldn't die

Back when I was a programmer by trade, one of the projects I worked on involved Fortran programming for a farm of PDP-11s. I honestly don't remember which OS we had installed on the PDPs, but if I had to guess I'd say it was probably RSX-11/M.

What I'll never forget, however, is the one quirk I hated beyond all others. You couldn't run executable files unless they were stored in contiguous blocks on the disk.

Programmers are a virtual disk frag factory, so we ran out of contiguous space almost daily. This means we often found ourselves in the uncomfortable situation where we could no longer test the modifications to our programs until someone defragged the drives. The worst of it was that, if there was such a thing as a disk defrag utility available, the systems guys obviously didn't know about it. They solved the problem by taking the systems off line, backing up, and then restoring the contents of the drives. We couldn't even edit code while we waited.

By the way, Microsoft credits Windows NT architect Dave Cutler as the designer of RSX-11/M (see resources). As tempting as it might be to compare the brain-dead pieces of Windows NT to the bizarre behavior of RSX-11/M, it would be unfair to do so for two reasons. First, more reliable sources than Microsoft only credit Cutler for the design of VMS. Cutler borrowed some RSX-11/M code for VMS, but didn't design RSX-11/M. Second, RSX-11/M was probably only brain-dead because the PDP-11 wasn't much of a brain.

Any computer historian knows the PDP-11 was a breakthrough in affordable computing in its time. Compared to today's desktops, it would be like taking out a second mortgage to buy an abacus. A PDP-11 computer with 8K words of core memory and a 256K disk cost about $30,000 in 1972. It could run you thousands of dollars for an additional 4K of memory.

It may be possible that the RSX-11/M architect was an idiot. It is also possible that the resident portion of the RSX-11/M kernel would have to exceed the size of the typical memory configuration for the PDP-11 in order to change this behavior, which would inflate the price of the system in the process.

I don't happen to recall how much memory we had on our PDP-11s or how much of it was used by RSX-11/M. However, I do know we never had enough. I had to implement overlays to make my Fortran programs work. In case you're not an old fart as I am, overlays are a bit like implementing virtual memory at the application level instead of the OS. You split off parts of your program into modules called overlays. The main program loads an overlay whenever it needs the functions in that overlay.

The trick is to make sure that none of your overlays rely on functions that reside in any other overlays, because your goal is to have only one overlay in memory at a time. I'm not even sure it was possible to have more than one loaded, but it's been too long to remember. Regardless, I'd bet the company paid at least double my yearly salary for some of those PDP-11s, so it was worth the relatively minimal effort for me to break up my program into overlays.

The new VM proposal

What does this have to do with virtual memory performance on the Linux 2.4 kernel?

Everything.

First, think about what the VM is for. The VM is like an extremely sophisticated automated overlay system, only it deals with many more types of memory storage. It is the part of the OS that comes to the rescue when you have used up all your expensive memory and need more.

Here's how it works. The OS finds some data in memory that can safely be removed and stores it to the cheaper storage (disk swap space), which frees up some expensive memory for other use. When a program needs the data that has been swapped to disk, the OS swaps something else out to disk and brings the needed data back into memory.

Most of the arguments about the VM in Linux revolve around how the OS should decide which memory is swapped and when, and methods to make the process fast and painless.

The remaining arguments are usually about what the OS needs to do when you've filled up all available memory and swap space but some task still needs even more memory. In this case, most people agree that the OS needs to kill one or more running tasks to free up memory. Since you're talking about stopping programs dead in their tracks, you have to address the issue of how the OS decides which tasks are less important than others and can afford to be killed.

If you don't see how this relates to my PDP story yet, then here's a hint. The controversy over the VM involves several extremely talented programmers, each of whom could command hundreds of thousands of dollars per year in salaries. They have been spending a great deal of their time and brain power over the past years figuring out how to squeeze the best performance out of systems with limited RAM and drive space.

Still don't get it? Then let me get right to my proposal for a new VM algorithm for Linux. Granted, this VM algorithm is not meant for typical system loads, but it would solve the most annoying VM problems.

I propose that we create a kernel daemon that checks for either of the following two conditions:

  1. The system swaps to disk so much that you see a severe degradation in performance.
  2. A task needs memory after all available RAM and swap is filled.

If either condition is met, the kernel then kills all tasks except those it needs to display the following message on the screen: "Lay off the doughnuts this week and spend the money to buy another DIMM, you penny pinching skinflint!"

As a bonus, the daemon could check the Internet for current pricing and replace the part about "doughnuts" with some comparison that better represents the current state of the market.

Again, I apologize to Andrea and Rik if this has already been suggested, and I suspect it has. Nevertheless, it was therapeutic, if not useful, to offer the advice.

More Stories By Nicholas Petreley

Nicholas Petreley is a computer consultant and author in Asheville, NC.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that On the Avenue Marketing Group, a sales and marketing firm that utilizes events to market and sell products to consumers, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. On the Avenue Marketing Group (OTA) is a sales and marketing firm that utilizes events to market and sell products to consumers. On behalf of our clients, we attend thousands of fairs, festivals, expos, concerts, conferences, and sporting events annually, helping them reach millions of individuals ...
SYS-CON Events announced today that BroadSoft, the leading global provider of Unified Communications and Collaboration (UCC) services to operators worldwide, has been named “Gold Sponsor” of SYS-CON's WebRTC Summit, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. BroadSoft is the leading provider of software and services that enable mobile, fixed-line and cable service providers to offer Unified Communications over their Internet Protocol networks. The Company’s core communications platform enables the delivery of a range of enterprise and consumer calling...
SYS-CON Events announced today that ActiveState, the leading independent Cloud Foundry and Docker-based PaaS provider, has been named “Silver Sponsor” of SYS-CON's DevOps Summit New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. ActiveState believes that enterprises gain a competitive advantage when they are able to quickly create, deploy and efficiently manage software solutions that immediately create business value, but they face many challenges that prevent them from doing so. The Company is uniquely positioned to help address these challenges thro...
SYS-CON Events announced today that Vitria Technology, Inc. will exhibit at SYS-CON’s @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Vitria will showcase the company’s new IoT Analytics Platform through live demonstrations at booth #330. Vitria’s IoT Analytics Platform, fully integrated and powered by an operational intelligence engine, enables customers to rapidly build and operationalize advanced analytics to deliver timely business outcomes for use cases across the industrial, enterprise, and consumer segments.
SYS-CON Events announced today that Alert Logic, the leading provider of Security-as-a-Service solutions for the cloud, has been named “Bronze Sponsor” of SYS-CON's 16th International Cloud Expo® and DevOps Summit 2015 New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY, and the 17th International Cloud Expo® and DevOps Summit 2015 Silicon Valley, which will take place November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Akana, formerly SOA Software, has been named “Bronze Sponsor” of SYS-CON's 16th International Cloud Expo® New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. Akana’s comprehensive suite of API Management, API Security, Integrated SOA Governance, and Cloud Integration solutions helps businesses accelerate digital transformation by securely extending their reach across multiple channels – mobile, cloud and Internet of Things. Akana enables enterprises to share data as APIs, connect and integrate applications, drive part...
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY, and the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and sim...
SYS-CON Events announced today that SafeLogic has been named “Bag Sponsor” of SYS-CON's 16th International Cloud Expo® New York, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. SafeLogic provides security products for applications in mobile and server/appliance environments. SafeLogic’s flagship product CryptoComply is a FIPS 140-2 validated cryptographic engine designed to secure data on servers, workstations, appliances, mobile devices, and in the Cloud.
SYS-CON Events announced today that StorPool Storage will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. StorPool is distributed storage software that allows service providers, enterprises and other cloud builders to run data storage on standard x86 servers, instead of using expensive and inefficient storage arrays (SAN).
SYS-CON Events announced today that Site24x7, the cloud infrastructure monitoring service, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Site24x7 is a cloud infrastructure monitoring service that helps monitor the uptime and performance of websites, online applications, servers, mobile websites and custom APIs. The monitoring is done from 50+ locations across the world and from various wireless carriers, thus providing a global perspective of the end-user experience. Site24x7 supports monitoring H...
SYS-CON Events announced today that Intelligent Systems Services will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Established in 1994, Intelligent Systems Services Inc. is located near Washington, DC, with representatives and partners nationwide. ISS’s well-established track record is based on the continuous pursuit of excellence in designing, implementing and supporting nationwide clients’ mission-critical systems. ISS has completed many successful projects in Healthcare, Commercial, Manufacturing, ...
SYS-CON Events announced today that B2Cloud, a provider of enterprise resource planning software, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. B2cloud develops the software you need. They have the ideal tools to help you work with your clients. B2Cloud’s main solutions include AGIS – ERP, CLOHC, AGIS – Invoice, and IZUM
The IoT Bootcamp is coming to Cloud Expo | @ThingsExpo on June 9-10 at the Javits Center in New York. Instructor. Registration is now available at http://iotbootcamp.sys-con.com/ Instructor Janakiram MSV previously taught the famously successful Multi-Cloud Bootcamp at Cloud Expo | @ThingsExpo in November in Santa Clara. Now he is expanding the focus to Janakiram is the founder and CTO of Get Cloud Ready Consulting, a niche Cloud Migration and Cloud Operations firm that recently got acquired by Aditi Technologies. He is a Microsoft Regional Director for Hyderabad, India, and one of the f...
SYS-CON Events announced today that Tufin, the market-leading provider of Security Policy Orchestration Solutions, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. As the market leader of Security Policy Orchestration, Tufin automates and accelerates network configuration changes while maintaining security and compliance. Tufin's award-winning Orchestration Suite™ gives IT organizations the power and agility to enforce security policy across complex, multi-vendor enterprise networks. With more than 1...
VoxImplant has announced full WebRTC support in the newest versions of its Android SDK and iOS SDK. The updated SDKs, which enable audio and video calls on mobile devices, are now compatible with the WebRTC standard to allow any mobile app to communicate with WebRTC-enabled browsers, including Google Chrome, Mozilla Firefox, Opera, and, when available, Microsoft Spartan. The WebRTC-updated SDKs represent VoxImplant's continued leadership in simplifying the development of real-time communications (RTC) services for app developers. VoxImplant (built by Zingaya, the real-time communication servi...
SYS-CON Events announced today that kintone has been named “Bronze Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY, and the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. kintone promotes cloud-based workgroup productivity, transparency and profitability with a seamless collaboration space, build your own business application (BYOA) platform, and workflow automation system.
SYS-CON Events announced today that Cloudian, Inc., the leading provider of hybrid cloud storage solutions, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Cloudian, Inc., is a Foster City, California - based software company specializing in cloud storage software. The main product is Cloudian, an Amazon S3-compliant cloud object storage platform, the bedrock of cloud computing systems, that enables cloud service providers and enterprises to build reliable, affordable and scalable cloud storage solu...
SYS-CON Events announced today that Gridstore™, the leader in hyper-converged infrastructure purpose-built to optimize Microsoft workloads, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Gridstore™ is the leader in hyper-converged infrastructure purpose-built for Microsoft workloads and designed to accelerate applications in virtualized environments. Gridstore’s hyper-converged infrastructure is the industry’s first all flash version of HyperConverged Appliances that include both compute and storag...
SYS-CON Events announced today that IDenticard will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. IDenticard™ is the security division of Brady Corp (NYSE: BRC), a $1.5 billion manufacturer of identification products. We have small-company values with the strength and stability of a major corporation. IDenticard offers local sales, support and service to our customers across the United States and Canada. Our partner network encompasses some 300 of the world's leading systems integrators and security s...
SYS-CON Events announced today that SoftLayer, an IBM company, has been named “Gold Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place June 9-11, 2015 at the Javits Center in New York City, NY, and the 17th International Cloud Expo®, which will take place November 3–5, 2015 at the Santa Clara Convention Center in Santa Clara, CA. SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from ...