Re: Increasing swap limits

Linus Torvalds (
Sun, 29 Sep 1996 13:09:55 +0200 (EET)

On Sat, 28 Sep 1996 wrote:
> I would like to go out and buy a 2G disk and throw it in as a dedicated
> swap drive. However, from the docs and what I can understand in the
> source, Linux can only handle 1G of swap made up of a maximum of 8
> swapfiles or partitions of a maximum of 128M apiece.


> It looks like all I have to do to increase the maximum number of swap
> areas is to change MAX_SWAPFILES in the kernel source.

Indeed. That's the easy way out - just increame MAX_SWAPFILES to 16 (or more
- there is _some_ limit, but I think the limit is something like 127 or
something like that, and even that limit is mainly due to some internal
non-present page representation that should be pretty easy to modify).

> But I would also
> like to be able to use larger partitions. To do that it looks like I
> will have to change the swapfile format from a one-page map to a
> multi-page map. Is it this simple, or are there other non-obvious
> factors that limit the maximum swap size? If I understand correctly,
> each process is limited to 3G of address space because of the way the
> kernel space is mapped in, but shouldn't we be able to have much more
> swap total?

Yes, there is a 3GB per-process VM limit, but the total VM limit is probably
on the order of 2G _pages_, ie something like 8TB (now, that's the
theoretical limit on x86 with the current swap setup, in practice I don't
think you can easily approach that, but swap space in the hundreds of GB's
should be attainable).

As you correctly have found out, the current 128MB swap limit is due to using
a one-page bitmap in the swap file, and no, there is nothing fundamental
about that (it just makes some things easier). You should be able to
reasonably easily extend the swap file format to have a multi-page bitmap,
and increase the current 128MB limit to 256 or 512GB by using two or four
pages for it all.