Re: Swap maximum size documented ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 01, 2005 at 03:47:05PM -0400, Bill Davidsen wrote:
>> mmap() is limited only by file offsets, which are fully 32-bit on
>> 32-bit systems. remap_file_pages() is limited by PTE_FILE_MAX_BITS,
>> which is fully 32-bit with CONFIG_HIGHMEM64G=y on i386 but only 29 bit
>> without it on i386. In general checking for PTE_FILE_MAX_BITS on the
>> relevant architecture should answer your question for remap_file_pages(),
>> and BITS_PER_LONG for mmap(). The swap limits for other architectures
>> will also differ and you generally have to look at the swp_entry/pte
>> encoding/decoding macros to decipher what the precise limits are
>> (though a quick hacky C program can help discover them for you).
>> Generally you get the filesizes by PAGE_SIZE << X_FILE_OFFSET_BITS.

The hacky C program. Note that some fiddling with compiler flags is
needed to get it to compile at all, and you probably need to have
done make oldconfig or similar to prep the kernel tree too. The answer
necessarily varies with your .config and it won't work cross-arch
except in the 32/64 -bit variant case (in which case it must be
compiled as the same kind of app [32/64] the kernel is expected to be).

The expressions for the swap limits were taken from sys_swapon().

This should remove all doubt, if any remain.


#include <linux/config.h>
#include <linux/swap.h>
#include <asm/pgtable.h>
#include <linux/swapops.h>

int printf(const char *, ...);

int main(void)
{
	unsigned long long type, offset;

	type = swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))));
	offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0,~0UL)))) - 1;
	offset = (offset << PAGE_SHIFT) + ~PAGE_MASK;

	printf("max swapfiles = %Lu files\n", type);
	printf("max swapsize = %Lu B\n", offset);
	return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux