Re: [patch] large swap areas

Jakub Jelinek (
Tue, 24 Feb 1998 10:27:59 +0100 (MET)

> Hi,
> I've made a patch to handle large swap spaces (larger than the ~128MB limit).
> It features some compatibility with the older swap space format. I don't
> know the new limit, but at least 1GB seems to work on x86. The corresponding
> patch to mkswap.c (from util-linux-2.7.1) is appended too.
> Also in this patch, kswapd_setup() and init_swap_timer() are made
> __initfunc() (I'm not sure if it's ok).
> This is my first kernel patch, so comments are welcome.

While you are at it, it would be good to handle disklabels inside of the
partition as well. At the moment it is not possible to have swap as first
partition on the disk on Sparc/UltraLinux boxes. First 512B of the disk
needs to be partition table (disklabel), next 512B have boot loader (in case
of SILO, Solaris boot loader takes 8K-512B).
So I'd suggest a NEW-SWAP-SPACE format, which would:

a) leave first 8K undefined
b) then at 8K it would contain the new signature, e.g.:
then u64 size of the swap space
then u32 PAGE_SIZE for which it was made
then u32 number of lockmap pages including this one
if 0, then all the swap space but first 8K+PAGE_SIZE is usable
(ie. lockmap would contain on PAGE_SIZE 4K bits 0 0 0 1 1 1 ... 1 1 1
on PAGE_SIZE 8K 0 0 1 1 1 ... 1 1), if non-zero, following
this number will be the lockmap
c) so that we maintain backwards compatibility with older swaps on non-sun
boxes (Solaris x86 uses similar disk labels), mkswap would check, if
the disk contains valid Sun disklabel (Big Endian 0xDABE???? as last
u32 in first 512K of the disk). If yes, it would not touch first 8K of
the disk at all and just write the new signature; if not, it would
write both old and new signature page, where in the old at least first
3 (for 4K pages) or 2 (for 8K pages) bits were cleared.
d) old kernel would keep working as it used to, new kernel would
first try to read old signature page. If it sees SWAP-SPACE at the end,
it would check first 3 (2) bits. If they were cleared or if SWAP-SPACE
signature is not present, it would try to read the new signature page...

What do you think about that? If you'd like to code it, I'd be happy to test
it for you, if not, I can write it if I find a spare time for it...
Any comments?

BTW: If swap_lockmap and/or swap_map is small enough, it would probably be
better to try to allocate it with __get_free_pages(,order) first, as on some
architectures vmalloc results in slower access than __get_free_pages()...

Jakub Jelinek | |
Administrator of SunSITE Czech Republic, MFF, Charles University
Ultralinux - first 64bit OS to take full power of the UltraSparc
Linux version 2.1.88 on a sparc64 machine (498.80 BogoMips).

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to